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/one_shot_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 // Whether the extension system has completed its startup tasks. | |
not at google - send to devlin
2013/05/16 15:51:08
The comment (and in a way, method name) implies th
Jeffrey Yasskin
2013/05/16 19:05:36
Good point; re-commented.
| |
146 virtual const OneShotEvent& ready() const = 0; | |
147 | |
148 protected: | |
149 friend class ::ExtensionService; | |
150 // Called by the ExtensionService when it finishes loading extensions on | |
151 // startup. | |
152 virtual void ExtensionServiceReady() = 0; | |
not at google - send to devlin
2013/05/16 15:51:08
I can see why ExtensionService owns this event, bu
Jeffrey Yasskin
2013/05/16 19:05:36
I agree that it's icky, and I tried your suggestio
not at google - send to devlin
2013/05/16 21:38:17
A constructor parameter to ExtensionService won't
Jeffrey Yasskin
2013/05/16 22:19:21
That seems to work and be cleaner that this callba
| |
143 }; | 153 }; |
144 | 154 |
145 // The ExtensionSystem for ProfileImpl and OffTheRecordProfileImpl. | 155 // The ExtensionSystem for ProfileImpl and OffTheRecordProfileImpl. |
146 // Implementation details: non-shared services are owned by | 156 // Implementation details: non-shared services are owned by |
147 // ExtensionSystemImpl, a ProfileKeyedService with separate incognito | 157 // ExtensionSystemImpl, a ProfileKeyedService with separate incognito |
148 // instances. A private Shared class (also a ProfileKeyedService, | 158 // instances. A private Shared class (also a ProfileKeyedService, |
149 // but with a shared instance for incognito) keeps the common services. | 159 // but with a shared instance for incognito) keeps the common services. |
150 class ExtensionSystemImpl : public ExtensionSystem { | 160 class ExtensionSystemImpl : public ExtensionSystem { |
151 public: | 161 public: |
152 explicit ExtensionSystemImpl(Profile* profile); | 162 explicit ExtensionSystemImpl(Profile* profile); |
(...skipping 29 matching lines...) Expand all Loading... | |
182 virtual ExtensionWarningService* warning_service() OVERRIDE; | 192 virtual ExtensionWarningService* warning_service() OVERRIDE; |
183 virtual Blacklist* blacklist() OVERRIDE; // shared | 193 virtual Blacklist* blacklist() OVERRIDE; // shared |
184 | 194 |
185 virtual void RegisterExtensionWithRequestContexts( | 195 virtual void RegisterExtensionWithRequestContexts( |
186 const Extension* extension) OVERRIDE; | 196 const Extension* extension) OVERRIDE; |
187 | 197 |
188 virtual void UnregisterExtensionWithRequestContexts( | 198 virtual void UnregisterExtensionWithRequestContexts( |
189 const std::string& extension_id, | 199 const std::string& extension_id, |
190 const extension_misc::UnloadedExtensionReason reason) OVERRIDE; | 200 const extension_misc::UnloadedExtensionReason reason) OVERRIDE; |
191 | 201 |
202 virtual const OneShotEvent& ready() const OVERRIDE; | |
203 | |
192 private: | 204 private: |
193 friend class ExtensionSystemSharedFactory; | 205 friend class ExtensionSystemSharedFactory; |
194 | 206 |
195 // Owns the Extension-related systems that have a single instance | 207 // Owns the Extension-related systems that have a single instance |
196 // shared between normal and incognito profiles. | 208 // shared between normal and incognito profiles. |
197 class Shared : public ProfileKeyedService { | 209 class Shared : public ProfileKeyedService { |
198 public: | 210 public: |
199 explicit Shared(Profile* profile); | 211 explicit Shared(Profile* profile); |
200 virtual ~Shared(); | 212 virtual ~Shared(); |
201 | 213 |
(...skipping 11 matching lines...) Expand all Loading... | |
213 ExtensionPrefs* extension_prefs(); | 225 ExtensionPrefs* extension_prefs(); |
214 ShellWindowGeometryCache* shell_window_geometry_cache(); | 226 ShellWindowGeometryCache* shell_window_geometry_cache(); |
215 ExtensionService* extension_service(); | 227 ExtensionService* extension_service(); |
216 ManagementPolicy* management_policy(); | 228 ManagementPolicy* management_policy(); |
217 UserScriptMaster* user_script_master(); | 229 UserScriptMaster* user_script_master(); |
218 Blacklist* blacklist(); | 230 Blacklist* blacklist(); |
219 ExtensionInfoMap* info_map(); | 231 ExtensionInfoMap* info_map(); |
220 LazyBackgroundTaskQueue* lazy_background_task_queue(); | 232 LazyBackgroundTaskQueue* lazy_background_task_queue(); |
221 EventRouter* event_router(); | 233 EventRouter* event_router(); |
222 ExtensionWarningService* warning_service(); | 234 ExtensionWarningService* warning_service(); |
235 OneShotEvent* ready() { return &ready_; } | |
223 | 236 |
224 private: | 237 private: |
225 Profile* profile_; | 238 Profile* profile_; |
226 | 239 |
227 // The services that are shared between normal and incognito profiles. | 240 // The services that are shared between normal and incognito profiles. |
228 | 241 |
229 scoped_ptr<StateStore> state_store_; | 242 scoped_ptr<StateStore> state_store_; |
230 scoped_ptr<StateStore> rules_store_; | 243 scoped_ptr<StateStore> rules_store_; |
231 scoped_ptr<ExtensionPrefs> extension_prefs_; | 244 scoped_ptr<ExtensionPrefs> extension_prefs_; |
232 // ShellWindowGeometryCache depends on ExtensionPrefs. | 245 // ShellWindowGeometryCache depends on ExtensionPrefs. |
233 scoped_ptr<ShellWindowGeometryCache> shell_window_geometry_cache_; | 246 scoped_ptr<ShellWindowGeometryCache> shell_window_geometry_cache_; |
234 // LazyBackgroundTaskQueue is a dependency of | 247 // LazyBackgroundTaskQueue is a dependency of |
235 // MessageService and EventRouter. | 248 // MessageService and EventRouter. |
236 scoped_ptr<LazyBackgroundTaskQueue> lazy_background_task_queue_; | 249 scoped_ptr<LazyBackgroundTaskQueue> lazy_background_task_queue_; |
237 scoped_ptr<EventRouter> event_router_; | 250 scoped_ptr<EventRouter> event_router_; |
238 scoped_ptr<NavigationObserver> navigation_observer_; | 251 scoped_ptr<NavigationObserver> navigation_observer_; |
239 scoped_refptr<UserScriptMaster> user_script_master_; | 252 scoped_refptr<UserScriptMaster> user_script_master_; |
240 // Blacklist depends on ExtensionPrefs. | 253 // Blacklist depends on ExtensionPrefs. |
241 scoped_ptr<Blacklist> blacklist_; | 254 scoped_ptr<Blacklist> blacklist_; |
242 // StandardManagementPolicyProvider depends on ExtensionPrefs and Blacklist. | 255 // StandardManagementPolicyProvider depends on ExtensionPrefs and Blacklist. |
243 scoped_ptr<StandardManagementPolicyProvider> | 256 scoped_ptr<StandardManagementPolicyProvider> |
244 standard_management_policy_provider_; | 257 standard_management_policy_provider_; |
245 // ExtensionService depends on ExtensionPrefs, StateStore, and Blacklist. | 258 // ExtensionService depends on ExtensionPrefs, StateStore, and Blacklist. |
246 scoped_ptr<ExtensionService> extension_service_; | 259 scoped_ptr<ExtensionService> extension_service_; |
247 scoped_ptr<ManagementPolicy> management_policy_; | 260 scoped_ptr<ManagementPolicy> management_policy_; |
248 // extension_info_map_ needs to outlive extension_process_manager_. | 261 // extension_info_map_ needs to outlive extension_process_manager_. |
249 scoped_refptr<ExtensionInfoMap> extension_info_map_; | 262 scoped_refptr<ExtensionInfoMap> extension_info_map_; |
250 scoped_ptr<ExtensionWarningService> extension_warning_service_; | 263 scoped_ptr<ExtensionWarningService> extension_warning_service_; |
251 scoped_ptr<ExtensionWarningBadgeService> extension_warning_badge_service_; | 264 scoped_ptr<ExtensionWarningBadgeService> extension_warning_badge_service_; |
265 | |
266 OneShotEvent ready_; | |
252 }; | 267 }; |
253 | 268 |
269 virtual void ExtensionServiceReady() OVERRIDE; | |
270 | |
254 Profile* profile_; | 271 Profile* profile_; |
255 | 272 |
256 Shared* shared_; | 273 Shared* shared_; |
257 | 274 |
258 // |extension_process_manager_| must be destroyed before the Profile's | 275 // |extension_process_manager_| must be destroyed before the Profile's |
259 // |io_data_|. While |extension_process_manager_| still lives, we handle | 276 // |io_data_|. While |extension_process_manager_| still lives, we handle |
260 // incoming resource requests from extension processes and those require | 277 // incoming resource requests from extension processes and those require |
261 // access to the ResourceContext owned by |io_data_|. | 278 // access to the ResourceContext owned by |io_data_|. |
262 scoped_ptr<ExtensionProcessManager> extension_process_manager_; | 279 scoped_ptr<ExtensionProcessManager> extension_process_manager_; |
263 scoped_ptr<LocationManager> location_manager_; | 280 scoped_ptr<LocationManager> location_manager_; |
264 scoped_ptr<ApiResourceManager<SerialConnection> > serial_connection_manager_; | 281 scoped_ptr<ApiResourceManager<SerialConnection> > serial_connection_manager_; |
265 scoped_ptr<ApiResourceManager<Socket> > socket_manager_; | 282 scoped_ptr<ApiResourceManager<Socket> > socket_manager_; |
266 scoped_ptr<ApiResourceManager< | 283 scoped_ptr<ApiResourceManager< |
267 UsbDeviceResource> > usb_device_resource_manager_; | 284 UsbDeviceResource> > usb_device_resource_manager_; |
268 scoped_ptr<RulesRegistryService> rules_registry_service_; | 285 scoped_ptr<RulesRegistryService> rules_registry_service_; |
269 | 286 |
270 DISALLOW_COPY_AND_ASSIGN(ExtensionSystemImpl); | 287 DISALLOW_COPY_AND_ASSIGN(ExtensionSystemImpl); |
271 }; | 288 }; |
272 | 289 |
273 } // namespace extensions | 290 } // namespace extensions |
274 | 291 |
275 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_H_ | 292 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_H_ |
OLD | NEW |