| Index: chrome/browser/background/background_mode_manager.cc
|
| diff --git a/chrome/browser/background/background_mode_manager.cc b/chrome/browser/background/background_mode_manager.cc
|
| index c44362c79f7c99dba7c42d0b80cebd49336c39ca..33eecf1f77d12ee429efce3159281f9b96f56139 100644
|
| --- a/chrome/browser/background/background_mode_manager.cc
|
| +++ b/chrome/browser/background/background_mode_manager.cc
|
| @@ -196,13 +196,15 @@ void BackgroundModeManager::RegisterProfile(Profile* profile) {
|
| profile, this));
|
| background_mode_data_[profile] = bmd;
|
|
|
| - // Listen for when extensions are loaded/unloaded so we can track the
|
| - // number of background apps and modify our keep-alive and launch-on-startup
|
| - // state appropriately.
|
| + // Listen for when extensions are loaded/unloaded or add/remove the
|
| + // background permission so we can track the number of background apps and
|
| + // modify our keep-alive and launch-on-startup state appropriately.
|
| registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
|
| Source<Profile>(profile));
|
| registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
|
| Source<Profile>(profile));
|
| + registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PERMISSIONS_UPDATED,
|
| + Source<Profile>(profile));
|
|
|
| // Check for the presence of background apps after all extensions have been
|
| // loaded, to handle the case where an extension has been manually removed
|
| @@ -274,6 +276,22 @@ void BackgroundModeManager::Observe(int type,
|
| OnBackgroundAppUninstalled();
|
| }
|
| break;
|
| + case chrome::NOTIFICATION_EXTENSION_PERMISSIONS_UPDATED: {
|
| + UpdatedExtensionPermissionsInfo* info =
|
| + Details<UpdatedExtensionPermissionsInfo>(details).ptr();
|
| + if (!info->permissions->HasAPIPermission(
|
| + ExtensionAPIPermission::kBackground))
|
| + break;
|
| +
|
| + if (info->reason == UpdatedExtensionPermissionsInfo::ADDED) {
|
| + OnBackgroundAppInstalled(info->extension);
|
| + OnBackgroundAppLoaded();
|
| + } else {
|
| + OnBackgroundAppUnloaded();
|
| + OnBackgroundAppUninstalled();
|
| + }
|
| + }
|
| + break;
|
| case content::NOTIFICATION_APP_TERMINATING:
|
| // Make sure we aren't still keeping the app alive (only happens if we
|
| // don't receive an EXTENSIONS_READY notification for some reason).
|
|
|