diff options
author | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-28 23:13:45 +0000 |
---|---|---|
committer | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-28 23:13:45 +0000 |
commit | cba0d55f1ad41f45da9c73081101e04e5cf581e3 (patch) | |
tree | 853b559b4564890358b5ef6269848590d0dbcd61 /chrome/browser/background_mode_manager.cc | |
parent | bc7c2de6a2f59d5d3b2a7d9ce0692bcf73ca089b (diff) | |
download | chromium_src-cba0d55f1ad41f45da9c73081101e04e5cf581e3.zip chromium_src-cba0d55f1ad41f45da9c73081101e04e5cf581e3.tar.gz chromium_src-cba0d55f1ad41f45da9c73081101e04e5cf581e3.tar.bz2 |
Revert 60848 - 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
TBR=akalin@chromium.org
Review URL: http://codereview.chromium.org/3528003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60868 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, 12 insertions, 23 deletions
diff --git a/chrome/browser/background_mode_manager.cc b/chrome/browser/background_mode_manager.cc index b3bf83a..01a9a36 100644 --- a/chrome/browser/background_mode_manager.cc +++ b/chrome/browser/background_mode_manager.cc @@ -191,20 +191,6 @@ 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) { @@ -219,21 +205,19 @@ 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 (HasBackgroundAppPermission( - Details<UninstalledExtensionInfo>(details).ptr()-> - extension_api_permissions)) + if (IsBackgroundApp(Details<Extension>(details).ptr())) OnBackgroundAppUninstalled(); break; case NotificationType::APP_TERMINATING: @@ -255,6 +239,11 @@ 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. @@ -322,9 +311,9 @@ void BackgroundModeManager::OnBackgroundAppInstalled() { } void BackgroundModeManager::OnBackgroundAppUninstalled() { - // When uninstalling a background app, disable launch on startup if - // we have no more background apps. - if (IsBackgroundModeEnabled() && background_app_count_ == 0) + // When uninstalling a background app, disable launch on startup if it's the + // last one. + if (IsBackgroundModeEnabled() && background_app_count_ == 1) EnableLaunchOnStartup(false); } |