Index: chrome/browser/extensions/extension_process_manager.cc |
diff --git a/chrome/browser/extensions/extension_process_manager.cc b/chrome/browser/extensions/extension_process_manager.cc |
index f64624c2588ff844e10f21e1eb4623c78bb0b87d..213e726c8854b548a9da1cabd950521c7c423ec4 100644 |
--- a/chrome/browser/extensions/extension_process_manager.cc |
+++ b/chrome/browser/extensions/extension_process_manager.cc |
@@ -2,6 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
+#include "base/command_line.h" |
#include "chrome/browser/extensions/extension_process_manager.h" |
#include "chrome/browser/ui/browser_window.h" |
@@ -14,6 +15,7 @@ |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/ui/browser.h" |
#include "chrome/common/chrome_notification_types.h" |
+#include "chrome/common/chrome_switches.h" |
#include "chrome/common/extensions/extension.h" |
#include "chrome/common/url_constants.h" |
#include "content/browser/site_instance.h" |
@@ -55,18 +57,18 @@ class IncognitoExtensionProcessManager : public ExtensionProcessManager { |
ExtensionProcessManager* original_manager_; |
}; |
-static void CreateBackgroundHost( |
+static void CreateBackgroundHostForExtensionLoad( |
ExtensionProcessManager* manager, const Extension* extension) { |
- // Start the process for the master page, if it exists. |
+ // Start the process for the master page, if it exists and we're not lazy. |
if (extension->background_url().is_valid()) |
manager->CreateBackgroundHost(extension, extension->background_url()); |
} |
-static void CreateBackgroundHosts( |
+static void CreateBackgroundHostsForProfileStartup( |
ExtensionProcessManager* manager, const ExtensionList* extensions) { |
for (ExtensionList::const_iterator extension = extensions->begin(); |
extension != extensions->end(); ++extension) { |
- CreateBackgroundHost(manager, *extension); |
+ CreateBackgroundHostForExtensionLoad(manager, *extension); |
} |
} |
@@ -288,17 +290,23 @@ void ExtensionProcessManager::Observe(int type, |
const NotificationDetails& details) { |
switch (type) { |
case chrome::NOTIFICATION_EXTENSIONS_READY: { |
- CreateBackgroundHosts(this, |
+ if (CommandLine::ForCurrentProcess()->HasSwitch( |
Aaron Boodman
2011/08/23 22:41:16
As discussed in chat, try moving these to CreateBa
Tessa MacDuff
2011/08/24 00:34:23
Done.
|
+ switches::kEnableLazyBackgroundPages)) |
+ break; |
+ CreateBackgroundHostsForProfileStartup(this, |
Source<Profile>(source).ptr()->GetExtensionService()->extensions()); |
break; |
} |
case chrome::NOTIFICATION_EXTENSION_LOADED: { |
+ if (CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kEnableLazyBackgroundPages)) |
+ break; |
ExtensionService* service = |
Source<Profile>(source).ptr()->GetExtensionService(); |
if (service->is_ready()) { |
const Extension* extension = Details<const Extension>(details).ptr(); |
- ::CreateBackgroundHost(this, extension); |
+ ::CreateBackgroundHostForExtensionLoad(this, extension); |
} |
break; |
} |
@@ -470,6 +478,9 @@ void IncognitoExtensionProcessManager::Observe( |
const NotificationDetails& details) { |
switch (type) { |
case chrome::NOTIFICATION_BROWSER_WINDOW_READY: { |
+ if (CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kEnableLazyBackgroundPages)) |
+ break; |
// We want to spawn our background hosts as soon as the user opens an |
// incognito window. Watch for new browsers and create the hosts if |
// it matches our profile. |
@@ -482,7 +493,7 @@ void IncognitoExtensionProcessManager::Observe( |
Profile::FromBrowserContext(browsing_instance_->browser_context()); |
ExtensionService* service = profile->GetExtensionService(); |
if (service && service->is_ready()) |
- CreateBackgroundHosts(this, service->extensions()); |
+ CreateBackgroundHostsForProfileStartup(this, service->extensions()); |
} |
break; |
} |