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

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

Issue 2499493004: Communicate ExtensionSettings policy to renderers (Closed)
Patch Set: Created 4 years, 1 month 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 26730a999aaa4510a01500c6c3bab92db4b18f12..3dd213b62f4fd1880b91be340b0846d0e27c804a 100644
--- a/chrome/browser/extensions/permissions_updater.cc
+++ b/chrome/browser/extensions/permissions_updater.cc
@@ -136,6 +136,24 @@ void PermissionsUpdater::RemovePermissions(const Extension* extension,
NotifyPermissionsUpdated(REMOVED, extension, to_remove);
}
+
+void PermissionsUpdater::SetRuntimeBlockedAllowedHosts(
+ const Extension* extension,
+ const URLPatternSet& runtime_blocked_hosts,
+ const URLPatternSet& runtime_allowed_hosts) {
+
+ // Keep track of runtime blocked and hosts for this extension in the browser
+ // process. We'll pull from here to populate when a new renderer is created.
+ extension->permissions_data()->SetRuntimeBlockedAllowedHosts(
+ std::move(runtime_blocked_hosts),
+ std::move(runtime_allowed_hosts));
+
+
+ // Send notification to the currently running renderers of the runtime block
+ // hosts settings.
+ NotifyPolicyUpdated(extension, runtime_blocked_hosts, runtime_allowed_hosts);
+}
+
void PermissionsUpdater::RemovePermissionsUnsafe(
const Extension* extension,
const PermissionSet& to_remove) {
@@ -292,4 +310,32 @@ void PermissionsUpdater::NotifyPermissionsUpdated(
DispatchEvent(extension->id(), histogram_value, event_name, changed);
}
+
+
+// Notify the renderers that extension policy (runtime_blocked_hosts) is updated
+// and provide new set of hosts.
+void PermissionsUpdater::NotifyPolicyUpdated(
+ const Extension* extension,
+ const URLPatternSet& runtime_blocked_hosts,
+ const URLPatternSet& runtime_allowed_hosts) {
+ DCHECK((init_flag_ & INIT_FLAG_TRANSIENT) == 0);
+
+ Profile* profile = Profile::FromBrowserContext(browser_context_);
+
+ ExtensionMsg_UpdatePolicy_Params params;
+ params.extension_id = extension->id();
+ params.runtime_blocked_hosts = runtime_blocked_hosts;
+ params.runtime_allowed_hosts = runtime_allowed_hosts;
+
+ // Send the new policy to the renderers.
+ for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator());
+ !i.IsAtEnd(); i.Advance()) {
+ RenderProcessHost* host = i.GetCurrentValue();
+ if (profile->IsSameProfile(
+ Profile::FromBrowserContext(host->GetBrowserContext()))) {
+ host->Send(new ExtensionMsg_UpdatePolicy(params));
+ }
+ }
+}
+
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698