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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 // extensions before anything else needs them to know. | 126 // extensions before anything else needs them to know. |
126 virtual void RegisterExtensionWithRequestContexts( | 127 virtual void RegisterExtensionWithRequestContexts( |
127 const Extension* extension) {} | 128 const Extension* extension) {} |
128 | 129 |
129 // Called by the ExtensionService that lives in this system. Lets the | 130 // Called by the ExtensionService that lives in this system. Lets the |
130 // info map clean up its RequestContexts once all the listeners to the | 131 // info map clean up its RequestContexts once all the listeners to the |
131 // EXTENSION_UNLOADED notification have finished running. | 132 // EXTENSION_UNLOADED notification have finished running. |
132 virtual void UnregisterExtensionWithRequestContexts( | 133 virtual void UnregisterExtensionWithRequestContexts( |
133 const std::string& extension_id, | 134 const std::string& extension_id, |
134 const extension_misc::UnloadedExtensionReason reason) {} | 135 const extension_misc::UnloadedExtensionReason reason) {} |
| 136 |
| 137 // Signaled when the extension system has completed its startup tasks. |
| 138 virtual const OneShotEvent& ready() const = 0; |
135 }; | 139 }; |
136 | 140 |
137 // The ExtensionSystem for ProfileImpl and OffTheRecordProfileImpl. | 141 // The ExtensionSystem for ProfileImpl and OffTheRecordProfileImpl. |
138 // Implementation details: non-shared services are owned by | 142 // Implementation details: non-shared services are owned by |
139 // ExtensionSystemImpl, a ProfileKeyedService with separate incognito | 143 // ExtensionSystemImpl, a ProfileKeyedService with separate incognito |
140 // instances. A private Shared class (also a ProfileKeyedService, | 144 // instances. A private Shared class (also a ProfileKeyedService, |
141 // but with a shared instance for incognito) keeps the common services. | 145 // but with a shared instance for incognito) keeps the common services. |
142 class ExtensionSystemImpl : public ExtensionSystem { | 146 class ExtensionSystemImpl : public ExtensionSystem { |
143 public: | 147 public: |
144 explicit ExtensionSystemImpl(Profile* profile); | 148 explicit ExtensionSystemImpl(Profile* profile); |
(...skipping 27 matching lines...) Expand all Loading... |
172 virtual ExtensionWarningService* warning_service() OVERRIDE; | 176 virtual ExtensionWarningService* warning_service() OVERRIDE; |
173 virtual Blacklist* blacklist() OVERRIDE; // shared | 177 virtual Blacklist* blacklist() OVERRIDE; // shared |
174 | 178 |
175 virtual void RegisterExtensionWithRequestContexts( | 179 virtual void RegisterExtensionWithRequestContexts( |
176 const Extension* extension) OVERRIDE; | 180 const Extension* extension) OVERRIDE; |
177 | 181 |
178 virtual void UnregisterExtensionWithRequestContexts( | 182 virtual void UnregisterExtensionWithRequestContexts( |
179 const std::string& extension_id, | 183 const std::string& extension_id, |
180 const extension_misc::UnloadedExtensionReason reason) OVERRIDE; | 184 const extension_misc::UnloadedExtensionReason reason) OVERRIDE; |
181 | 185 |
| 186 virtual const OneShotEvent& ready() const OVERRIDE; |
| 187 |
182 private: | 188 private: |
183 friend class ExtensionSystemSharedFactory; | 189 friend class ExtensionSystemSharedFactory; |
184 | 190 |
185 // Owns the Extension-related systems that have a single instance | 191 // Owns the Extension-related systems that have a single instance |
186 // shared between normal and incognito profiles. | 192 // shared between normal and incognito profiles. |
187 class Shared : public ProfileKeyedService { | 193 class Shared : public ProfileKeyedService { |
188 public: | 194 public: |
189 explicit Shared(Profile* profile); | 195 explicit Shared(Profile* profile); |
190 virtual ~Shared(); | 196 virtual ~Shared(); |
191 | 197 |
(...skipping 10 matching lines...) Expand all Loading... |
202 StateStore* rules_store(); | 208 StateStore* rules_store(); |
203 ShellWindowGeometryCache* shell_window_geometry_cache(); | 209 ShellWindowGeometryCache* shell_window_geometry_cache(); |
204 ExtensionService* extension_service(); | 210 ExtensionService* extension_service(); |
205 ManagementPolicy* management_policy(); | 211 ManagementPolicy* management_policy(); |
206 UserScriptMaster* user_script_master(); | 212 UserScriptMaster* user_script_master(); |
207 Blacklist* blacklist(); | 213 Blacklist* blacklist(); |
208 ExtensionInfoMap* info_map(); | 214 ExtensionInfoMap* info_map(); |
209 LazyBackgroundTaskQueue* lazy_background_task_queue(); | 215 LazyBackgroundTaskQueue* lazy_background_task_queue(); |
210 EventRouter* event_router(); | 216 EventRouter* event_router(); |
211 ExtensionWarningService* warning_service(); | 217 ExtensionWarningService* warning_service(); |
| 218 const OneShotEvent& ready() const { return ready_; } |
212 | 219 |
213 private: | 220 private: |
214 Profile* profile_; | 221 Profile* profile_; |
215 | 222 |
216 // The services that are shared between normal and incognito profiles. | 223 // The services that are shared between normal and incognito profiles. |
217 | 224 |
218 scoped_ptr<StateStore> state_store_; | 225 scoped_ptr<StateStore> state_store_; |
219 scoped_ptr<StateStore> rules_store_; | 226 scoped_ptr<StateStore> rules_store_; |
220 scoped_ptr<ShellWindowGeometryCache> shell_window_geometry_cache_; | 227 scoped_ptr<ShellWindowGeometryCache> shell_window_geometry_cache_; |
221 // LazyBackgroundTaskQueue is a dependency of | 228 // LazyBackgroundTaskQueue is a dependency of |
222 // MessageService and EventRouter. | 229 // MessageService and EventRouter. |
223 scoped_ptr<LazyBackgroundTaskQueue> lazy_background_task_queue_; | 230 scoped_ptr<LazyBackgroundTaskQueue> lazy_background_task_queue_; |
224 scoped_ptr<EventRouter> event_router_; | 231 scoped_ptr<EventRouter> event_router_; |
225 scoped_ptr<NavigationObserver> navigation_observer_; | 232 scoped_ptr<NavigationObserver> navigation_observer_; |
226 scoped_refptr<UserScriptMaster> user_script_master_; | 233 scoped_refptr<UserScriptMaster> user_script_master_; |
227 scoped_ptr<Blacklist> blacklist_; | 234 scoped_ptr<Blacklist> blacklist_; |
228 // StandardManagementPolicyProvider depends on Blacklist. | 235 // StandardManagementPolicyProvider depends on Blacklist. |
229 scoped_ptr<StandardManagementPolicyProvider> | 236 scoped_ptr<StandardManagementPolicyProvider> |
230 standard_management_policy_provider_; | 237 standard_management_policy_provider_; |
231 // ExtensionService depends on StateStore and Blacklist. | 238 // ExtensionService depends on StateStore and Blacklist. |
232 scoped_ptr<ExtensionService> extension_service_; | 239 scoped_ptr<ExtensionService> extension_service_; |
233 scoped_ptr<ManagementPolicy> management_policy_; | 240 scoped_ptr<ManagementPolicy> management_policy_; |
234 // extension_info_map_ needs to outlive extension_process_manager_. | 241 // extension_info_map_ needs to outlive extension_process_manager_. |
235 scoped_refptr<ExtensionInfoMap> extension_info_map_; | 242 scoped_refptr<ExtensionInfoMap> extension_info_map_; |
236 scoped_ptr<ExtensionWarningService> extension_warning_service_; | 243 scoped_ptr<ExtensionWarningService> extension_warning_service_; |
237 scoped_ptr<ExtensionWarningBadgeService> extension_warning_badge_service_; | 244 scoped_ptr<ExtensionWarningBadgeService> extension_warning_badge_service_; |
| 245 |
| 246 OneShotEvent ready_; |
238 }; | 247 }; |
239 | 248 |
240 Profile* profile_; | 249 Profile* profile_; |
241 | 250 |
242 Shared* shared_; | 251 Shared* shared_; |
243 | 252 |
244 // |extension_process_manager_| must be destroyed before the Profile's | 253 // |extension_process_manager_| must be destroyed before the Profile's |
245 // |io_data_|. While |extension_process_manager_| still lives, we handle | 254 // |io_data_|. While |extension_process_manager_| still lives, we handle |
246 // incoming resource requests from extension processes and those require | 255 // incoming resource requests from extension processes and those require |
247 // access to the ResourceContext owned by |io_data_|. | 256 // access to the ResourceContext owned by |io_data_|. |
248 scoped_ptr<ExtensionProcessManager> extension_process_manager_; | 257 scoped_ptr<ExtensionProcessManager> extension_process_manager_; |
249 scoped_ptr<ApiResourceManager<SerialConnection> > serial_connection_manager_; | 258 scoped_ptr<ApiResourceManager<SerialConnection> > serial_connection_manager_; |
250 scoped_ptr<ApiResourceManager<Socket> > socket_manager_; | 259 scoped_ptr<ApiResourceManager<Socket> > socket_manager_; |
251 scoped_ptr<ApiResourceManager< | 260 scoped_ptr<ApiResourceManager< |
252 UsbDeviceResource> > usb_device_resource_manager_; | 261 UsbDeviceResource> > usb_device_resource_manager_; |
253 scoped_ptr<RulesRegistryService> rules_registry_service_; | 262 scoped_ptr<RulesRegistryService> rules_registry_service_; |
254 | 263 |
255 DISALLOW_COPY_AND_ASSIGN(ExtensionSystemImpl); | 264 DISALLOW_COPY_AND_ASSIGN(ExtensionSystemImpl); |
256 }; | 265 }; |
257 | 266 |
258 } // namespace extensions | 267 } // namespace extensions |
259 | 268 |
260 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_H_ | 269 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_H_ |
OLD | NEW |