Chromium Code Reviews| Index: extensions/browser/process_manager.h |
| diff --git a/extensions/browser/process_manager.h b/extensions/browser/process_manager.h |
| index 664c9420fde504a05d071e6de9a9a232722b57fa..c4d8e910d0a005f4246f3163ef30e0c60096541e 100644 |
| --- a/extensions/browser/process_manager.h |
| +++ b/extensions/browser/process_manager.h |
| @@ -35,6 +35,24 @@ class Extension; |
| class ExtensionHost; |
| class ProcessManagerObserver; |
| +// Customization of ProcessManager from the extension system embedder. |
| +class ProcessManagerDelegate { |
|
Yoyo Zhou
2014/07/15 02:13:22
Probably it's best to put this in a separate heade
James Cook
2014/07/15 17:02:52
Done.
|
| + public: |
| + virtual ~ProcessManagerDelegate() {} |
| + |
| + // Returns true if the embedder allows background pages for the given |
| + // |context|. |
| + virtual bool IsBackgroundPageAllowed( |
| + content::BrowserContext* context) const = 0; |
| + |
| + // Returns true if the embedder wishes to defer starting up the renderers for |
| + // extension background pages. If the embedder returns true it must call |
| + // ProcessManager::MaybeCreateStartupBackgroundHosts() when it is ready. See |
| + // ChromeProcessManagerDelegate for examples of how this is useful. |
| + virtual bool DeferCreatingStartupBackgroundHosts( |
| + content::BrowserContext* context) const = 0; |
| +}; |
| + |
| // Manages dynamic state of running Chromium extensions. There is one instance |
| // of this class per Profile. OTR Profiles have a separate instance that keeps |
| // track of split-mode extensions only. |
| @@ -122,8 +140,9 @@ class ProcessManager : public content::NotificationObserver { |
| // onSuspendCanceled() event to it. |
| void CancelSuspend(const Extension* extension); |
| - // Ensures background hosts are loaded for a new browser window. |
| - void OnBrowserWindowReady(); |
| + // Creates background hosts if the embedder is ready and they are not already |
| + // loaded. |
| + void MaybeCreateStartupBackgroundHosts(); |
| // Gets the BrowserContext associated with site_instance_ and all other |
| // related SiteInstances. |
| @@ -144,6 +163,10 @@ class ProcessManager : public content::NotificationObserver { |
| content::BrowserContext* original_context, |
| ProcessManager* original_manager); |
| + bool startup_background_hosts_created_for_test() const { |
| + return startup_background_hosts_created_; |
| + } |
| + |
| protected: |
| // If |context| is incognito pass the master context as |original_context|. |
| // Otherwise pass the same context for both. |
| @@ -160,7 +183,7 @@ class ProcessManager : public content::NotificationObserver { |
| // Load all background pages once the profile data is ready and the pages |
| // should be loaded. |
| - void CreateBackgroundHostsForProfileStartup(); |
| + void CreateStartupBackgroundHosts(); |
|
Yoyo Zhou
2014/07/15 02:13:22
nit: does this need to be protected? can it be in
James Cook
2014/07/15 17:02:52
Good catch! Moved to private.
|
| content::NotificationRegistrar registrar_; |
| @@ -216,9 +239,6 @@ class ProcessManager : public content::NotificationObserver { |
| // Clears background page data for this extension. |
| void ClearBackgroundPageData(const std::string& extension_id); |
| - // Returns true if loading background pages should be deferred. |
| - bool DeferLoadingBackgroundHosts() const; |
| - |
| void OnDevToolsStateChanged(content::DevToolsAgentHost*, bool attached); |
| // Contains all active extension-related RenderViewHost instances for all |