diff options
author | jstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-27 14:36:49 +0000 |
---|---|---|
committer | jstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-27 14:36:49 +0000 |
commit | 38383b194bc471ebba4de124cbf391b00114923a (patch) | |
tree | f7a027d2ea9f88f28216a29d0b9a0368e03ae502 /chrome/browser/background | |
parent | 4d48dccadf757b39157537331a3becd13a5f7d9f (diff) | |
download | chromium_src-38383b194bc471ebba4de124cbf391b00114923a.zip chromium_src-38383b194bc471ebba4de124cbf391b00114923a.tar.gz chromium_src-38383b194bc471ebba4de124cbf391b00114923a.tar.bz2 |
Add an experimental permissions API for extensions.
The permissions API lets extensions specify optional permissions in their manifest that they can request at run-time. It currently supports API permissions through a white-list. Host permissions will come later.
BUG=48119, 70466, 84507
TEST=*Extension*
Review URL: http://codereview.chromium.org/7432006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94288 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/background')
-rw-r--r-- | chrome/browser/background/background_mode_manager.cc | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/chrome/browser/background/background_mode_manager.cc b/chrome/browser/background/background_mode_manager.cc index c44362c..33eecf1 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). |