diff options
-rw-r--r-- | chrome/app/chrome_command_ids.h | 3 | ||||
-rw-r--r-- | chrome/app/chromium_strings.grd | 9 | ||||
-rw-r--r-- | chrome/app/generated_resources.grd | 3 | ||||
-rw-r--r-- | chrome/app/google_chrome_strings.grd | 9 | ||||
-rw-r--r-- | chrome/browser/background_mode_manager.cc | 102 | ||||
-rw-r--r-- | chrome/browser/background_mode_manager.h | 24 | ||||
-rw-r--r-- | chrome/browser/background_mode_manager_unittest.cc | 64 | ||||
-rw-r--r-- | chrome/browser/resources/options/advanced_options.html | 11 | ||||
-rw-r--r-- | chrome/browser/resources/options/advanced_options.js | 11 | ||||
-rw-r--r-- | chrome/browser/ui/webui/options/advanced_options_handler.cc | 42 | ||||
-rw-r--r-- | chrome/browser/ui/webui/options/advanced_options_handler.h | 13 | ||||
-rw-r--r-- | chrome/common/pref_names.cc | 3 | ||||
-rw-r--r-- | chrome/common/pref_names.h | 1 |
13 files changed, 275 insertions, 20 deletions
diff --git a/chrome/app/chrome_command_ids.h b/chrome/app/chrome_command_ids.h index a9cabbf..b149d62 100644 --- a/chrome/app/chrome_command_ids.h +++ b/chrome/app/chrome_command_ids.h @@ -272,3 +272,6 @@ #define IDC_BOOKMARK_BAR_NEW_FOLDER 51008 #define IDC_BOOKMARK_MANAGER 51009 #define IDC_BOOKMARK_BAR_ALWAYS_SHOW 51010 + +// Context menu items in the status tray +#define IDC_STATUS_TRAY_KEEP_CHROME_RUNNING_IN_BACKGROUND 51100 diff --git a/chrome/app/chromium_strings.grd b/chrome/app/chromium_strings.grd index eb34a83..fb5960b 100644 --- a/chrome/app/chromium_strings.grd +++ b/chrome/app/chromium_strings.grd @@ -336,6 +336,15 @@ be available for now. --> Please sign out of Chromium OS and sign in again for this change to take effect. </message> </if> + <message name="IDS_STATUS_TRAY_KEEP_CHROME_RUNNING_IN_BACKGROUND" desc="The checkbox in the status tray context menu that controls whether chrome keeps running in the background after the last window is closed"> + Let Chromium Run In The Background + </message> + <message name="IDS_OPTIONS_BACKGROUND_ENABLE_BACKGROUND_MODE" desc="The label of the check-box that enables background mode"> + Continue running background apps when Chromium is closed + </message> + <message name="IDS_CONFIRM_EXIT_BACKGROUND_MODE_BODY" desc="Confirmation displayed when disabling background mode via the status tray context menu when there are no windows open"> + Are you sure you want to quit Chromium? (This setting can be toggled in <ph name="OPTIONS_MENU_LABEL">$1<ex>Options</ex></ph> - Under the Hood) + </message> <message name="IDS_CANT_WRITE_USER_DIRECTORY_SUMMARY" desc="Summary of problem displayed in dialog when we can't create a directory for this user."> Chromium cannot read and write to its data directory:\n\n<ph name="USER_DATA_DIRECTORY">$1<ex>C:\Documents and Settings\devint\Local Settings\Application Data\Google\Chrome</ex></ph> </message> diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index ca6f843..ad453c9 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -8306,6 +8306,9 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_OPTIONS_ADVANCED_SECTION_TITLE_CLOUD_PRINT"> <ph name="CLOUD_PRINT_NAME">Google Cloud Print</ph> </message> + <message name="IDS_OPTIONS_ADVANCED_SECTION_TITLE_BACKGROUND"> + Background Apps + </message> <!-- Multiple download warning--> <message name="IDS_MULTI_DOWNLOAD_WARNING" desc="Warning invoked if multiple downloads are attempted without user interaction."> diff --git a/chrome/app/google_chrome_strings.grd b/chrome/app/google_chrome_strings.grd index 343a5b21d..4870fe8 100644 --- a/chrome/app/google_chrome_strings.grd +++ b/chrome/app/google_chrome_strings.grd @@ -342,6 +342,15 @@ Chrome supports. --> Please sign out of Chrome OS and sign in again for this change to take effect. </message> </if> + <message name="IDS_STATUS_TRAY_KEEP_CHROME_RUNNING_IN_BACKGROUND" desc="The checkbox in the status tray context menu that controls whether chrome keeps running in the background after the last window is closed"> + Let Google Chrome Run In The Background + </message> + <message name="IDS_OPTIONS_BACKGROUND_ENABLE_BACKGROUND_MODE" desc="The label of the check-box that enables background mode"> + Continue running background apps when Google Chrome is closed + </message> + <message name="IDS_CONFIRM_EXIT_BACKGROUND_MODE_BODY" desc="Confirmation displayed when disabling background mode via the status tray context menu when there are no windows open"> + Are you sure you want to quit Google Chrome? (This setting can be toggled in <ph name="OPTIONS_MENU_LABEL">$1<ex>Options</ex></ph> - Under the Hood) + </message> <message name="IDS_CANT_WRITE_USER_DIRECTORY_SUMMARY" desc="Summary of problem displayed in dialog when we can't create a directory for this user."> Google Chrome cannot read and write to its data directory:\n\n<ph name="USER_DATA_DIRECTORY">$1<ex>C:\Documents and Settings\devint\Local Settings\Application Data\Google\Chrome</ex></ph> </message> diff --git a/chrome/browser/background_mode_manager.cc b/chrome/browser/background_mode_manager.cc index c69d57f..68e6f6f 100644 --- a/chrome/browser/background_mode_manager.cc +++ b/chrome/browser/background_mode_manager.cc @@ -11,7 +11,9 @@ #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/background_application_list_model.h" #include "chrome/browser/background_mode_manager.h" +#include "chrome/browser/browser_process.h" #include "chrome/browser/extensions/extension_service.h" +#include "chrome/browser/platform_util.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/status_icons/status_icon.h" #include "chrome/browser/status_icons/status_tray.h" @@ -48,11 +50,17 @@ BackgroundModeManager::BackgroundModeManager(Profile* profile, keep_alive_for_startup_(false), status_tray_(NULL), status_icon_(NULL) { - // If background mode is disabled, just exit - don't listen for any + // If background mode is currently disabled, just exit - don't listen for any // notifications. - if (!IsBackgroundModeEnabled(command_line)) + if (IsBackgroundModePermanentlyDisabled(command_line)) return; + // Listen for the background mode preference changing. + if (g_browser_process->local_state()) { // Skip for unit tests + pref_registrar_.Init(g_browser_process->local_state()); + pref_registrar_.Add(prefs::kBackgroundModeEnabled, this); + } + // Keep the browser alive until extensions are done loading - this is needed // by the --no-startup-window flag. We want to stay alive until we load // extensions, at which point we should either run in background mode (if @@ -104,6 +112,14 @@ void BackgroundModeManager::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { switch (type.value) { + case NotificationType::PREF_CHANGED: + DCHECK(*Details<std::string>(details).ptr() == + prefs::kBackgroundModeEnabled); + if (IsBackgroundModePrefEnabled()) + EnableBackgroundMode(); + else + DisableBackgroundMode(); + break; case NotificationType::EXTENSIONS_READY: // Extensions are loaded, so we don't need to manually keep the browser // process alive any more when running in no-startup-window mode. @@ -182,8 +198,9 @@ void BackgroundModeManager::OnBackgroundAppLoaded() { } void BackgroundModeManager::StartBackgroundMode() { - // Don't bother putting ourselves in background mode if we're already there. - if (in_background_mode_) + // Don't bother putting ourselves in background mode if we're already there + // or if background mode is disabled. + if (in_background_mode_ || !IsBackgroundModePrefEnabled()) return; // Mark ourselves as running in background mode. @@ -215,8 +232,30 @@ void BackgroundModeManager::EndBackgroundMode() { RemoveStatusTrayIcon(); } +void BackgroundModeManager::EnableBackgroundMode() { + DCHECK(IsBackgroundModePrefEnabled()); + // If background mode should be enabled, but isn't, turn it on. + if (background_app_count_ > 0 && !in_background_mode_) { + StartBackgroundMode(); + EnableLaunchOnStartup(true); + } +} + +void BackgroundModeManager::DisableBackgroundMode() { + DCHECK(!IsBackgroundModePrefEnabled()); + // If background mode is currently enabled, turn it off. + if (in_background_mode_) { + EndBackgroundMode(); + EnableLaunchOnStartup(false); + } +} + void BackgroundModeManager::OnBackgroundAppInstalled( const Extension* extension) { + // Background mode is disabled - don't do anything. + if (!IsBackgroundModePrefEnabled()) + return; + // We're installing a background app. If this is the first background app // being installed, make sure we are set to launch on startup. if (background_app_count_ == 0) @@ -294,13 +333,17 @@ void BackgroundModeManager::UpdateStatusTrayIconContextMenu() { } if (applications_.size() > 0) menu->AddSeparator(); + menu->AddCheckItemWithStringId( + IDC_STATUS_TRAY_KEEP_CHROME_RUNNING_IN_BACKGROUND, + IDS_STATUS_TRAY_KEEP_CHROME_RUNNING_IN_BACKGROUND); menu->AddItemWithStringId(IDC_EXIT, IDS_EXIT); context_menu_ = menu; status_icon_->SetContextMenu(menu); } bool BackgroundModeManager::IsCommandIdChecked(int command_id) const { - return false; + DCHECK(command_id == IDC_STATUS_TRAY_KEEP_CHROME_RUNNING_IN_BACKGROUND); + return true; } bool BackgroundModeManager::IsCommandIdEnabled(int command_id) const { @@ -348,6 +391,31 @@ void BackgroundModeManager::ExecuteCommand(int item) { case IDC_TASK_MANAGER: GetBrowserWindow()->OpenTaskManager(true); break; + case IDC_STATUS_TRAY_KEEP_CHROME_RUNNING_IN_BACKGROUND: { + // Background mode must already be enabled (as otherwise this menu would + // not be visible). + DCHECK(IsBackgroundModePrefEnabled()); + DCHECK(BrowserList::WillKeepAlive()); + if (BrowserList::size() == 0) { + // There are no windows open - unchecking this will exit Chrome. Warn + // the user. + if (!platform_util::SimpleYesNoBox( + NULL, + l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), + l10n_util::GetStringFUTF16( + IDS_CONFIRM_EXIT_BACKGROUND_MODE_BODY, + GetPreferencesMenuLabel()))) { + return; + } + } + + // Set the background mode pref to "disabled" - the resulting notification + // will result in a call to DisableBackgroundMode(). + PrefService* service = g_browser_process->local_state(); + DCHECK(service); + service->SetBoolean(prefs::kBackgroundModeEnabled, false); + break; + } default: ExecuteApplication(item); break; @@ -364,23 +432,31 @@ Browser* BackgroundModeManager::GetBrowserWindow() { } // static -bool BackgroundModeManager::IsBackgroundModeEnabled( +bool BackgroundModeManager::IsBackgroundModePermanentlyDisabled( const CommandLine* command_line) { // Background mode is disabled if the appropriate flag is passed, or if - // extensions are disabled. It's always disabled on chromeos since chrome - // is always running on that platform, making it superfluous. + // extensions are disabled, or if the associated preference is unset. It's + // always disabled on chromeos since chrome is always running on that + // platform, making it superfluous. #if defined(OS_CHROMEOS) - return false; + return true; #else - bool background_mode_enabled = - !command_line->HasSwitch(switches::kDisableBackgroundMode) && - !command_line->HasSwitch(switches::kDisableExtensions); - return background_mode_enabled; + bool background_mode_disabled = + command_line->HasSwitch(switches::kDisableBackgroundMode) || + command_line->HasSwitch(switches::kDisableExtensions); + return background_mode_disabled; #endif } +bool BackgroundModeManager::IsBackgroundModePrefEnabled() { + PrefService* service = g_browser_process->local_state(); + DCHECK(service); + return service->GetBoolean(prefs::kBackgroundModeEnabled); +} + // static void BackgroundModeManager::RegisterPrefs(PrefService* prefs) { prefs->RegisterBooleanPref(prefs::kUserCreatedLoginItem, false); + prefs->RegisterBooleanPref(prefs::kBackgroundModeEnabled, true); } diff --git a/chrome/browser/background_mode_manager.h b/chrome/browser/background_mode_manager.h index 236637f..4ef8d81 100644 --- a/chrome/browser/background_mode_manager.h +++ b/chrome/browser/background_mode_manager.h @@ -46,7 +46,6 @@ class BackgroundModeManager BackgroundModeManager(Profile* profile, CommandLine* command_line); virtual ~BackgroundModeManager(); - static bool IsBackgroundModeEnabled(const CommandLine* command_line); static void RegisterPrefs(PrefService* prefs); private: @@ -57,11 +56,9 @@ class BackgroundModeManager FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, BackgroundAppInstallUninstall); FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, - BackgroundPrefDisabled); + BackgroundAppInstallUninstallWhileDisabled); FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, - BackgroundPrefDynamicDisable); - FRIEND_TEST_ALL_PREFIXES(BackgroundModeManagerTest, - BackgroundPrefDynamicEnable); + EnableAfterBackgroundAppInstall); // NotificationObserver implementation. virtual void Observe(NotificationType type, @@ -146,7 +143,24 @@ class BackgroundModeManager // window. Browser* GetBrowserWindow(); + // Returns true if the "Let chrome run in the background" pref is checked. + // (virtual to allow overriding in tests). + virtual bool IsBackgroundModePrefEnabled(); + + // Turns off background mode if it's currently enabled. + void DisableBackgroundMode(); + + // Turns on background mode if it's currently disabled. + void EnableBackgroundMode(); + + // Returns true if background mode is permanently disabled for this chrome + // session. + static bool IsBackgroundModePermanentlyDisabled( + const CommandLine* command_line); + + // Registrars for managing our change observers. NotificationRegistrar registrar_; + PrefChangeRegistrar pref_registrar_; // The parent profile for this object. Profile* profile_; diff --git a/chrome/browser/background_mode_manager_unittest.cc b/chrome/browser/background_mode_manager_unittest.cc index abfbf90..dc19e2a 100644 --- a/chrome/browser/background_mode_manager_unittest.cc +++ b/chrome/browser/background_mode_manager_unittest.cc @@ -13,7 +13,9 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +using testing::AtLeast; using testing::InSequence; +using testing::Return; class BackgroundModeManagerTest : public TestingBrowserProcessTest { public: @@ -28,11 +30,15 @@ class BackgroundModeManagerTest : public TestingBrowserProcessTest { class TestBackgroundModeManager : public BackgroundModeManager { public: TestBackgroundModeManager(Profile* profile, CommandLine* cl) - : BackgroundModeManager(profile, cl) { - } + : BackgroundModeManager(profile, cl), + enabled_(true) {} MOCK_METHOD1(EnableLaunchOnStartup, void(bool)); MOCK_METHOD0(CreateStatusTrayIcon, void()); MOCK_METHOD0(RemoveStatusTrayIcon, void()); + virtual bool IsBackgroundModePrefEnabled() { return enabled_; } + void SetEnabled(bool enabled) { enabled_ = enabled; } + private: + bool enabled_; }; TEST_F(BackgroundModeManagerTest, BackgroundAppLoadUnload) { @@ -65,3 +71,57 @@ TEST_F(BackgroundModeManagerTest, BackgroundAppInstallUninstall) { manager.OnBackgroundAppUnloaded(); manager.OnBackgroundAppUninstalled(); } + +// App installs while disabled should do nothing. +TEST_F(BackgroundModeManagerTest, BackgroundAppInstallUninstallWhileDisabled) { + InSequence s; + TestingProfile profile; + TestBackgroundModeManager manager(&profile, command_line_.get()); + // Turn off background mode. + manager.SetEnabled(false); + manager.DisableBackgroundMode(); + + // Status tray icons will not be created, launch on startup status will be set + // to "do not launch on startup". + EXPECT_CALL(manager, EnableLaunchOnStartup(false)); + manager.OnBackgroundAppInstalled(NULL); + manager.OnBackgroundAppLoaded(); + manager.OnBackgroundAppUnloaded(); + manager.OnBackgroundAppUninstalled(); + + // Re-enable background mode. + manager.SetEnabled(true); + manager.EnableBackgroundMode(); +} + + +// App installs while disabled should do nothing. +TEST_F(BackgroundModeManagerTest, EnableAfterBackgroundAppInstall) { + InSequence s; + TestingProfile profile; + TestBackgroundModeManager manager(&profile, command_line_.get()); + EXPECT_CALL(manager, EnableLaunchOnStartup(true)); + EXPECT_CALL(manager, CreateStatusTrayIcon()); + EXPECT_CALL(manager, RemoveStatusTrayIcon()); + EXPECT_CALL(manager, EnableLaunchOnStartup(false)); + EXPECT_CALL(manager, CreateStatusTrayIcon()); + EXPECT_CALL(manager, EnableLaunchOnStartup(true)); + EXPECT_CALL(manager, RemoveStatusTrayIcon()); + EXPECT_CALL(manager, EnableLaunchOnStartup(false)); + + // Install app, should show status tray icon. + manager.OnBackgroundAppInstalled(NULL); + manager.OnBackgroundAppLoaded(); + + // Turn off background mode - should hide status tray icon. + manager.SetEnabled(false); + manager.DisableBackgroundMode(); + + // Turn back on background mode - should show status tray icon. + manager.SetEnabled(true); + manager.EnableBackgroundMode(); + + // Uninstall app, should hide status tray icon again. + manager.OnBackgroundAppUnloaded(); + manager.OnBackgroundAppUninstalled(); +} diff --git a/chrome/browser/resources/options/advanced_options.html b/chrome/browser/resources/options/advanced_options.html index 184b66a..9fc1e50 100644 --- a/chrome/browser/resources/options/advanced_options.html +++ b/chrome/browser/resources/options/advanced_options.html @@ -210,4 +210,15 @@ </div> </section> </if> +<if expr="os != 'darwin' and not pp_ifdef('chromeos')"> + <section id="background-section"> + <h3 i18n-content="advancedSectionTitleBackground"></h3> + <div class="checkbox"> + <label> + <input id="backgroundModeCheckbox" type="checkbox"> + <span i18n-content="backgroundModeCheckbox"></span> + </label> + </div> + </section> +</if> </div> diff --git a/chrome/browser/resources/options/advanced_options.js b/chrome/browser/resources/options/advanced_options.js index fa845a8..777f4f3 100644 --- a/chrome/browser/resources/options/advanced_options.js +++ b/chrome/browser/resources/options/advanced_options.js @@ -113,6 +113,12 @@ var OptionsPage = options.OptionsPage; chrome.send('useTLS1CheckboxAction', [String($('sslUseTLS1').checked)]); }; + if ($('backgroundModeCheckbox')) { + $('backgroundModeCheckbox').onclick = function(event) { + chrome.send('backgroundModeAction', + [String($('backgroundModeCheckbox').checked)]); + }; + } // 'cloudPrintProxyEnabled' is true for Chrome branded builds on // certain platforms, or could be enabled by a lab. @@ -236,6 +242,11 @@ var OptionsPage = options.OptionsPage; $('sslUseTLS1').disabled = disabled; }; + // Set the checked state for the backgroundModeCheckbox element. + AdvancedOptions.SetBackgroundModeCheckboxState = function(checked) { + $('backgroundModeCheckbox').checked = checked; + }; + // Set the Cloud Print proxy UI to enabled, disabled, or processing. AdvancedOptions.SetupCloudPrintProxySection = function( disabled, label, allowed) { diff --git a/chrome/browser/ui/webui/options/advanced_options_handler.cc b/chrome/browser/ui/webui/options/advanced_options_handler.cc index 2abb4d2..2f7f0ea 100644 --- a/chrome/browser/ui/webui/options/advanced_options_handler.cc +++ b/chrome/browser/ui/webui/options/advanced_options_handler.cc @@ -162,6 +162,12 @@ void AdvancedOptionsHandler::GetLocalizedValues( { "cloudPrintProxyEnablingButton", IDS_OPTIONS_CLOUD_PRINT_PROXY_ENABLING_BUTTON }, #endif +#if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) + { "advancedSectionTitleBackground", + IDS_OPTIONS_ADVANCED_SECTION_TITLE_BACKGROUND }, + { "backgroundModeCheckbox", + IDS_OPTIONS_BACKGROUND_ENABLE_BACKGROUND_MODE }, +#endif }; RegisterStrings(localized_strings, resources, arraysize(resources)); @@ -191,6 +197,9 @@ void AdvancedOptionsHandler::Initialize() { RemoveCloudPrintProxySection(); } #endif +#if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) + SetupBackgroundModeSettings(); +#endif banner_handler_.reset( new OptionsManagedBannerHandler(web_ui_, @@ -220,6 +229,12 @@ WebUIMessageHandler* AdvancedOptionsHandler::Attach(WebUI* web_ui) { tls1_enabled_.Init(prefs::kTLS1Enabled, g_browser_process->local_state(), this); +#if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) + background_mode_enabled_.Init(prefs::kBackgroundModeEnabled, + g_browser_process->local_state(), + this); +#endif + default_download_location_.Init(prefs::kDownloadDefaultDirectory, prefs, this); ask_for_save_location_.Init(prefs::kPromptForDownload, prefs, this); @@ -283,6 +298,11 @@ void AdvancedOptionsHandler::RegisterMessages() { web_ui_->RegisterMessageCallback("useTLS1CheckboxAction", NewCallback(this, &AdvancedOptionsHandler::HandleUseTLS1Checkbox)); +#if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) + web_ui_->RegisterMessageCallback("backgroundModeAction", + NewCallback(this, + &AdvancedOptionsHandler::HandleBackgroundModeCheckbox)); +#endif } void AdvancedOptionsHandler::Observe(NotificationType type, @@ -307,6 +327,10 @@ void AdvancedOptionsHandler::Observe(NotificationType type, #endif } else if (*pref_name == prefs::kWebKitDefaultFontSize) { SetupFontSizeLabel(); +#if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) + } else if (*pref_name == prefs::kBackgroundModeEnabled) { + SetupBackgroundModeSettings(); +#endif } } } @@ -404,6 +428,24 @@ void AdvancedOptionsHandler::HandleUseTLS1Checkbox(const ListValue* args) { tls1_enabled_.SetValue(enabled); } +#if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) +void AdvancedOptionsHandler::HandleBackgroundModeCheckbox( + const ListValue* args) { + std::string checked_str = UTF16ToUTF8(ExtractStringValue(args)); + bool enabled = checked_str == "true"; + std::string metric = enabled ? "Options_BackgroundMode_Enable" : + "Options_BackgroundMode_Disable"; + UserMetricsRecordAction(UserMetricsAction(metric.c_str())); + background_mode_enabled_.SetValue(enabled); +} + +void AdvancedOptionsHandler::SetupBackgroundModeSettings() { + FundamentalValue checked(background_mode_enabled_.GetValue()); + web_ui_->CallJavascriptFunction( + "options.AdvancedOptions.SetBackgroundModeCheckboxState", checked); +} +#endif + #if !defined(OS_CHROMEOS) void AdvancedOptionsHandler::ShowNetworkProxySettings(const ListValue* args) { UserMetricsRecordAction(UserMetricsAction("Options_ShowProxySettings")); diff --git a/chrome/browser/ui/webui/options/advanced_options_handler.h b/chrome/browser/ui/webui/options/advanced_options_handler.h index 5b9c2f3..6b59944 100644 --- a/chrome/browser/ui/webui/options/advanced_options_handler.h +++ b/chrome/browser/ui/webui/options/advanced_options_handler.h @@ -116,6 +116,15 @@ class AdvancedOptionsHandler #endif +#if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) + // Sets up the checked state for the "Continue running background apps..." + // checkbox. + void SetupBackgroundModeSettings(); + + // Callback for the "Continue running background apps..." checkbox. + void HandleBackgroundModeCheckbox(const ListValue* args); +#endif + // Setup the checked state for the metrics reporting checkbox. void SetupMetricsReportingCheckbox(); @@ -154,6 +163,10 @@ class AdvancedOptionsHandler BooleanPrefMember ssl3_enabled_; BooleanPrefMember tls1_enabled_; +#if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) + BooleanPrefMember background_mode_enabled_; +#endif + FilePathPrefMember default_download_location_; BooleanPrefMember ask_for_save_location_; BooleanPrefMember allow_file_selection_dialogs_; diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index 603ccf6..9200f85 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -1350,6 +1350,9 @@ const char kManagedPopupsBlockedForUrls[] = // uninstalling background apps. const char kUserCreatedLoginItem[] = "background_mode.user_created_login_item"; +// Set to true if background mode is enabled on this browser. +const char kBackgroundModeEnabled[] = "background_mode.enabled"; + // List of protocol handlers. const char kRegisteredProtocolHandlers[] = "custom_handlers.registered_protocol_handlers"; diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index b2f4841..8cbabd0 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -500,6 +500,7 @@ extern const char kIgnoredProtocolHandlers[]; extern const char kCustomHandlersEnabled[]; extern const char kUserCreatedLoginItem[]; +extern const char kBackgroundModeEnabled[]; } // namespace prefs |