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

Unified Diff: chrome/browser/extensions/permissions_updater.cc

Issue 501273002: Update extension install prompt to reflect withheld permissions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor changes Created 6 years, 3 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/extensions/permissions_updater.cc
diff --git a/chrome/browser/extensions/permissions_updater.cc b/chrome/browser/extensions/permissions_updater.cc
index 385d5e9b95e7f2518a93e6dd8da62308792ad452..6a68371beee3eaf40cc2d27d316724ca6ea0baa1 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;

Powered by Google App Engine
This is Rietveld 408576698