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 | 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/time/time.h" | 16 #include "base/time/time.h" |
17 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
18 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
19 #include "extensions/common/view_type.h" | 19 #include "extensions/common/view_type.h" |
20 | 20 |
21 class Browser; | 21 class Browser; |
22 class GURL; | 22 class GURL; |
23 class Profile; | |
24 | 23 |
25 namespace content { | 24 namespace content { |
26 class BrowserContext; | 25 class BrowserContext; |
27 class DevToolsAgentHost; | 26 class DevToolsAgentHost; |
28 class RenderViewHost; | 27 class RenderViewHost; |
29 class SiteInstance; | 28 class SiteInstance; |
30 }; | 29 }; |
31 | 30 |
32 namespace extensions { | 31 namespace extensions { |
33 class Extension; | 32 class Extension; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 133 |
135 // Prevents |extension|'s background page from being closed and sends the | 134 // Prevents |extension|'s background page from being closed and sends the |
136 // onSuspendCanceled() event to it. | 135 // onSuspendCanceled() event to it. |
137 void CancelSuspend(const extensions::Extension* extension); | 136 void CancelSuspend(const extensions::Extension* extension); |
138 | 137 |
139 // If |defer| is true background host creation is to be deferred until this is | 138 // If |defer| is true background host creation is to be deferred until this is |
140 // called again with |defer| set to false, at which point all deferred | 139 // called again with |defer| set to false, at which point all deferred |
141 // background hosts will be created. Defaults to false. | 140 // background hosts will be created. Defaults to false. |
142 void DeferBackgroundHostCreation(bool defer); | 141 void DeferBackgroundHostCreation(bool defer); |
143 | 142 |
| 143 // Ensures background hosts are loaded for a new browser window. |
| 144 void OnBrowserWindowReady(); |
| 145 |
| 146 // Gets the BrowserContext associated with site_instance_ and all other |
| 147 // related SiteInstances. |
| 148 content::BrowserContext* GetBrowserContext() const; |
| 149 |
144 protected: | 150 protected: |
145 // If |context| is incognito pass the master context as |original_context|. | 151 // If |context| is incognito pass the master context as |original_context|. |
146 // Otherwise pass the same context for both. | 152 // Otherwise pass the same context for both. |
147 ExtensionProcessManager(content::BrowserContext* context, | 153 ExtensionProcessManager(content::BrowserContext* context, |
148 content::BrowserContext* original_context); | 154 content::BrowserContext* original_context); |
149 | 155 |
150 // Called just after |host| is created so it can be registered in our lists. | 156 // Called just after |host| is created so it can be registered in our lists. |
151 void OnExtensionHostCreated(extensions::ExtensionHost* host, | 157 void OnExtensionHostCreated(extensions::ExtensionHost* host, |
152 bool is_background); | 158 bool is_background); |
153 | 159 |
154 // Called on browser shutdown to close our extension hosts. | 160 // Called on browser shutdown to close our extension hosts. |
155 void CloseBackgroundHosts(); | 161 void CloseBackgroundHosts(); |
156 | 162 |
157 // content::NotificationObserver: | 163 // content::NotificationObserver: |
158 virtual void Observe(int type, | 164 virtual void Observe(int type, |
159 const content::NotificationSource& source, | 165 const content::NotificationSource& source, |
160 const content::NotificationDetails& details) OVERRIDE; | 166 const content::NotificationDetails& details) OVERRIDE; |
161 | 167 |
162 // Load all background pages once the profile data is ready and the pages | 168 // Load all background pages once the profile data is ready and the pages |
163 // should be loaded. | 169 // should be loaded. |
164 void CreateBackgroundHostsForProfileStartup(); | 170 void CreateBackgroundHostsForProfileStartup(); |
165 | 171 |
166 // Gets the profile associated with site_instance_ and all other | |
167 // related SiteInstances. | |
168 Profile* GetProfile() const; | |
169 | |
170 // Returns the same value as GetProfile() as a BrowserContext. | |
171 content::BrowserContext* GetBrowserContext() const; | |
172 | |
173 content::NotificationRegistrar registrar_; | 172 content::NotificationRegistrar registrar_; |
174 | 173 |
175 // The set of ExtensionHosts running viewless background extensions. | 174 // The set of ExtensionHosts running viewless background extensions. |
176 ExtensionHostSet background_hosts_; | 175 ExtensionHostSet background_hosts_; |
177 | 176 |
178 // A SiteInstance related to the SiteInstance for all extensions in | 177 // A SiteInstance related to the SiteInstance for all extensions in |
179 // this profile. We create it in such a way that a new | 178 // this profile. We create it in such a way that a new |
180 // browsing instance is created. This controls process grouping. | 179 // browsing instance is created. This controls process grouping. |
181 scoped_refptr<content::SiteInstance> site_instance_; | 180 scoped_refptr<content::SiteInstance> site_instance_; |
182 | 181 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 // sending a ShouldSuspend message; read from command-line switch. | 231 // sending a ShouldSuspend message; read from command-line switch. |
233 base::TimeDelta event_page_idle_time_; | 232 base::TimeDelta event_page_idle_time_; |
234 | 233 |
235 // The time to delay between sending a ShouldSuspend message and | 234 // The time to delay between sending a ShouldSuspend message and |
236 // sending a Suspend message; read from command-line switch. | 235 // sending a Suspend message; read from command-line switch. |
237 base::TimeDelta event_page_suspending_time_; | 236 base::TimeDelta event_page_suspending_time_; |
238 | 237 |
239 // If true, then creation of background hosts is suspended. | 238 // If true, then creation of background hosts is suspended. |
240 bool defer_background_host_creation_; | 239 bool defer_background_host_creation_; |
241 | 240 |
| 241 // True if we have created the startup set of background hosts. |
| 242 bool startup_background_hosts_created_; |
| 243 |
242 base::Callback<void(content::DevToolsAgentHost*, bool)> devtools_callback_; | 244 base::Callback<void(content::DevToolsAgentHost*, bool)> devtools_callback_; |
243 | 245 |
244 base::WeakPtrFactory<ExtensionProcessManager> weak_ptr_factory_; | 246 base::WeakPtrFactory<ExtensionProcessManager> weak_ptr_factory_; |
245 | 247 |
246 DISALLOW_COPY_AND_ASSIGN(ExtensionProcessManager); | 248 DISALLOW_COPY_AND_ASSIGN(ExtensionProcessManager); |
247 }; | 249 }; |
248 | 250 |
249 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ | 251 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ |
OLD | NEW |