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/browser/profiles/profile_keyed_service.h" | 16 #include "chrome/browser/profiles/profile_keyed_service.h" |
17 #include "chrome/common/extensions/extension_constants.h" | 17 #include "chrome/common/extensions/extension_constants.h" |
| 18 #include "extensions/common/async_event.h" |
18 | 19 |
19 class ExtensionInfoMap; | 20 class ExtensionInfoMap; |
20 class ExtensionProcessManager; | 21 class ExtensionProcessManager; |
21 class ExtensionService; | 22 class ExtensionService; |
22 class Profile; | 23 class Profile; |
23 | 24 |
24 namespace extensions { | 25 namespace extensions { |
25 // Unfortunately, for the ApiResourceManager<> template classes, we don't seem | 26 // Unfortunately, for the ApiResourceManager<> template classes, we don't seem |
26 // 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. |
27 class AlarmManager; | 28 class AlarmManager; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 // extensions before anything else needs them to know. | 134 // extensions before anything else needs them to know. |
134 virtual void RegisterExtensionWithRequestContexts( | 135 virtual void RegisterExtensionWithRequestContexts( |
135 const Extension* extension) {} | 136 const Extension* extension) {} |
136 | 137 |
137 // Called by the ExtensionService that lives in this system. Lets the | 138 // Called by the ExtensionService that lives in this system. Lets the |
138 // info map clean up its RequestContexts once all the listeners to the | 139 // info map clean up its RequestContexts once all the listeners to the |
139 // EXTENSION_UNLOADED notification have finished running. | 140 // EXTENSION_UNLOADED notification have finished running. |
140 virtual void UnregisterExtensionWithRequestContexts( | 141 virtual void UnregisterExtensionWithRequestContexts( |
141 const std::string& extension_id, | 142 const std::string& extension_id, |
142 const extension_misc::UnloadedExtensionReason reason) {} | 143 const extension_misc::UnloadedExtensionReason reason) {} |
| 144 |
| 145 virtual const AsyncEvent& ready() const = 0; |
143 }; | 146 }; |
144 | 147 |
145 // The ExtensionSystem for ProfileImpl and OffTheRecordProfileImpl. | 148 // The ExtensionSystem for ProfileImpl and OffTheRecordProfileImpl. |
146 // Implementation details: non-shared services are owned by | 149 // Implementation details: non-shared services are owned by |
147 // ExtensionSystemImpl, a ProfileKeyedService with separate incognito | 150 // ExtensionSystemImpl, a ProfileKeyedService with separate incognito |
148 // instances. A private Shared class (also a ProfileKeyedService, | 151 // instances. A private Shared class (also a ProfileKeyedService, |
149 // but with a shared instance for incognito) keeps the common services. | 152 // but with a shared instance for incognito) keeps the common services. |
150 class ExtensionSystemImpl : public ExtensionSystem { | 153 class ExtensionSystemImpl : public ExtensionSystem { |
151 public: | 154 public: |
152 explicit ExtensionSystemImpl(Profile* profile); | 155 explicit ExtensionSystemImpl(Profile* profile); |
(...skipping 29 matching lines...) Expand all Loading... |
182 virtual ExtensionWarningService* warning_service() OVERRIDE; | 185 virtual ExtensionWarningService* warning_service() OVERRIDE; |
183 virtual Blacklist* blacklist() OVERRIDE; // shared | 186 virtual Blacklist* blacklist() OVERRIDE; // shared |
184 | 187 |
185 virtual void RegisterExtensionWithRequestContexts( | 188 virtual void RegisterExtensionWithRequestContexts( |
186 const Extension* extension) OVERRIDE; | 189 const Extension* extension) OVERRIDE; |
187 | 190 |
188 virtual void UnregisterExtensionWithRequestContexts( | 191 virtual void UnregisterExtensionWithRequestContexts( |
189 const std::string& extension_id, | 192 const std::string& extension_id, |
190 const extension_misc::UnloadedExtensionReason reason) OVERRIDE; | 193 const extension_misc::UnloadedExtensionReason reason) OVERRIDE; |
191 | 194 |
| 195 virtual const AsyncEvent& ready() const OVERRIDE; |
| 196 |
192 private: | 197 private: |
193 friend class ExtensionSystemSharedFactory; | 198 friend class ExtensionSystemSharedFactory; |
194 | 199 |
195 // Owns the Extension-related systems that have a single instance | 200 // Owns the Extension-related systems that have a single instance |
196 // shared between normal and incognito profiles. | 201 // shared between normal and incognito profiles. |
197 class Shared : public ProfileKeyedService { | 202 class Shared : public ProfileKeyedService { |
198 public: | 203 public: |
199 explicit Shared(Profile* profile); | 204 explicit Shared(Profile* profile); |
200 virtual ~Shared(); | 205 virtual ~Shared(); |
201 | 206 |
(...skipping 11 matching lines...) Expand all Loading... |
213 ExtensionPrefs* extension_prefs(); | 218 ExtensionPrefs* extension_prefs(); |
214 ShellWindowGeometryCache* shell_window_geometry_cache(); | 219 ShellWindowGeometryCache* shell_window_geometry_cache(); |
215 ExtensionService* extension_service(); | 220 ExtensionService* extension_service(); |
216 ManagementPolicy* management_policy(); | 221 ManagementPolicy* management_policy(); |
217 UserScriptMaster* user_script_master(); | 222 UserScriptMaster* user_script_master(); |
218 Blacklist* blacklist(); | 223 Blacklist* blacklist(); |
219 ExtensionInfoMap* info_map(); | 224 ExtensionInfoMap* info_map(); |
220 LazyBackgroundTaskQueue* lazy_background_task_queue(); | 225 LazyBackgroundTaskQueue* lazy_background_task_queue(); |
221 EventRouter* event_router(); | 226 EventRouter* event_router(); |
222 ExtensionWarningService* warning_service(); | 227 ExtensionWarningService* warning_service(); |
| 228 const AsyncEvent& ready() const { return ready_; } |
223 | 229 |
224 private: | 230 private: |
225 Profile* profile_; | 231 Profile* profile_; |
226 | 232 |
227 // The services that are shared between normal and incognito profiles. | 233 // The services that are shared between normal and incognito profiles. |
228 | 234 |
229 scoped_ptr<StateStore> state_store_; | 235 scoped_ptr<StateStore> state_store_; |
230 scoped_ptr<StateStore> rules_store_; | 236 scoped_ptr<StateStore> rules_store_; |
231 scoped_ptr<ExtensionPrefs> extension_prefs_; | 237 scoped_ptr<ExtensionPrefs> extension_prefs_; |
232 // ShellWindowGeometryCache depends on ExtensionPrefs. | 238 // ShellWindowGeometryCache depends on ExtensionPrefs. |
233 scoped_ptr<ShellWindowGeometryCache> shell_window_geometry_cache_; | 239 scoped_ptr<ShellWindowGeometryCache> shell_window_geometry_cache_; |
234 // LazyBackgroundTaskQueue is a dependency of | 240 // LazyBackgroundTaskQueue is a dependency of |
235 // MessageService and EventRouter. | 241 // MessageService and EventRouter. |
236 scoped_ptr<LazyBackgroundTaskQueue> lazy_background_task_queue_; | 242 scoped_ptr<LazyBackgroundTaskQueue> lazy_background_task_queue_; |
237 scoped_ptr<EventRouter> event_router_; | 243 scoped_ptr<EventRouter> event_router_; |
238 scoped_ptr<NavigationObserver> navigation_observer_; | 244 scoped_ptr<NavigationObserver> navigation_observer_; |
239 scoped_refptr<UserScriptMaster> user_script_master_; | 245 scoped_refptr<UserScriptMaster> user_script_master_; |
240 // Blacklist depends on ExtensionPrefs. | 246 // Blacklist depends on ExtensionPrefs. |
241 scoped_ptr<Blacklist> blacklist_; | 247 scoped_ptr<Blacklist> blacklist_; |
242 // StandardManagementPolicyProvider depends on ExtensionPrefs and Blacklist. | 248 // StandardManagementPolicyProvider depends on ExtensionPrefs and Blacklist. |
243 scoped_ptr<StandardManagementPolicyProvider> | 249 scoped_ptr<StandardManagementPolicyProvider> |
244 standard_management_policy_provider_; | 250 standard_management_policy_provider_; |
245 // ExtensionService depends on ExtensionPrefs, StateStore, and Blacklist. | 251 // ExtensionService depends on ExtensionPrefs, StateStore, and Blacklist. |
246 scoped_ptr<ExtensionService> extension_service_; | 252 scoped_ptr<ExtensionService> extension_service_; |
247 scoped_ptr<ManagementPolicy> management_policy_; | 253 scoped_ptr<ManagementPolicy> management_policy_; |
248 // extension_info_map_ needs to outlive extension_process_manager_. | 254 // extension_info_map_ needs to outlive extension_process_manager_. |
249 scoped_refptr<ExtensionInfoMap> extension_info_map_; | 255 scoped_refptr<ExtensionInfoMap> extension_info_map_; |
250 scoped_ptr<ExtensionWarningService> extension_warning_service_; | 256 scoped_ptr<ExtensionWarningService> extension_warning_service_; |
251 scoped_ptr<ExtensionWarningBadgeService> extension_warning_badge_service_; | 257 scoped_ptr<ExtensionWarningBadgeService> extension_warning_badge_service_; |
| 258 |
| 259 AsyncEvent ready_; |
252 }; | 260 }; |
253 | 261 |
254 Profile* profile_; | 262 Profile* profile_; |
255 | 263 |
256 Shared* shared_; | 264 Shared* shared_; |
257 | 265 |
258 // |extension_process_manager_| must be destroyed before the Profile's | 266 // |extension_process_manager_| must be destroyed before the Profile's |
259 // |io_data_|. While |extension_process_manager_| still lives, we handle | 267 // |io_data_|. While |extension_process_manager_| still lives, we handle |
260 // incoming resource requests from extension processes and those require | 268 // incoming resource requests from extension processes and those require |
261 // access to the ResourceContext owned by |io_data_|. | 269 // access to the ResourceContext owned by |io_data_|. |
262 scoped_ptr<ExtensionProcessManager> extension_process_manager_; | 270 scoped_ptr<ExtensionProcessManager> extension_process_manager_; |
263 scoped_ptr<LocationManager> location_manager_; | 271 scoped_ptr<LocationManager> location_manager_; |
264 scoped_ptr<ApiResourceManager<SerialConnection> > serial_connection_manager_; | 272 scoped_ptr<ApiResourceManager<SerialConnection> > serial_connection_manager_; |
265 scoped_ptr<ApiResourceManager<Socket> > socket_manager_; | 273 scoped_ptr<ApiResourceManager<Socket> > socket_manager_; |
266 scoped_ptr<ApiResourceManager< | 274 scoped_ptr<ApiResourceManager< |
267 UsbDeviceResource> > usb_device_resource_manager_; | 275 UsbDeviceResource> > usb_device_resource_manager_; |
268 scoped_ptr<RulesRegistryService> rules_registry_service_; | 276 scoped_ptr<RulesRegistryService> rules_registry_service_; |
269 | 277 |
270 DISALLOW_COPY_AND_ASSIGN(ExtensionSystemImpl); | 278 DISALLOW_COPY_AND_ASSIGN(ExtensionSystemImpl); |
271 }; | 279 }; |
272 | 280 |
273 } // namespace extensions | 281 } // namespace extensions |
274 | 282 |
275 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_H_ | 283 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_H_ |
OLD | NEW |