Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(914)

Unified Diff: chrome/browser/background_mode_manager.cc

Issue 6306010: BackgroundModeManager will no longer listen to EXTENSION_(UN)INSTALLED. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/background_mode_manager.cc
diff --git a/chrome/browser/background_mode_manager.cc b/chrome/browser/background_mode_manager.cc
index 1ba32700abb04803ae6fd8df56fdf2022f745567..1b806ba1031135826a44fd6e22f4e1a99775bff3 100644
--- a/chrome/browser/background_mode_manager.cc
+++ b/chrome/browser/background_mode_manager.cc
@@ -68,15 +68,9 @@ BackgroundModeManager::BackgroundModeManager(Profile* profile,
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKeepAliveForTest))
OnBackgroundAppLoaded();
- // When an extension is installed, make sure launch on startup is properly
- // set if appropriate. Likewise, turn off launch on startup when the last
- // background app is uninstalled.
- registrar_.Add(this, NotificationType::EXTENSION_INSTALLED,
- Source<Profile>(profile));
- registrar_.Add(this, NotificationType::EXTENSION_UNINSTALLED,
- Source<Profile>(profile));
// Listen for when extensions are loaded/unloaded so we can track the
- // number of background apps.
+ // number of background apps and modify our keep-alive and launch-on-startup
+ // state appropriately.
registrar_.Add(this, NotificationType::EXTENSION_LOADED,
Source<Profile>(profile));
registrar_.Add(this, NotificationType::EXTENSION_UNLOADED,
@@ -117,7 +111,10 @@ void BackgroundModeManager::Observe(NotificationType type,
// 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.
+ // registered extensions. This means that if a background app is removed
+ // or added while Chrome is not running, we could leave Chrome in the
+ // wrong state, but this is better than constantly forcing Chrome to
+ // launch on startup even after the user removes the LoginItem manually.
#if !defined(OS_MACOSX)
EnableLaunchOnStartup(background_app_count_ > 0);
#endif
@@ -125,6 +122,10 @@ void BackgroundModeManager::Observe(NotificationType type,
case NotificationType::EXTENSION_LOADED:
if (BackgroundApplicationListModel::IsBackgroundApp(
*Details<Extension>(details).ptr())) {
+ // Extensions loaded after the ExtensionsService is ready should be
+ // treated as new installs.
+ if (profile_->GetExtensionService()->is_ready())
+ OnBackgroundAppInstalled();
OnBackgroundAppLoaded();
}
break;
@@ -132,19 +133,6 @@ void BackgroundModeManager::Observe(NotificationType type,
if (BackgroundApplicationListModel::IsBackgroundApp(
*Details<UnloadedExtensionInfo>(details)->extension)) {
OnBackgroundAppUnloaded();
- }
- break;
- case NotificationType::EXTENSION_INSTALLED:
- if (BackgroundApplicationListModel::IsBackgroundApp(
- *Details<Extension>(details).ptr())) {
- OnBackgroundAppInstalled();
- }
- break;
- case NotificationType::EXTENSION_UNINSTALLED:
- if (Extension::HasApiPermission(
- Details<UninstalledExtensionInfo>(details).ptr()->
- extension_api_permissions,
- Extension::kBackgroundPermission)) {
OnBackgroundAppUninstalled();
}
break;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698