| 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
|
|
|