diff options
author | dimich@chromium.org <dimich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-27 01:54:28 +0000 |
---|---|---|
committer | dimich@chromium.org <dimich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-27 01:54:28 +0000 |
commit | 1c704b71a123770b6091a01d9a54ac57a99ae290 (patch) | |
tree | 05c4bf67cbd39da2d2cb7891596a64cb6b5e7b9f /chrome | |
parent | 3dc423f963527b2788226359b34ab367f0788e44 (diff) | |
download | chromium_src-1c704b71a123770b6091a01d9a54ac57a99ae290.zip chromium_src-1c704b71a123770b6091a01d9a54ac57a99ae290.tar.gz chromium_src-1c704b71a123770b6091a01d9a54ac57a99ae290.tar.bz2 |
Revert 57614 - Re-land. Fixed previous build error.
It looks like it broke browser_tests. Will revert and investigate.
Implement OSX version for "Start on Login" for background-enabled extensions.
Review URL: http://codereview.chromium.org/3163029
TBR=dimich@chromium.org
Review URL: http://codereview.chromium.org/3226002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57625 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/background_mode_manager.cc | 51 | ||||
-rw-r--r-- | chrome/browser/background_mode_manager.h | 6 | ||||
-rw-r--r-- | chrome/browser/browser_main_mac.mm | 7 | ||||
-rw-r--r-- | chrome/common/pref_names.cc | 5 | ||||
-rw-r--r-- | chrome/common/pref_names.h | 1 |
5 files changed, 1 insertions, 69 deletions
diff --git a/chrome/browser/background_mode_manager.cc b/chrome/browser/background_mode_manager.cc index b619177..871e243 100644 --- a/chrome/browser/background_mode_manager.cc +++ b/chrome/browser/background_mode_manager.cc @@ -23,10 +23,6 @@ #include "grit/generated_resources.h" #include "grit/theme_resources.h" -#if defined(OS_MACOSX) -#include "base/mac_util.h" -#endif - #if defined(TOOLKIT_GTK) #include "chrome/browser/gtk/gtk_util.h" #endif @@ -86,27 +82,13 @@ bool BackgroundModeManager::IsBackgroundModeEnabled() { return profile_->GetPrefs()->GetBoolean(prefs::kBackgroundModeEnabled); } -bool BackgroundModeManager::IsLaunchOnStartupResetAllowed() { - return profile_->GetPrefs()->GetBoolean(prefs::kLaunchOnStartupResetAllowed); -} - -void BackgroundModeManager::SetLaunchOnStartupResetAllowed(bool allowed) { - profile_->GetPrefs()->SetBoolean(prefs::kLaunchOnStartupResetAllowed, - allowed); -} - void BackgroundModeManager::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { switch (type.value) { case NotificationType::EXTENSIONS_READY: - // On a Mac, we use 'login items' mechanism which has user-facing UI so we - // don't want to stomp on user choice every time we start and load - // registered extensions. -#if !defined(OS_MACOSX) EnableLaunchOnStartup(IsBackgroundModeEnabled() && background_app_count_ > 0); -#endif break; case NotificationType::EXTENSION_LOADED: if (IsBackgroundApp(Details<Extension>(details).ptr())) @@ -189,38 +171,8 @@ void BackgroundModeManager::OnBackgroundAppUninstalled() { } void BackgroundModeManager::EnableLaunchOnStartup(bool should_launch) { - // TODO(BUG43382): Add code for other platforms to enable/disable launch on + // TODO(atwilson): Add platform-specific code to enable/disable launch on // startup. - - // This functionality is only defined for default profile, currently. - if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUserDataDir)) - return; - -#if defined(OS_MACOSX) - if (should_launch) { - // Return if Chrome is already a Login Item (avoid overriding user choice). - if (mac_util::CheckLoginItemStatus(NULL)) - return; - - mac_util::AddToLoginItems(true); // Hide on startup. - - // Remember we set Login Item, not the user - so we can reset it later. - SetLaunchOnStartupResetAllowed(true); - } else { - // If we didn't set Login Item, don't mess with it. - if (!IsLaunchOnStartupResetAllowed()) - return; - SetLaunchOnStartupResetAllowed(false); - - // Check if Chrome is not a login Item, or is a Login Item but w/o 'hidden' - // flag - most likely user has modified the setting, don't override it. - bool is_hidden = false; - if (!mac_util::CheckLoginItemStatus(&is_hidden) || !is_hidden) - return; - - mac_util::RemoveFromLoginItems(); - } -#endif } void BackgroundModeManager::CreateStatusTrayIcon() { @@ -317,5 +269,4 @@ Browser* BackgroundModeManager::GetBrowserWindow() { // static void BackgroundModeManager::RegisterUserPrefs(PrefService* prefs) { prefs->RegisterBooleanPref(prefs::kBackgroundModeEnabled, true); - prefs->RegisterBooleanPref(prefs::kLaunchOnStartupResetAllowed, false); } diff --git a/chrome/browser/background_mode_manager.h b/chrome/browser/background_mode_manager.h index 38b010c..3a82399 100644 --- a/chrome/browser/background_mode_manager.h +++ b/chrome/browser/background_mode_manager.h @@ -82,12 +82,6 @@ class BackgroundModeManager // Returns true if the background mode preference is enabled bool IsBackgroundModeEnabled(); - // Returns true if chrome has set "launch on startup" property for itself - // earlier and is allowed to reset it later, reducing likelihood of - // overriding user choices. - bool IsLaunchOnStartupResetAllowed(); - void SetLaunchOnStartupResetAllowed(bool allowed); - // Called to make sure that our launch-on-startup mode is properly set. // (virtual so we can override for tests). virtual void EnableLaunchOnStartup(bool should_launch); diff --git a/chrome/browser/browser_main_mac.mm b/chrome/browser/browser_main_mac.mm index 3f4017d..5aa5999 100644 --- a/chrome/browser/browser_main_mac.mm +++ b/chrome/browser/browser_main_mac.mm @@ -68,13 +68,6 @@ class BrowserMainPartsMac : public BrowserMainPartsPosix { : BrowserMainPartsPosix(parameters) {} protected: - virtual void PreEarlyInitialization() { - if (mac_util::WasLaunchedAsHiddenLoginItem()) { - CommandLine* singleton_command_line = CommandLine::ForCurrentProcess(); - singleton_command_line->AppendSwitch(switches::kNoStartupWindow); - } - } - virtual void PreMainMessageLoopStart() { BrowserMainPartsPosix::PreMainMessageLoopStart(); diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index 72820ef..cf74af4 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -691,11 +691,6 @@ const char kMemoryCacheSize[] = "renderer.memory_cache.size"; // apps are installed. const char kBackgroundModeEnabled[] = "background_mode.enabled"; -// Boolean that records if chrome has set "launch on startup" property for -// itself earlier and is allowed to reset it later, reducing likelihood of -// overriding user choices. -const char kLaunchOnStartupResetAllowed[] = "launch_on_startup_reset_allowed"; - // String which specifies where to download files to by default. const char kDownloadDefaultDirectory[] = "download.default_directory"; diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index 714def0..232d0fd 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -251,7 +251,6 @@ extern const char kPreferencesWindowPlacement[]; extern const char kMemoryCacheSize[]; extern const char kBackgroundModeEnabled[]; -extern const char kLaunchOnStartupResetAllowed[]; extern const char kDownloadDefaultDirectory[]; extern const char kDownloadExtensionsToOpen[]; |