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

Unified Diff: chrome/browser/background/background_mode_manager.cc

Issue 7432006: Add an experimental permissions API for extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix clang Created 9 years, 5 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
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).
« no previous file with comments | « chrome/browser/automation/testing_automation_provider.cc ('k') | chrome/browser/extensions/convert_web_app_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698