OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ | 5 #ifndef EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ |
6 #define EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ | 6 #define EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
| 17 #include "base/scoped_observer.h" |
17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
18 #include "content/public/browser/notification_observer.h" | 19 #include "content/public/browser/notification_observer.h" |
19 #include "content/public/browser/notification_registrar.h" | 20 #include "content/public/browser/notification_registrar.h" |
| 21 #include "extensions/browser/extension_registry_observer.h" |
20 #include "extensions/common/view_type.h" | 22 #include "extensions/common/view_type.h" |
21 | 23 |
22 class GURL; | 24 class GURL; |
23 | 25 |
24 namespace content { | 26 namespace content { |
25 class BrowserContext; | 27 class BrowserContext; |
26 class DevToolsAgentHost; | 28 class DevToolsAgentHost; |
27 class RenderViewHost; | 29 class RenderViewHost; |
28 class RenderFrameHost; | 30 class RenderFrameHost; |
29 class SiteInstance; | 31 class SiteInstance; |
30 }; | 32 }; |
31 | 33 |
32 namespace extensions { | 34 namespace extensions { |
33 | 35 |
34 class Extension; | 36 class Extension; |
35 class ExtensionHost; | 37 class ExtensionHost; |
| 38 class ExtensionRegistry; |
36 class ProcessManagerObserver; | 39 class ProcessManagerObserver; |
37 | 40 |
38 // Manages dynamic state of running Chromium extensions. There is one instance | 41 // Manages dynamic state of running Chromium extensions. There is one instance |
39 // of this class per Profile. OTR Profiles have a separate instance that keeps | 42 // of this class per Profile. OTR Profiles have a separate instance that keeps |
40 // track of split-mode extensions only. | 43 // track of split-mode extensions only. |
41 class ProcessManager : public content::NotificationObserver { | 44 class ProcessManager : public content::NotificationObserver, |
| 45 public ExtensionRegistryObserver { |
42 public: | 46 public: |
43 typedef std::set<extensions::ExtensionHost*> ExtensionHostSet; | 47 typedef std::set<extensions::ExtensionHost*> ExtensionHostSet; |
44 typedef ExtensionHostSet::const_iterator const_iterator; | 48 typedef ExtensionHostSet::const_iterator const_iterator; |
45 | 49 |
46 static ProcessManager* Create(content::BrowserContext* context); | 50 static ProcessManager* Create(content::BrowserContext* context); |
47 virtual ~ProcessManager(); | 51 virtual ~ProcessManager(); |
48 | 52 |
49 const ExtensionHostSet& background_hosts() const { | 53 const ExtensionHostSet& background_hosts() const { |
50 return background_hosts_; | 54 return background_hosts_; |
51 } | 55 } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 content::BrowserContext* original_context); | 155 content::BrowserContext* original_context); |
152 | 156 |
153 // Called on browser shutdown to close our extension hosts. | 157 // Called on browser shutdown to close our extension hosts. |
154 void CloseBackgroundHosts(); | 158 void CloseBackgroundHosts(); |
155 | 159 |
156 // content::NotificationObserver: | 160 // content::NotificationObserver: |
157 virtual void Observe(int type, | 161 virtual void Observe(int type, |
158 const content::NotificationSource& source, | 162 const content::NotificationSource& source, |
159 const content::NotificationDetails& details) OVERRIDE; | 163 const content::NotificationDetails& details) OVERRIDE; |
160 | 164 |
| 165 // ExtensionRegistryObserver: |
| 166 virtual void OnExtensionLoaded(content::BrowserContext* browser_context, |
| 167 const Extension* extension) OVERRIDE; |
| 168 virtual void OnExtensionUnloaded( |
| 169 content::BrowserContext* browser_context, |
| 170 const Extension* extension, |
| 171 UnloadedExtensionInfo::Reason reason) OVERRIDE; |
| 172 |
161 // Load all background pages once the profile data is ready and the pages | 173 // Load all background pages once the profile data is ready and the pages |
162 // should be loaded. | 174 // should be loaded. |
163 void CreateBackgroundHostsForProfileStartup(); | 175 void CreateBackgroundHostsForProfileStartup(); |
164 | 176 |
165 content::NotificationRegistrar registrar_; | 177 content::NotificationRegistrar registrar_; |
166 | 178 |
167 // The set of ExtensionHosts running viewless background extensions. | 179 // The set of ExtensionHosts running viewless background extensions. |
168 ExtensionHostSet background_hosts_; | 180 ExtensionHostSet background_hosts_; |
169 | 181 |
170 // A SiteInstance related to the SiteInstance for all extensions in | 182 // A SiteInstance related to the SiteInstance for all extensions in |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 // value of the extension's close_sequence_id at the beginning of the process. | 269 // value of the extension's close_sequence_id at the beginning of the process. |
258 // Thus comparisons can be done to halt when IDs no longer match. | 270 // Thus comparisons can be done to halt when IDs no longer match. |
259 // | 271 // |
260 // This counter provides unique IDs even when BackgroundPageData objects are | 272 // This counter provides unique IDs even when BackgroundPageData objects are |
261 // reset. | 273 // reset. |
262 uint64 last_background_close_sequence_id_; | 274 uint64 last_background_close_sequence_id_; |
263 | 275 |
264 // Must be last member, see doc on WeakPtrFactory. | 276 // Must be last member, see doc on WeakPtrFactory. |
265 base::WeakPtrFactory<ProcessManager> weak_ptr_factory_; | 277 base::WeakPtrFactory<ProcessManager> weak_ptr_factory_; |
266 | 278 |
| 279 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
| 280 extension_registry_observer_; |
| 281 |
267 DISALLOW_COPY_AND_ASSIGN(ProcessManager); | 282 DISALLOW_COPY_AND_ASSIGN(ProcessManager); |
268 }; | 283 }; |
269 | 284 |
270 } // namespace extensions | 285 } // namespace extensions |
271 | 286 |
272 #endif // EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ | 287 #endif // EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ |
OLD | NEW |