summaryrefslogtreecommitdiffstats
path: root/chrome/browser/background
diff options
context:
space:
mode:
authorbartfab@chromium.org <bartfab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-19 17:10:07 +0000
committerbartfab@chromium.org <bartfab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-19 17:10:07 +0000
commitd6bbd29389124100f174e1e94601454a94ec923a (patch)
treeb6ce85d57c8a70e546a71adc336bcef9a9d9e351 /chrome/browser/background
parentdd50857397ddf9b7a99478eeb11260251d9dc66b (diff)
downloadchromium_src-d6bbd29389124100f174e1e94601454a94ec923a.zip
chromium_src-d6bbd29389124100f174e1e94601454a94ec923a.tar.gz
chromium_src-d6bbd29389124100f174e1e94601454a94ec923a.tar.bz2
Add policy to control "allow background apps"
This CL adds a policy to control the "allow background apps" pref. The pref can now be set manually as before, overridden by a command line flag as before or be enforced through policy. BUG=107456 TEST=manual with policy managed/unmanaged, background apps present/not present Review URL: http://codereview.chromium.org/9705103 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@127492 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/background')
-rw-r--r--chrome/browser/background/background_mode_manager.cc33
-rw-r--r--chrome/browser/background/background_mode_manager.h7
2 files changed, 8 insertions, 32 deletions
diff --git a/chrome/browser/background/background_mode_manager.cc b/chrome/browser/background/background_mode_manager.cc
index 141aa3c..a8c49d7 100644
--- a/chrome/browser/background/background_mode_manager.cc
+++ b/chrome/browser/background/background_mode_manager.cc
@@ -53,8 +53,8 @@ BackgroundModeManager::BackgroundModeData::~BackgroundModeData() {
// BackgroundModeManager::BackgroundModeData, ui::SimpleMenuModel overrides
bool BackgroundModeManager::BackgroundModeData::IsCommandIdChecked(
int command_id) const {
- DCHECK(command_id == IDC_STATUS_TRAY_KEEP_CHROME_RUNNING_IN_BACKGROUND);
- return true;
+ NOTREACHED() << "There are no checked items in the profile submenu.";
+ return false;
}
bool BackgroundModeManager::BackgroundModeData::IsCommandIdEnabled(
@@ -153,10 +153,6 @@ BackgroundModeManager::BackgroundModeManager(
// currently quitting.
CHECK(g_browser_process != NULL);
CHECK(!browser_shutdown::IsTryingToQuit());
- // If background mode is currently disabled, just exit - don't listen for any
- // notifications.
- if (IsBackgroundModePermanentlyDisabled(command_line))
- return;
// Add self as an observer for the profile info cache so we know when profiles
// are deleted and their names change.
@@ -460,6 +456,11 @@ bool BackgroundModeManager::IsCommandIdChecked(
bool BackgroundModeManager::IsCommandIdEnabled(
int command_id) const {
+ if (command_id == IDC_STATUS_TRAY_KEEP_CHROME_RUNNING_IN_BACKGROUND) {
+ PrefService* service = g_browser_process->local_state();
+ DCHECK(service);
+ return service->IsUserModifiablePreference(prefs::kBackgroundModeEnabled);
+ }
return command_id != IDC_MinimumLabelValue;
}
@@ -745,26 +746,6 @@ BackgroundModeManager::GetBackgroundModeIterator(
return profile_it;
}
-// static
-bool BackgroundModeManager::IsBackgroundModePermanentlyDisabled(
- const CommandLine* command_line) {
-
- // Background mode is disabled if the appropriate flag is passed, or if
- // 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)
- if (command_line->HasSwitch(switches::kKeepAliveForTest))
- return false;
- return true;
-#else
- bool background_mode_disabled =
- command_line->HasSwitch(switches::kDisableBackgroundMode) ||
- command_line->HasSwitch(switches::kDisableExtensions);
- return background_mode_disabled;
-#endif
-}
-
bool BackgroundModeManager::IsBackgroundModePrefEnabled() const {
PrefService* service = g_browser_process->local_state();
DCHECK(service);
diff --git a/chrome/browser/background/background_mode_manager.h b/chrome/browser/background/background_mode_manager.h
index 590898d..633c92b 100644
--- a/chrome/browser/background/background_mode_manager.h
+++ b/chrome/browser/background/background_mode_manager.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -56,11 +56,6 @@ class BackgroundModeManager
virtual void RegisterProfile(Profile* profile);
- // Returns true if background mode is permanently disabled for this Chrome
- // session.
- static bool IsBackgroundModePermanentlyDisabled(
- const CommandLine* command_line);
-
static void LaunchBackgroundApplication(Profile* profile,
const Extension* extension);