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

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

Issue 396033002: Support "always allow" for runtime script execution (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Discriminate between explicit and scriptable hosts, other minor changes Created 6 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/extensions/permissions_updater.cc
diff --git a/chrome/browser/extensions/permissions_updater.cc b/chrome/browser/extensions/permissions_updater.cc
index 5f2f62981d5889f7db19804d7734561aaaac5b9f..414bdbc9c69fbbd7c532b383125e60e9052c9db6 100644
--- a/chrome/browser/extensions/permissions_updater.cc
+++ b/chrome/browser/extensions/permissions_updater.cc
@@ -144,9 +144,9 @@ void PermissionsUpdater::GrantActivePermissions(const Extension* extension) {
}
void PermissionsUpdater::InitializePermissions(const Extension* extension) {
+ ExtensionPrefs* prefs = ExtensionPrefs::Get(browser_context_);
scoped_refptr<const PermissionSet> bounded_active =
- GetBoundedActivePermissions(extension,
- ExtensionPrefs::Get(browser_context_));
+ GetBoundedActivePermissions(extension, prefs);
// We withhold permissions iff the switch to do so is enabled, the extension
// shows up in chrome:extensions (so the user can grant withheld permissions),
@@ -175,6 +175,23 @@ void PermissionsUpdater::InitializePermissions(const Extension* extension) {
&granted_scriptable_hosts,
&withheld_scriptable_hosts);
+ // Add persisted permissions to granted hosts.
+ PermissionSet* persisted = prefs->GetPersistedPermissions(extension->id());
+ if (persisted) {
+ const URLPatternSet& explicit_hosts = persisted->explicit_hosts();
+ for (URLPatternSet::const_iterator iter = explicit_hosts.begin();
+ iter != explicit_hosts.end();
+ ++iter) {
+ granted_explicit_hosts.AddPattern(*iter);
+ }
+ const URLPatternSet& scriptable_hosts = persisted->scriptable_hosts();
+ for (URLPatternSet::const_iterator iter = scriptable_hosts.begin();
+ iter != scriptable_hosts.end();
+ ++iter) {
+ granted_scriptable_hosts.AddPattern(*iter);
+ }
+ }
+
bounded_active = new PermissionSet(bounded_active->apis(),
bounded_active->manifest_permissions(),
granted_explicit_hosts,

Powered by Google App Engine
This is Rietveld 408576698