diff options
author | atwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-24 07:01:10 +0000 |
---|---|---|
committer | atwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-24 07:01:10 +0000 |
commit | 186c8af18006730780f4dbd5c1d8921bc139e060 (patch) | |
tree | cb8dbfa89f3743e1529061850d4192f047b3d20a | |
parent | e1bc00131f2c175e69da6188f744f976a3de14cb (diff) | |
download | chromium_src-186c8af18006730780f4dbd5c1d8921bc139e060.zip chromium_src-186c8af18006730780f4dbd5c1d8921bc139e060.tar.gz chromium_src-186c8af18006730780f4dbd5c1d8921bc139e060.tar.bz2 |
Turn background mode on by default on windows.
Added a common routine to check whether background mode/background page tracking
should be enabled with logic to enable it by default on windows.
BUG=59980
TEST=existing tests suffice
Review URL: http://codereview.chromium.org/5296003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67235 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/about_flags.cc | 2 | ||||
-rw-r--r-- | chrome/browser/background_mode_manager.cc | 27 | ||||
-rw-r--r-- | chrome/browser/background_mode_manager.h | 2 | ||||
-rw-r--r-- | chrome/browser/background_page_tracker.cc | 11 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 8 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 1 |
6 files changed, 41 insertions, 10 deletions
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index 0000aa5..722cd5d 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -136,7 +136,7 @@ const Experiment kExperiments[] = { "background-webapps", // FLAGS:RECORD_UMA IDS_FLAGS_BACKGROUND_WEBAPPS_NAME, IDS_FLAGS_BACKGROUND_WEBAPPS_DESCRIPTION, - kOsAll, + kOsMac | kOsLinux | kOsCrOS, // Enabled by default on windows switches::kEnableBackgroundMode }, { diff --git a/chrome/browser/background_mode_manager.cc b/chrome/browser/background_mode_manager.cc index 8f78dfb..99c0ee3 100644 --- a/chrome/browser/background_mode_manager.cc +++ b/chrome/browser/background_mode_manager.cc @@ -150,10 +150,9 @@ BackgroundModeManager::BackgroundModeManager(Profile* profile, keep_alive_for_startup_(false), status_tray_(NULL), status_icon_(NULL) { - // If background mode or apps are disabled, just exit - don't listen for - // any notifications. - if (!command_line->HasSwitch(switches::kEnableBackgroundMode) || - command_line->HasSwitch(switches::kDisableExtensions)) + // If background mode is disabled, just exit - don't listen for any + // notifications. + if (!IsBackgroundModeEnabled(command_line)) return; // Keep the browser alive until extensions are done loading - this is needed @@ -552,3 +551,23 @@ Browser* BackgroundModeManager::GetBrowserWindow() { void BackgroundModeManager::RegisterUserPrefs(PrefService* prefs) { prefs->RegisterBooleanPref(prefs::kLaunchOnStartupResetAllowed, false); } + +// static +bool BackgroundModeManager::IsBackgroundModeEnabled( + const CommandLine* command_line) { + + // Background mode is disabled if the appropriate flag is passed, or if + // extensions are disabled. + bool background_mode_enabled = + !command_line->HasSwitch(switches::kDisableBackgroundMode) && + !command_line->HasSwitch(switches::kDisableExtensions); +#if !defined(OS_WIN) + // BackgroundMode is enabled by default on windows. On other platforms, it + // is enabled via about:flags. + background_mode_enabled = background_mode_enabled && + command_line->HasSwitch(switches::kEnableBackgroundMode); +#endif + + return background_mode_enabled; +} + diff --git a/chrome/browser/background_mode_manager.h b/chrome/browser/background_mode_manager.h index dbae6e5..6da40ec 100644 --- a/chrome/browser/background_mode_manager.h +++ b/chrome/browser/background_mode_manager.h @@ -46,6 +46,8 @@ class BackgroundModeManager static void RegisterUserPrefs(PrefService* prefs); + static bool IsBackgroundModeEnabled(const CommandLine* command_line); + private: friend class TestBackgroundModeManager; friend class BackgroundModeManagerTest; diff --git a/chrome/browser/background_page_tracker.cc b/chrome/browser/background_page_tracker.cc index 8647e5d..515ca75 100644 --- a/chrome/browser/background_page_tracker.cc +++ b/chrome/browser/background_page_tracker.cc @@ -11,6 +11,7 @@ #include "base/values.h" #include "chrome/browser/background_application_list_model.h" #include "chrome/browser/background_contents_service.h" +#include "chrome/browser/background_mode_manager.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/prefs/pref_service.h" @@ -134,11 +135,13 @@ PrefService* BackgroundPageTracker::GetPrefService() { } bool BackgroundPageTracker::IsEnabled() { - // BackgroundPageTracker is enabled if both extensions and background mode - // are enabled. + // Disable the background page tracker for unittests. + if (!g_browser_process->local_state()) + return false; + + // BackgroundPageTracker is enabled if background mode is enabled. CommandLine* command_line = CommandLine::ForCurrentProcess(); - return command_line->HasSwitch(switches::kEnableBackgroundMode) && - !command_line->HasSwitch(switches::kDisableExtensions); + return BackgroundModeManager::IsBackgroundModeEnabled(command_line); } void BackgroundPageTracker::Observe(NotificationType type, diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 8e99e8e..e036dd0 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -157,6 +157,11 @@ const char kDisableAudio[] = "disable-audio"; const char kDisableAuthNegotiateCnameLookup[] = "disable-auth-negotiate-cname-lookup"; +// Disable background mode (background apps will not keep chrome running in the +// background). This has priority over the kEnableBackgroundMode flag which is +// settable via about:labs. +const char kDisableBackgroundMode[] = "disable-background-mode"; + // Disable several subsystems which run network requests in the background. // This is for use when doing network performance testing to avoid noise // in the measurements. @@ -390,7 +395,8 @@ const char kEnableAppLauncher[] = "enable-app-launcher"; const char kEnableAuthNegotiatePort[] = "enable-auth-negotiate-port"; // Enable background mode (background apps will keep chrome running in the -// background and allow chrome to launch on startup). +// background and allow chrome to launch on startup). Has no effect on Windows +// because background mode is enabled there by default. const char kEnableBackgroundMode[] = "enable-background-mode"; // Enables the benchmarking extensions. diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 1154171..152e5af 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -55,6 +55,7 @@ extern const char kDisableAltWinstation[]; extern const char kDisableApplicationCache[]; extern const char kDisableAudio[]; extern const char kDisableAuthNegotiateCnameLookup[]; +extern const char kDisableBackgroundMode[]; extern const char kDisableBackgroundNetworking[]; extern const char kDisableBackingStoreLimit[]; extern const char kDisableConnectBackupJobs[]; |