summaryrefslogtreecommitdiffstats
path: root/chrome/browser/background_mode_manager.cc
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-28 21:52:10 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-28 21:52:10 +0000
commit54cdca4fe4814a6fdd4e7deb6ca6681514f50505 (patch)
treea91453d6b2b328362fb8521a1585382c82cedd8f /chrome/browser/background_mode_manager.cc
parent975496c3acddae77c7d8bf0f936242efe6ec9e0a (diff)
downloadchromium_src-54cdca4fe4814a6fdd4e7deb6ca6681514f50505.zip
chromium_src-54cdca4fe4814a6fdd4e7deb6ca6681514f50505.tar.gz
chromium_src-54cdca4fe4814a6fdd4e7deb6ca6681514f50505.tar.bz2
Changed EXTENSION_UNINSTALLED notification to happen after uninstallation.
The important part is that it comes after the EXTENSION_UNLOADED notification is sent. This makes it easier on the listeners, as they can assume that extension notifications other than EXTENSION_UNINSTALLED are sent for currently-installed extensions. BUG=54415 TEST=BackgroundModeManagerTest Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=60834 Review URL: http://codereview.chromium.org/3461025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60848 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/background_mode_manager.cc')
-rw-r--r--chrome/browser/background_mode_manager.cc35
1 files changed, 23 insertions, 12 deletions
diff --git a/chrome/browser/background_mode_manager.cc b/chrome/browser/background_mode_manager.cc
index 01a9a36..b3bf83a 100644
--- a/chrome/browser/background_mode_manager.cc
+++ b/chrome/browser/background_mode_manager.cc
@@ -191,6 +191,20 @@ void BackgroundModeManager::SetLaunchOnStartupResetAllowed(bool allowed) {
allowed);
}
+namespace {
+
+bool HasBackgroundAppPermission(
+ const std::set<std::string>& api_permissions) {
+ return Extension::HasApiPermission(
+ api_permissions, Extension::kBackgroundPermission);
+}
+
+bool IsBackgroundApp(const Extension& extension) {
+ return HasBackgroundAppPermission(extension.api_permissions());
+}
+
+} // namespace
+
void BackgroundModeManager::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
@@ -205,19 +219,21 @@ void BackgroundModeManager::Observe(NotificationType type,
#endif
break;
case NotificationType::EXTENSION_LOADED:
- if (IsBackgroundApp(Details<Extension>(details).ptr()))
+ if (IsBackgroundApp(*Details<Extension>(details).ptr()))
OnBackgroundAppLoaded();
break;
case NotificationType::EXTENSION_UNLOADED:
- if (IsBackgroundApp(Details<Extension>(details).ptr()))
+ if (IsBackgroundApp(*Details<Extension>(details).ptr()))
OnBackgroundAppUnloaded();
break;
case NotificationType::EXTENSION_INSTALLED:
- if (IsBackgroundApp(Details<Extension>(details).ptr()))
+ if (IsBackgroundApp(*Details<Extension>(details).ptr()))
OnBackgroundAppInstalled();
break;
case NotificationType::EXTENSION_UNINSTALLED:
- if (IsBackgroundApp(Details<Extension>(details).ptr()))
+ if (HasBackgroundAppPermission(
+ Details<UninstalledExtensionInfo>(details).ptr()->
+ extension_api_permissions))
OnBackgroundAppUninstalled();
break;
case NotificationType::APP_TERMINATING:
@@ -239,11 +255,6 @@ void BackgroundModeManager::Observe(NotificationType type,
}
}
-bool BackgroundModeManager::IsBackgroundApp(Extension* extension) {
- return extension->HasApiPermission(Extension::kBackgroundPermission);
-}
-
-
void BackgroundModeManager::OnBackgroundModePrefChanged() {
// Background mode has been enabled/disabled in preferences, so update our
// state accordingly.
@@ -311,9 +322,9 @@ void BackgroundModeManager::OnBackgroundAppInstalled() {
}
void BackgroundModeManager::OnBackgroundAppUninstalled() {
- // When uninstalling a background app, disable launch on startup if it's the
- // last one.
- if (IsBackgroundModeEnabled() && background_app_count_ == 1)
+ // When uninstalling a background app, disable launch on startup if
+ // we have no more background apps.
+ if (IsBackgroundModeEnabled() && background_app_count_ == 0)
EnableLaunchOnStartup(false);
}