diff options
author | gpdavis.chromium <gpdavis.chromium@gmail.com> | 2014-09-19 13:57:54 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-19 20:58:11 +0000 |
commit | 0fbac4d6271f2eaacd8d67800ba5dce7781578b4 (patch) | |
tree | d5e0daf658446f356ad8b72dd20b150fc30810a0 /chrome/browser/extensions/permissions_updater.cc | |
parent | a7738c9de62e061649896353c9d3ebe5176ece07 (diff) | |
download | chromium_src-0fbac4d6271f2eaacd8d67800ba5dce7781578b4.zip chromium_src-0fbac4d6271f2eaacd8d67800ba5dce7781578b4.tar.gz chromium_src-0fbac4d6271f2eaacd8d67800ba5dce7781578b4.tar.bz2 |
Update extension install prompt to reflect withheld permissions.
Screenshots:
Ubuntu:
http://i.imgur.com/FuzZfcr.jpg
OSX:
http://i.imgur.com/ylHBVCx.png
BUG=407453
Review URL: https://codereview.chromium.org/501273002
Cr-Commit-Position: refs/heads/master@{#295773}
Diffstat (limited to 'chrome/browser/extensions/permissions_updater.cc')
-rw-r--r-- | chrome/browser/extensions/permissions_updater.cc | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/chrome/browser/extensions/permissions_updater.cc b/chrome/browser/extensions/permissions_updater.cc index 385d5e9..6a68371 100644 --- a/chrome/browser/extensions/permissions_updater.cc +++ b/chrome/browser/extensions/permissions_updater.cc @@ -110,7 +110,12 @@ void SegregateUrlPermissions(const URLPatternSet& url_patterns, } // namespace PermissionsUpdater::PermissionsUpdater(content::BrowserContext* browser_context) - : browser_context_(browser_context) { + : browser_context_(browser_context), init_flag_(INIT_FLAG_NONE) { +} + +PermissionsUpdater::PermissionsUpdater(content::BrowserContext* browser_context, + InitFlag init_flag) + : browser_context_(browser_context), init_flag_(init_flag) { } PermissionsUpdater::~PermissionsUpdater() {} @@ -164,17 +169,28 @@ void PermissionsUpdater::GrantActivePermissions(const Extension* extension) { } void PermissionsUpdater::InitializePermissions(const Extension* extension) { - scoped_refptr<const PermissionSet> active_permissions = - ExtensionPrefs::Get(browser_context_) - ->GetActivePermissions(extension->id()); - scoped_refptr<const PermissionSet> bounded_active = - GetBoundedActivePermissions(extension, active_permissions); - - // Withhold permissions only if the switch applies to this extension and the - // extension doesn't have the preference to allow scripting on all urls. + scoped_refptr<const PermissionSet> active_permissions(NULL); + scoped_refptr<const PermissionSet> bounded_active(NULL); + // If |extension| is a transient dummy extension, we do not want to look for + // it in preferences. + if (init_flag_ & INIT_FLAG_TRANSIENT) { + bounded_active = active_permissions = + extension->permissions_data()->active_permissions(); + } else { + active_permissions = ExtensionPrefs::Get(browser_context_) + ->GetActivePermissions(extension->id()); + bounded_active = GetBoundedActivePermissions(extension, active_permissions); + } + + // Withhold permissions if the switch applies to this extension. + // Non-transient extensions also must not have the preference to allow + // scripting on all urls. bool should_withhold_permissions = - util::ScriptsMayRequireActionForExtension(extension) && - !util::AllowedScriptingOnAllUrls(extension->id(), browser_context_); + util::ScriptsMayRequireActionForExtension(extension); + if ((init_flag_ & INIT_FLAG_TRANSIENT) == 0) { + should_withhold_permissions &= + !util::AllowedScriptingOnAllUrls(extension->id(), browser_context_); + } URLPatternSet granted_explicit_hosts; URLPatternSet withheld_explicit_hosts; @@ -286,8 +302,10 @@ void PermissionsUpdater::SetPermissions( withheld = withheld.get() ? withheld : extension->permissions_data()->withheld_permissions(); extension->permissions_data()->SetPermissions(active, withheld); - ExtensionPrefs::Get(browser_context_)->SetActivePermissions( - extension->id(), active.get()); + if ((init_flag_ & INIT_FLAG_TRANSIENT) == 0) { + ExtensionPrefs::Get(browser_context_) + ->SetActivePermissions(extension->id(), active.get()); + } } void PermissionsUpdater::DispatchEvent( @@ -311,6 +329,7 @@ void PermissionsUpdater::NotifyPermissionsUpdated( EventType event_type, const Extension* extension, const PermissionSet* changed) { + DCHECK((init_flag_ & INIT_FLAG_TRANSIENT) == 0); if (!changed || changed->IsEmpty()) return; |