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_PROCESS_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 | 12 |
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 "content/public/common/view_type.h" | 15 #include "content/public/common/view_type.h" |
16 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
17 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
18 | 18 |
19 class Browser; | 19 class Browser; |
20 class Extension; | 20 class Extension; |
21 class ExtensionHost; | 21 class ExtensionHost; |
22 class GURL; | 22 class GURL; |
23 class Profile; | 23 class Profile; |
24 class RenderViewHost; | 24 class RenderViewHost; |
| 25 |
| 26 namespace content { |
25 class SiteInstance; | 27 class SiteInstance; |
| 28 }; |
26 | 29 |
27 // Manages dynamic state of running Chromium extensions. There is one instance | 30 // Manages dynamic state of running Chromium extensions. There is one instance |
28 // of this class per Profile. OTR Profiles have a separate instance that keeps | 31 // of this class per Profile. OTR Profiles have a separate instance that keeps |
29 // track of split-mode extensions only. | 32 // track of split-mode extensions only. |
30 class ExtensionProcessManager : public content::NotificationObserver { | 33 class ExtensionProcessManager : public content::NotificationObserver { |
31 public: | 34 public: |
32 static ExtensionProcessManager* Create(Profile* profile); | 35 static ExtensionProcessManager* Create(Profile* profile); |
33 virtual ~ExtensionProcessManager(); | 36 virtual ~ExtensionProcessManager(); |
34 | 37 |
35 // Creates a new ExtensionHost with its associated view, grouping it in the | 38 // Creates a new ExtensionHost with its associated view, grouping it in the |
(...skipping 26 matching lines...) Expand all Loading... |
62 virtual void CreateBackgroundHost(const Extension* extension, | 65 virtual void CreateBackgroundHost(const Extension* extension, |
63 const GURL& url); | 66 const GURL& url); |
64 | 67 |
65 // Gets the ExtensionHost for the background page for an extension, or NULL if | 68 // Gets the ExtensionHost for the background page for an extension, or NULL if |
66 // the extension isn't running or doesn't have a background page. | 69 // the extension isn't running or doesn't have a background page. |
67 ExtensionHost* GetBackgroundHostForExtension(const std::string& extension_id); | 70 ExtensionHost* GetBackgroundHostForExtension(const std::string& extension_id); |
68 | 71 |
69 // Returns the SiteInstance that the given URL belongs to. | 72 // Returns the SiteInstance that the given URL belongs to. |
70 // TODO(aa): This only returns correct results for extensions and packaged | 73 // TODO(aa): This only returns correct results for extensions and packaged |
71 // apps, not hosted apps. | 74 // apps, not hosted apps. |
72 virtual SiteInstance* GetSiteInstanceForURL(const GURL& url); | 75 virtual content::SiteInstance* GetSiteInstanceForURL(const GURL& url); |
73 | 76 |
74 // Registers a RenderViewHost as hosting a given extension. | 77 // Registers a RenderViewHost as hosting a given extension. |
75 void RegisterRenderViewHost(RenderViewHost* render_view_host, | 78 void RegisterRenderViewHost(RenderViewHost* render_view_host, |
76 const Extension* extension); | 79 const Extension* extension); |
77 | 80 |
78 // Unregisters a RenderViewHost as hosting any extension. | 81 // Unregisters a RenderViewHost as hosting any extension. |
79 void UnregisterRenderViewHost(RenderViewHost* render_view_host); | 82 void UnregisterRenderViewHost(RenderViewHost* render_view_host); |
80 | 83 |
81 // Returns all RenderViewHosts that are registered for the specified | 84 // Returns all RenderViewHosts that are registered for the specified |
82 // extension. | 85 // extension. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 | 120 |
118 // The set of all ExtensionHosts managed by this process manager. | 121 // The set of all ExtensionHosts managed by this process manager. |
119 ExtensionHostSet all_hosts_; | 122 ExtensionHostSet all_hosts_; |
120 | 123 |
121 // The set of running viewless background extensions. | 124 // The set of running viewless background extensions. |
122 ExtensionHostSet background_hosts_; | 125 ExtensionHostSet background_hosts_; |
123 | 126 |
124 // A SiteInstance related to the SiteInstance for all extensions in | 127 // A SiteInstance related to the SiteInstance for all extensions in |
125 // this profile. We create it in such a way that a new | 128 // this profile. We create it in such a way that a new |
126 // browsing instance is created. This controls process grouping. | 129 // browsing instance is created. This controls process grouping. |
127 scoped_refptr<SiteInstance> site_instance_; | 130 scoped_refptr<content::SiteInstance> site_instance_; |
128 | 131 |
129 private: | 132 private: |
130 // Contains all extension-related RenderViewHost instances for all extensions. | 133 // Contains all extension-related RenderViewHost instances for all extensions. |
131 typedef std::set<RenderViewHost*> RenderViewHostSet; | 134 typedef std::set<RenderViewHost*> RenderViewHostSet; |
132 RenderViewHostSet all_extension_views_; | 135 RenderViewHostSet all_extension_views_; |
133 | 136 |
134 // Close the given |host| iff it's a background page. | 137 // Close the given |host| iff it's a background page. |
135 void CloseBackgroundHost(ExtensionHost* host); | 138 void CloseBackgroundHost(ExtensionHost* host); |
136 | 139 |
137 // Excludes background page. | 140 // Excludes background page. |
138 bool HasVisibleViews(const std::string& extension_id); | 141 bool HasVisibleViews(const std::string& extension_id); |
139 | 142 |
140 DISALLOW_COPY_AND_ASSIGN(ExtensionProcessManager); | 143 DISALLOW_COPY_AND_ASSIGN(ExtensionProcessManager); |
141 }; | 144 }; |
142 | 145 |
143 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ | 146 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ |
OLD | NEW |