Index: trunk/src/chrome/browser/extensions/chrome_extensions_browser_client.cc |
=================================================================== |
--- trunk/src/chrome/browser/extensions/chrome_extensions_browser_client.cc (revision 283800) |
+++ trunk/src/chrome/browser/extensions/chrome_extensions_browser_client.cc (working copy) |
@@ -21,6 +21,7 @@ |
#include "chrome/browser/external_protocol/external_protocol_handler.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/profiles/profile_manager.h" |
+#include "chrome/browser/ui/browser_finder.h" |
#include "chrome/common/chrome_paths.h" |
#include "chrome/common/chrome_switches.h" |
#include "chrome/common/chrome_version_info.h" |
@@ -41,14 +42,12 @@ |
#include "chrome/browser/extensions/activity_log/activity_log.h" |
#include "chrome/browser/extensions/api/chrome_extensions_api_client.h" |
#include "chrome/browser/extensions/api/content_settings/content_settings_service.h" |
-#include "chrome/browser/extensions/chrome_process_manager_delegate.h" |
#endif |
namespace extensions { |
ChromeExtensionsBrowserClient::ChromeExtensionsBrowserClient() { |
#if defined(ENABLE_EXTENSIONS) |
- process_manager_delegate_.reset(new ChromeProcessManagerDelegate); |
api_client_.reset(new ChromeExtensionsAPIClient); |
#endif |
// Only set if it hasn't already been set (e.g. by a test). |
@@ -159,15 +158,35 @@ |
#endif |
} |
-ProcessManagerDelegate* |
-ChromeExtensionsBrowserClient::GetProcessManagerDelegate() const { |
-#if defined(ENABLE_EXTENSIONS) |
- return process_manager_delegate_.get(); |
+bool ChromeExtensionsBrowserClient::DeferLoadingBackgroundHosts( |
+ content::BrowserContext* context) const { |
+ Profile* profile = static_cast<Profile*>(context); |
+ |
+ // The profile may not be valid yet if it is still being initialized. |
+ // In that case, defer loading, since it depends on an initialized profile. |
+ // http://crbug.com/222473 |
+ if (!g_browser_process->profile_manager()->IsValidProfile(profile)) |
+ return true; |
+ |
+#if defined(OS_ANDROID) |
+ return false; |
#else |
- return NULL; |
+ // There are no browser windows open and the browser process was |
+ // started to show the app launcher. |
+ return chrome::GetTotalBrowserCountForProfile(profile) == 0 && |
+ CommandLine::ForCurrentProcess()->HasSwitch(switches::kShowAppList); |
#endif |
} |
+bool ChromeExtensionsBrowserClient::IsBackgroundPageAllowed( |
+ content::BrowserContext* context) const { |
+ // Returns true if current session is Guest mode session and current |
+ // browser context is *not* off-the-record. Such context is artificial and |
+ // background page shouldn't be created in it. |
+ return !static_cast<Profile*>(context)->IsGuestSession() || |
+ context->IsOffTheRecord(); |
+} |
+ |
scoped_ptr<ExtensionHostDelegate> |
ChromeExtensionsBrowserClient::CreateExtensionHostDelegate() { |
return scoped_ptr<ExtensionHostDelegate>(new ChromeExtensionHostDelegate); |