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