Index: extensions/browser/process_manager.cc |
diff --git a/extensions/browser/process_manager.cc b/extensions/browser/process_manager.cc |
index f6297ec21c8f79c01e0a5d1c796a17043e8e0fd9..1017ff7166b1d2c239b0c4c1a0971c16bc7f4e32 100644 |
--- a/extensions/browser/process_manager.cc |
+++ b/extensions/browser/process_manager.cc |
@@ -227,6 +227,7 @@ ProcessManager::ProcessManager(BrowserContext* context, |
&ProcessManager::OnDevToolsStateChanged, |
base::Unretained(this))), |
weak_ptr_factory_(this) { |
+ LOG(ERROR) << "JAMES new ProcessManager"; |
registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY, |
content::Source<BrowserContext>(original_context)); |
registrar_.Add(this, |
@@ -615,13 +616,14 @@ void ProcessManager::CancelSuspend(const Extension* extension) { |
} |
void ProcessManager::OnBrowserWindowReady() { |
+ LOG(ERROR) << "JAMES OnBrowserWindowReady"; |
// If the extension system isn't ready yet the background hosts will be |
// created via NOTIFICATION_EXTENSIONS_READY below. |
ExtensionSystem* system = ExtensionSystem::Get(GetBrowserContext()); |
if (!system->ready().is_signaled()) |
return; |
- CreateBackgroundHostsForProfileStartup(); |
+ MaybeCreateBackgroundHostsForStartup(); |
} |
content::BrowserContext* ProcessManager::GetBrowserContext() const { |
@@ -644,13 +646,12 @@ void ProcessManager::Observe(int type, |
switch (type) { |
case chrome::NOTIFICATION_EXTENSIONS_READY: |
case chrome::NOTIFICATION_PROFILE_CREATED: { |
- // Don't load background hosts now if the loading should be deferred. |
- // Instead they will be loaded when a browser window for this profile |
- // (or an incognito profile from this profile) is ready. |
- if (DeferLoadingBackgroundHosts()) |
- break; |
+ if (type == chrome::NOTIFICATION_EXTENSIONS_READY) |
+ LOG(ERROR) << "JAMES got extensions_ready"; |
+ else |
+ LOG(ERROR) << "JAMES got profile_created"; |
- CreateBackgroundHostsForProfileStartup(); |
+ MaybeCreateBackgroundHostsForStartup(); |
break; |
} |
@@ -742,6 +743,7 @@ void ProcessManager::Observe(int type, |
} |
case chrome::NOTIFICATION_PROFILE_DESTROYED: { |
+ LOG(ERROR) << "JAMES got profile_destroyed"; |
// Close background hosts when the last browser is closed so that they |
// have time to shutdown various objects on different threads. Our |
// destructor is called too late in the shutdown sequence. |
@@ -778,12 +780,16 @@ void ProcessManager::OnDevToolsStateChanged( |
} |
} |
-void ProcessManager::CreateBackgroundHostsForProfileStartup() { |
- if (startup_background_hosts_created_ || |
- !ExtensionsBrowserClient::Get()-> |
- IsBackgroundPageAllowed(GetBrowserContext())) { |
+void ProcessManager::MaybeCreateBackgroundHostsForStartup() { |
+ if (startup_background_hosts_created_) |
+ return; |
+ |
+ // The embedder might want to defer background page loading. For example, |
+ // Chrome defers background page loading when it is launched to show the app |
+ // list, then triggers a load later via OnBrowserWindowReady(). |
+ if (ExtensionsBrowserClient::Get()->DeferLoadingBackgroundHosts( |
+ GetBrowserContext())) |
return; |
- } |
const ExtensionSet& enabled_extensions = |
ExtensionRegistry::Get(GetBrowserContext())->enabled_extensions(); |