diff options
author | rdevlin.cronin@chromium.org <rdevlin.cronin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-07 23:26:19 +0000 |
---|---|---|
committer | rdevlin.cronin@chromium.org <rdevlin.cronin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-07 23:26:19 +0000 |
commit | 23a85362dfcde394dd17d7158423dfde35c20ca4 (patch) | |
tree | e4b43c3d0027510e86443488b63cac3a2f0e7770 /chrome/browser/extensions/extension_util.cc | |
parent | 801c8663dacdcaccaf8b01efceb78989c56cba87 (diff) | |
download | chromium_src-23a85362dfcde394dd17d7158423dfde35c20ca4.zip chromium_src-23a85362dfcde394dd17d7158423dfde35c20ca4.tar.gz chromium_src-23a85362dfcde394dd17d7158423dfde35c20ca4.tar.bz2 |
Add a withheld permissions model to PermissionsData. Withheld permissions are the permissions which were requested by the extension, but not granted due to how dangerous/powerful they are. Currently, these withheld permissions are only used for all hosts, and only behind the scripts_require_action flag.
BUG=362353
Review URL: https://codereview.chromium.org/348313003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@281605 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_util.cc')
-rw-r--r-- | chrome/browser/extensions/extension_util.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extension_util.cc b/chrome/browser/extensions/extension_util.cc index 6b27885..6d86ca7 100644 --- a/chrome/browser/extensions/extension_util.cc +++ b/chrome/browser/extensions/extension_util.cc @@ -9,6 +9,7 @@ #include "base/values.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_sync_service.h" +#include "chrome/browser/extensions/permissions_updater.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" #include "chrome/common/chrome_switches.h" @@ -183,10 +184,24 @@ bool AllowedScriptingOnAllUrls(const std::string& extension_id, void SetAllowedScriptingOnAllUrls(const std::string& extension_id, content::BrowserContext* context, bool allowed) { + if (allowed == AllowedScriptingOnAllUrls(extension_id, context)) + return; // Nothing to do here. + ExtensionPrefs::Get(context)->UpdateExtensionPref( extension_id, kExtensionAllowedOnAllUrlsPrefName, allowed ? new base::FundamentalValue(true) : NULL); + + const Extension* extension = + ExtensionRegistry::Get(context)->enabled_extensions().GetByID( + extension_id); + if (extension) { + PermissionsUpdater updater(context); + if (allowed) + updater.GrantWithheldImpliedAllHosts(extension); + else + updater.WithholdImpliedAllHosts(extension); + } } bool IsAppLaunchable(const std::string& extension_id, |