OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "chrome/browser/extensions/api/api_resource_manager.h" | 12 #include "chrome/browser/extensions/api/api_resource_manager.h" |
13 #include "chrome/browser/extensions/api/serial/serial_connection.h" | 13 #include "chrome/browser/extensions/api/serial/serial_connection.h" |
14 #include "chrome/browser/extensions/api/socket/socket.h" | 14 #include "chrome/browser/extensions/api/socket/socket.h" |
15 #include "chrome/browser/extensions/api/usb/usb_device_resource.h" | 15 #include "chrome/browser/extensions/api/usb/usb_device_resource.h" |
16 #include "chrome/common/extensions/extension_constants.h" | 16 #include "chrome/common/extensions/extension_constants.h" |
17 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | 17 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
18 #include "extensions/common/one_shot_event.h" | 18 #include "extensions/common/one_shot_event.h" |
19 | 19 |
20 class ExtensionInfoMap; | 20 class ExtensionInfoMap; |
21 class ExtensionProcessManager; | 21 class ExtensionProcessManager; |
22 class ExtensionService; | 22 class ExtensionService; |
23 class Profile; | 23 class Profile; |
24 | 24 |
25 namespace extensions { | 25 namespace extensions { |
26 // Unfortunately, for the ApiResourceManager<> template classes, we don't seem | 26 // Unfortunately, for the ApiResourceManager<> template classes, we don't seem |
27 // to be able to forward-declare because of compilation errors on Windows. | 27 // to be able to forward-declare because of compilation errors on Windows. |
28 class AlarmManager; | |
29 class Blacklist; | 28 class Blacklist; |
30 class EventRouter; | 29 class EventRouter; |
31 class Extension; | 30 class Extension; |
32 class ExtensionSystemSharedFactory; | 31 class ExtensionSystemSharedFactory; |
33 class ExtensionWarningBadgeService; | 32 class ExtensionWarningBadgeService; |
34 class ExtensionWarningService; | 33 class ExtensionWarningService; |
35 class LazyBackgroundTaskQueue; | 34 class LazyBackgroundTaskQueue; |
36 class ManagementPolicy; | 35 class ManagementPolicy; |
37 class MessageService; | |
38 class NavigationObserver; | 36 class NavigationObserver; |
39 class RulesRegistryService; | |
40 class StandardManagementPolicyProvider; | 37 class StandardManagementPolicyProvider; |
41 class StateStore; | 38 class StateStore; |
42 class UserScriptMaster; | 39 class UserScriptMaster; |
43 | 40 |
44 // The ExtensionSystem manages the creation and destruction of services | 41 // The ExtensionSystem manages the creation and destruction of services |
45 // related to extensions. Most objects are shared between normal | 42 // related to extensions. Most objects are shared between normal |
46 // and incognito Profiles, except as called out in comments. | 43 // and incognito Profiles, except as called out in comments. |
47 // This interface supports using TestExtensionSystem for TestingProfiles | 44 // This interface supports using TestExtensionSystem for TestingProfiles |
48 // that don't want all of the extensions baggage in their tests. | 45 // that don't want all of the extensions baggage in their tests. |
49 class ExtensionSystem : public BrowserContextKeyedService { | 46 class ExtensionSystem : public BrowserContextKeyedService { |
50 public: | 47 public: |
51 ExtensionSystem(); | 48 ExtensionSystem(); |
52 virtual ~ExtensionSystem(); | 49 virtual ~ExtensionSystem(); |
53 | 50 |
54 // Returns the instance for the given profile, or NULL if none. This is | 51 // Returns the instance for the given profile, or NULL if none. This is |
55 // a convenience wrapper around ExtensionSystemFactory::GetForProfile. | 52 // a convenience wrapper around ExtensionSystemFactory::GetForProfile. |
56 static ExtensionSystem* Get(Profile* profile); | 53 static ExtensionSystem* Get(Profile* profile); |
57 | 54 |
58 // BrowserContextKeyedService implementation. | 55 // BrowserContextKeyedService implementation. |
59 virtual void Shutdown() OVERRIDE {} | 56 virtual void Shutdown() OVERRIDE {} |
60 | 57 |
61 // Initializes extensions machinery. | 58 // Initializes extensions machinery. |
62 // Component extensions are always enabled, external and user extensions | 59 // Component extensions are always enabled, external and user extensions |
63 // are controlled by |extensions_enabled|. | 60 // are controlled by |extensions_enabled|. |
64 virtual void InitForRegularProfile(bool extensions_enabled) = 0; | 61 virtual void InitForRegularProfile(bool extensions_enabled) = 0; |
65 | 62 |
66 virtual void InitForOTRProfile() = 0; | |
67 | |
68 // The ExtensionService is created at startup. | 63 // The ExtensionService is created at startup. |
69 virtual ExtensionService* extension_service() = 0; | 64 virtual ExtensionService* extension_service() = 0; |
70 | 65 |
71 // The class controlling whether users are permitted to perform certain | 66 // The class controlling whether users are permitted to perform certain |
72 // actions on extensions (install, uninstall, disable, etc.). | 67 // actions on extensions (install, uninstall, disable, etc.). |
73 // The ManagementPolicy is created at startup. | 68 // The ManagementPolicy is created at startup. |
74 virtual ManagementPolicy* management_policy() = 0; | 69 virtual ManagementPolicy* management_policy() = 0; |
75 | 70 |
76 // The UserScriptMaster is created at startup. | 71 // The UserScriptMaster is created at startup. |
77 virtual UserScriptMaster* user_script_master() = 0; | 72 virtual UserScriptMaster* user_script_master() = 0; |
78 | 73 |
79 // The ExtensionProcessManager is created at startup. | 74 // The ExtensionProcessManager is created at startup. |
80 virtual ExtensionProcessManager* process_manager() = 0; | 75 virtual ExtensionProcessManager* process_manager() = 0; |
81 | 76 |
82 // The StateStore is created at startup. | 77 // The StateStore is created at startup. |
83 virtual StateStore* state_store() = 0; | 78 virtual StateStore* state_store() = 0; |
84 | 79 |
85 // The rules store is created at startup. | 80 // The rules store is created at startup. |
86 virtual StateStore* rules_store() = 0; | 81 virtual StateStore* rules_store() = 0; |
87 | 82 |
88 // Returns the IO-thread-accessible extension data. | 83 // Returns the IO-thread-accessible extension data. |
89 virtual ExtensionInfoMap* info_map() = 0; | 84 virtual ExtensionInfoMap* info_map() = 0; |
90 | 85 |
91 // The LazyBackgroundTaskQueue is created at startup. | 86 // The LazyBackgroundTaskQueue is created at startup. |
92 virtual LazyBackgroundTaskQueue* lazy_background_task_queue() = 0; | 87 virtual LazyBackgroundTaskQueue* lazy_background_task_queue() = 0; |
93 | 88 |
94 // The EventRouter is created at startup. | 89 // The EventRouter is created at startup. |
95 virtual EventRouter* event_router() = 0; | 90 virtual EventRouter* event_router() = 0; |
96 | 91 |
97 // The RulesRegistryService is created at startup. | |
98 virtual RulesRegistryService* rules_registry_service() = 0; | |
99 | |
100 // The SerialConnection ResourceManager is created at startup. | 92 // The SerialConnection ResourceManager is created at startup. |
101 virtual ApiResourceManager<SerialConnection>* | 93 virtual ApiResourceManager<SerialConnection>* |
102 serial_connection_manager() = 0; | 94 serial_connection_manager() = 0; |
103 | 95 |
104 // The Socket ResourceManager is created at startup. | 96 // The Socket ResourceManager is created at startup. |
105 virtual ApiResourceManager<Socket>* | 97 virtual ApiResourceManager<Socket>* |
106 socket_manager() = 0; | 98 socket_manager() = 0; |
107 | 99 |
108 // The UsbDeviceResource ResourceManager is created at startup. | 100 // The UsbDeviceResource ResourceManager is created at startup. |
109 virtual ApiResourceManager<UsbDeviceResource>* | 101 virtual ApiResourceManager<UsbDeviceResource>* |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 // but with a shared instance for incognito) keeps the common services. | 133 // but with a shared instance for incognito) keeps the common services. |
142 class ExtensionSystemImpl : public ExtensionSystem { | 134 class ExtensionSystemImpl : public ExtensionSystem { |
143 public: | 135 public: |
144 explicit ExtensionSystemImpl(Profile* profile); | 136 explicit ExtensionSystemImpl(Profile* profile); |
145 virtual ~ExtensionSystemImpl(); | 137 virtual ~ExtensionSystemImpl(); |
146 | 138 |
147 // BrowserContextKeyedService implementation. | 139 // BrowserContextKeyedService implementation. |
148 virtual void Shutdown() OVERRIDE; | 140 virtual void Shutdown() OVERRIDE; |
149 | 141 |
150 virtual void InitForRegularProfile(bool extensions_enabled) OVERRIDE; | 142 virtual void InitForRegularProfile(bool extensions_enabled) OVERRIDE; |
151 virtual void InitForOTRProfile() OVERRIDE; | |
152 | 143 |
153 virtual ExtensionService* extension_service() OVERRIDE; // shared | 144 virtual ExtensionService* extension_service() OVERRIDE; // shared |
154 virtual ManagementPolicy* management_policy() OVERRIDE; // shared | 145 virtual ManagementPolicy* management_policy() OVERRIDE; // shared |
155 virtual UserScriptMaster* user_script_master() OVERRIDE; // shared | 146 virtual UserScriptMaster* user_script_master() OVERRIDE; // shared |
156 virtual ExtensionProcessManager* process_manager() OVERRIDE; | 147 virtual ExtensionProcessManager* process_manager() OVERRIDE; |
157 virtual StateStore* state_store() OVERRIDE; // shared | 148 virtual StateStore* state_store() OVERRIDE; // shared |
158 virtual StateStore* rules_store() OVERRIDE; // shared | 149 virtual StateStore* rules_store() OVERRIDE; // shared |
159 virtual LazyBackgroundTaskQueue* lazy_background_task_queue() | 150 virtual LazyBackgroundTaskQueue* lazy_background_task_queue() |
160 OVERRIDE; // shared | 151 OVERRIDE; // shared |
161 virtual ExtensionInfoMap* info_map() OVERRIDE; // shared | 152 virtual ExtensionInfoMap* info_map() OVERRIDE; // shared |
162 virtual EventRouter* event_router() OVERRIDE; // shared | 153 virtual EventRouter* event_router() OVERRIDE; // shared |
163 virtual RulesRegistryService* rules_registry_service() | |
164 OVERRIDE; // shared | |
165 virtual ApiResourceManager<SerialConnection>* serial_connection_manager() | 154 virtual ApiResourceManager<SerialConnection>* serial_connection_manager() |
166 OVERRIDE; | 155 OVERRIDE; |
167 virtual ApiResourceManager<Socket>* socket_manager() OVERRIDE; | 156 virtual ApiResourceManager<Socket>* socket_manager() OVERRIDE; |
168 virtual ApiResourceManager<UsbDeviceResource>* usb_device_resource_manager() | 157 virtual ApiResourceManager<UsbDeviceResource>* usb_device_resource_manager() |
169 OVERRIDE; | 158 OVERRIDE; |
170 virtual ExtensionWarningService* warning_service() OVERRIDE; | 159 virtual ExtensionWarningService* warning_service() OVERRIDE; |
171 virtual Blacklist* blacklist() OVERRIDE; // shared | 160 virtual Blacklist* blacklist() OVERRIDE; // shared |
172 | 161 |
173 virtual void RegisterExtensionWithRequestContexts( | 162 virtual void RegisterExtensionWithRequestContexts( |
174 const Extension* extension) OVERRIDE; | 163 const Extension* extension) OVERRIDE; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 | 233 |
245 // |extension_process_manager_| must be destroyed before the Profile's | 234 // |extension_process_manager_| must be destroyed before the Profile's |
246 // |io_data_|. While |extension_process_manager_| still lives, we handle | 235 // |io_data_|. While |extension_process_manager_| still lives, we handle |
247 // incoming resource requests from extension processes and those require | 236 // incoming resource requests from extension processes and those require |
248 // access to the ResourceContext owned by |io_data_|. | 237 // access to the ResourceContext owned by |io_data_|. |
249 scoped_ptr<ExtensionProcessManager> extension_process_manager_; | 238 scoped_ptr<ExtensionProcessManager> extension_process_manager_; |
250 scoped_ptr<ApiResourceManager<SerialConnection> > serial_connection_manager_; | 239 scoped_ptr<ApiResourceManager<SerialConnection> > serial_connection_manager_; |
251 scoped_ptr<ApiResourceManager<Socket> > socket_manager_; | 240 scoped_ptr<ApiResourceManager<Socket> > socket_manager_; |
252 scoped_ptr<ApiResourceManager< | 241 scoped_ptr<ApiResourceManager< |
253 UsbDeviceResource> > usb_device_resource_manager_; | 242 UsbDeviceResource> > usb_device_resource_manager_; |
254 scoped_ptr<RulesRegistryService> rules_registry_service_; | |
255 | 243 |
256 DISALLOW_COPY_AND_ASSIGN(ExtensionSystemImpl); | 244 DISALLOW_COPY_AND_ASSIGN(ExtensionSystemImpl); |
257 }; | 245 }; |
258 | 246 |
259 } // namespace extensions | 247 } // namespace extensions |
260 | 248 |
261 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_H_ | 249 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_H_ |
OLD | NEW |