NaCl: Update revision in DEPS, r13724 -> r13730
[chromium-blink-merge.git] / extensions / browser / extension_system.h
blob4f8dc84379280520841786d4f0889d39611f1386
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.
5 #ifndef EXTENSIONS_BROWSER_EXTENSION_SYSTEM_H_
6 #define EXTENSIONS_BROWSER_EXTENSION_SYSTEM_H_
8 #include <string>
10 #include "base/memory/ref_counted.h"
11 #include "components/keyed_service/core/keyed_service.h"
12 #include "extensions/common/extension.h"
14 class ExtensionService;
16 #if defined(OS_CHROMEOS)
17 namespace chromeos {
18 class DeviceLocalAccountManagementPolicyProvider;
20 #endif // defined(OS_CHROMEOS)
22 namespace content {
23 class BrowserContext;
26 namespace extensions {
28 class Blacklist;
29 class ContentVerifier;
30 class DeclarativeUserScriptMaster;
31 class ErrorConsole;
32 class EventRouter;
33 class Extension;
34 class ExtensionSet;
35 class InfoMap;
36 class InstallVerifier;
37 class LazyBackgroundTaskQueue;
38 class ManagementPolicy;
39 class OneShotEvent;
40 class ProcessManager;
41 class QuotaService;
42 class RuntimeData;
43 class SharedUserScriptMaster;
44 class StateStore;
45 class WarningService;
47 // ExtensionSystem manages the lifetime of many of the services used by the
48 // extensions and apps system, and it handles startup and shutdown as needed.
49 // Eventually, we'd like to make more of these services into KeyedServices in
50 // their own right.
51 class ExtensionSystem : public KeyedService {
52 public:
53 ExtensionSystem();
54 virtual ~ExtensionSystem();
56 // Returns the instance for the given browser context, or NULL if none.
57 static ExtensionSystem* Get(content::BrowserContext* context);
59 // Initializes extensions machinery.
60 // Component extensions are always enabled, external and user extensions are
61 // controlled by |extensions_enabled|.
62 virtual void InitForRegularProfile(bool extensions_enabled) = 0;
64 // The ExtensionService is created at startup.
65 virtual ExtensionService* extension_service() = 0;
67 // Per-extension data that can change during the life of the process but
68 // does not persist across restarts. Lives on UI thread. Created at startup.
69 virtual RuntimeData* runtime_data() = 0;
71 // The class controlling whether users are permitted to perform certain
72 // actions on extensions (install, uninstall, disable, etc.).
73 // The ManagementPolicy is created at startup.
74 virtual ManagementPolicy* management_policy() = 0;
76 // The SharedUserScriptMaster is created at startup.
77 virtual SharedUserScriptMaster* shared_user_script_master() = 0;
79 // The ProcessManager is created at startup.
80 virtual ProcessManager* process_manager() = 0;
82 // The StateStore is created at startup.
83 virtual StateStore* state_store() = 0;
85 // The rules store is created at startup.
86 virtual StateStore* rules_store() = 0;
88 // Returns the IO-thread-accessible extension data.
89 virtual InfoMap* info_map() = 0;
91 // The LazyBackgroundTaskQueue is created at startup.
92 virtual LazyBackgroundTaskQueue* lazy_background_task_queue() = 0;
94 // The EventRouter is created at startup.
95 virtual EventRouter* event_router() = 0;
97 // The WarningService is created at startup.
98 virtual WarningService* warning_service() = 0;
100 // The blacklist is created at startup.
101 virtual Blacklist* blacklist() = 0;
103 // The ErrorConsole is created at startup.
104 virtual ErrorConsole* error_console() = 0;
106 // The InstallVerifier is created at startup.
107 virtual InstallVerifier* install_verifier() = 0;
109 // Returns the QuotaService that limits calls to certain extension functions.
110 // Lives on the UI thread. Created at startup.
111 virtual QuotaService* quota_service() = 0;
113 // Called by the ExtensionService that lives in this system. Gives the
114 // info map a chance to react to the load event before the EXTENSION_LOADED
115 // notification has fired. The purpose for handling this event first is to
116 // avoid race conditions by making sure URLRequestContexts learn about new
117 // extensions before anything else needs them to know.
118 virtual void RegisterExtensionWithRequestContexts(
119 const Extension* extension) {}
121 // Called by the ExtensionService that lives in this system. Lets the
122 // info map clean up its RequestContexts once all the listeners to the
123 // EXTENSION_UNLOADED notification have finished running.
124 virtual void UnregisterExtensionWithRequestContexts(
125 const std::string& extension_id,
126 const UnloadedExtensionInfo::Reason reason) {}
128 // Signaled when the extension system has completed its startup tasks.
129 virtual const OneShotEvent& ready() const = 0;
131 // Returns the content verifier, if any.
132 virtual ContentVerifier* content_verifier() = 0;
134 // Get a set of extensions that depend on the given extension.
135 // TODO(elijahtaylor): Move SharedModuleService out of chrome/browser
136 // so it can be retrieved from ExtensionSystem directly.
137 virtual scoped_ptr<ExtensionSet> GetDependentExtensions(
138 const Extension* extension) = 0;
140 // Get the user script master for declarative scripts, if any.
141 virtual DeclarativeUserScriptMaster*
142 GetDeclarativeUserScriptMasterByExtension(
143 const ExtensionId& extension_id) = 0;
146 } // namespace extensions
148 #endif // EXTENSIONS_BROWSER_EXTENSION_SYSTEM_H_