[email protected] | 59b0e60 | 2014-01-30 00:41:24 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef EXTENSIONS_BROWSER_EXTENSION_SYSTEM_H_ |
| 6 | #define EXTENSIONS_BROWSER_EXTENSION_SYSTEM_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | |
| 10 | #include "base/memory/ref_counted.h" |
[email protected] | b33f0b11 | 2014-03-13 17:05:30 | [diff] [blame] | 11 | #include "components/keyed_service/core/keyed_service.h" |
[email protected] | 59b0e60 | 2014-01-30 00:41:24 | [diff] [blame] | 12 | #include "extensions/common/extension.h" |
| 13 | |
| 14 | class ExtensionService; |
| 15 | |
| 16 | #if defined(OS_CHROMEOS) |
| 17 | namespace chromeos { |
| 18 | class DeviceLocalAccountManagementPolicyProvider; |
| 19 | } |
| 20 | #endif // defined(OS_CHROMEOS) |
| 21 | |
| 22 | namespace content { |
| 23 | class BrowserContext; |
| 24 | } |
| 25 | |
| 26 | namespace extensions { |
| 27 | |
| 28 | class Blacklist; |
[email protected] | fd3df778 | 2014-05-08 23:54:27 | [diff] [blame] | 29 | class ContentVerifier; |
[email protected] | 59b0e60 | 2014-01-30 00:41:24 | [diff] [blame] | 30 | class ErrorConsole; |
| 31 | class EventRouter; |
| 32 | class Extension; |
| 33 | class ExtensionWarningService; |
| 34 | class InfoMap; |
| 35 | class InstallVerifier; |
| 36 | class LazyBackgroundTaskQueue; |
| 37 | class ManagementPolicy; |
| 38 | class OneShotEvent; |
| 39 | class ProcessManager; |
[email protected] | aab2310 | 2014-02-05 18:57:55 | [diff] [blame] | 40 | class QuotaService; |
[email protected] | 59b0e60 | 2014-01-30 00:41:24 | [diff] [blame] | 41 | class RuntimeData; |
| 42 | class StateStore; |
| 43 | class UserScriptMaster; |
| 44 | |
| 45 | // ExtensionSystem manages the lifetime of many of the services used by the |
| 46 | // extensions and apps system, and it handles startup and shutdown as needed. |
[email protected] | b33f0b11 | 2014-03-13 17:05:30 | [diff] [blame] | 47 | // Eventually, we'd like to make more of these services into KeyedServices in |
| 48 | // their own right. |
| 49 | class ExtensionSystem : public KeyedService { |
[email protected] | 59b0e60 | 2014-01-30 00:41:24 | [diff] [blame] | 50 | public: |
| 51 | ExtensionSystem(); |
| 52 | virtual ~ExtensionSystem(); |
| 53 | |
| 54 | // Returns the instance for the given browser context, or NULL if none. |
[email protected] | 59b0e60 | 2014-01-30 00:41:24 | [diff] [blame] | 55 | static ExtensionSystem* Get(content::BrowserContext* context); |
| 56 | |
| 57 | // Initializes extensions machinery. |
| 58 | // Component extensions are always enabled, external and user extensions are |
| 59 | // controlled by |extensions_enabled|. |
| 60 | virtual void InitForRegularProfile(bool extensions_enabled) = 0; |
| 61 | |
| 62 | // The ExtensionService is created at startup. |
| 63 | virtual ExtensionService* extension_service() = 0; |
| 64 | |
| 65 | // Per-extension data that can change during the life of the process but |
| 66 | // does not persist across restarts. Lives on UI thread. Created at startup. |
| 67 | virtual RuntimeData* runtime_data() = 0; |
| 68 | |
| 69 | // The class controlling whether users are permitted to perform certain |
| 70 | // actions on extensions (install, uninstall, disable, etc.). |
| 71 | // The ManagementPolicy is created at startup. |
| 72 | virtual ManagementPolicy* management_policy() = 0; |
| 73 | |
| 74 | // The UserScriptMaster is created at startup. |
| 75 | virtual UserScriptMaster* user_script_master() = 0; |
| 76 | |
| 77 | // The ProcessManager is created at startup. |
| 78 | virtual ProcessManager* process_manager() = 0; |
| 79 | |
| 80 | // The StateStore is created at startup. |
| 81 | virtual StateStore* state_store() = 0; |
| 82 | |
| 83 | // The rules store is created at startup. |
| 84 | virtual StateStore* rules_store() = 0; |
| 85 | |
| 86 | // Returns the IO-thread-accessible extension data. |
| 87 | virtual InfoMap* info_map() = 0; |
| 88 | |
| 89 | // The LazyBackgroundTaskQueue is created at startup. |
| 90 | virtual LazyBackgroundTaskQueue* lazy_background_task_queue() = 0; |
| 91 | |
| 92 | // The EventRouter is created at startup. |
| 93 | virtual EventRouter* event_router() = 0; |
| 94 | |
| 95 | // The ExtensionWarningService is created at startup. |
| 96 | virtual ExtensionWarningService* warning_service() = 0; |
| 97 | |
| 98 | // The blacklist is created at startup. |
| 99 | virtual Blacklist* blacklist() = 0; |
| 100 | |
| 101 | // The ErrorConsole is created at startup. |
| 102 | virtual ErrorConsole* error_console() = 0; |
| 103 | |
| 104 | // The InstallVerifier is created at startup. |
| 105 | virtual InstallVerifier* install_verifier() = 0; |
| 106 | |
[email protected] | aab2310 | 2014-02-05 18:57:55 | [diff] [blame] | 107 | // Returns the QuotaService that limits calls to certain extension functions. |
| 108 | // Lives on the UI thread. Created at startup. |
| 109 | virtual QuotaService* quota_service() = 0; |
| 110 | |
[email protected] | 59b0e60 | 2014-01-30 00:41:24 | [diff] [blame] | 111 | // Called by the ExtensionService that lives in this system. Gives the |
| 112 | // info map a chance to react to the load event before the EXTENSION_LOADED |
| 113 | // notification has fired. The purpose for handling this event first is to |
| 114 | // avoid race conditions by making sure URLRequestContexts learn about new |
| 115 | // extensions before anything else needs them to know. |
| 116 | virtual void RegisterExtensionWithRequestContexts( |
| 117 | const Extension* extension) {} |
| 118 | |
| 119 | // Called by the ExtensionService that lives in this system. Lets the |
| 120 | // info map clean up its RequestContexts once all the listeners to the |
| 121 | // EXTENSION_UNLOADED notification have finished running. |
| 122 | virtual void UnregisterExtensionWithRequestContexts( |
| 123 | const std::string& extension_id, |
| 124 | const UnloadedExtensionInfo::Reason reason) {} |
| 125 | |
| 126 | // Signaled when the extension system has completed its startup tasks. |
| 127 | virtual const OneShotEvent& ready() const = 0; |
[email protected] | fd3df778 | 2014-05-08 23:54:27 | [diff] [blame] | 128 | |
| 129 | // Returns the content verifier, if any. |
| 130 | virtual ContentVerifier* content_verifier() = 0; |
[email protected] | 59b0e60 | 2014-01-30 00:41:24 | [diff] [blame] | 131 | }; |
| 132 | |
| 133 | } // namespace extensions |
| 134 | |
| 135 | #endif // EXTENSIONS_BROWSER_EXTENSION_SYSTEM_H_ |