diff options
author | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-30 18:41:06 +0000 |
---|---|---|
committer | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-30 18:41:06 +0000 |
commit | 21103034ad3f39ca1b24a254e97ff91776ea9a9e (patch) | |
tree | 8bf3b7e1d12fdf3aac534339b0ba27342fb4610d /chrome/browser/background_mode_manager.cc | |
parent | 5e94010a11a6c2f0f3c93063c9a078bfbdbc5468 (diff) | |
download | chromium_src-21103034ad3f39ca1b24a254e97ff91776ea9a9e.zip chromium_src-21103034ad3f39ca1b24a254e97ff91776ea9a9e.tar.gz chromium_src-21103034ad3f39ca1b24a254e97ff91776ea9a9e.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
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=60848
Review URL: http://codereview.chromium.org/3461025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61089 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/background_mode_manager.cc')
-rw-r--r-- | chrome/browser/background_mode_manager.cc | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/chrome/browser/background_mode_manager.cc b/chrome/browser/background_mode_manager.cc index ba952cb..8946e3c 100644 --- a/chrome/browser/background_mode_manager.cc +++ b/chrome/browser/background_mode_manager.cc @@ -188,6 +188,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) { @@ -202,19 +216,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: @@ -236,11 +252,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. @@ -308,9 +319,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); } |