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

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

Issue 2820333003: Revert of Communicate ExtensionSettings policy to renderers (Closed)
Patch Set: Created 3 years, 8 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 67e3ccbbd4d03ddad540480b1717871fa55571c0..a26f0eaa0e42dc6b0222688c7689d7ec748db184 100644
--- a/chrome/browser/extensions/permissions_updater.cc
+++ b/chrome/browser/extensions/permissions_updater.cc
@@ -146,38 +146,6 @@
NotifyPermissionsUpdated(REMOVED, extension, to_remove);
}
-void PermissionsUpdater::SetPolicyHostRestrictions(
- const Extension* extension,
- const URLPatternSet& runtime_blocked_hosts,
- const URLPatternSet& runtime_allowed_hosts) {
- extension->permissions_data()->SetPolicyHostRestrictions(
- runtime_blocked_hosts, runtime_allowed_hosts);
-
- // Send notification to the currently running renderers of the runtime block
- // hosts settings.
- const PermissionSet perms;
- NotifyPermissionsUpdated(POLICY, extension, perms);
-}
-
-void PermissionsUpdater::SetUsesDefaultHostRestrictions(
- const Extension* extension) {
- extension->permissions_data()->SetUsesDefaultHostRestrictions();
- const PermissionSet perms;
- NotifyPermissionsUpdated(POLICY, extension, perms);
-}
-
-void PermissionsUpdater::SetDefaultPolicyHostRestrictions(
- const URLPatternSet& default_runtime_blocked_hosts,
- const URLPatternSet& default_runtime_allowed_hosts) {
- PermissionsData::SetDefaultPolicyHostRestrictions(
- default_runtime_blocked_hosts, default_runtime_allowed_hosts);
-
- // Send notification to the currently running renderers of the runtime block
- // hosts settings.
- NotifyDefaultPolicyHostRestrictionsUpdated(default_runtime_blocked_hosts,
- default_runtime_allowed_hosts);
-}
-
void PermissionsUpdater::RemovePermissionsUnsafe(
const Extension* extension,
const PermissionSet& to_remove) {
@@ -289,31 +257,28 @@
const Extension* extension,
const PermissionSet& changed) {
DCHECK_EQ(0, init_flag_ & INIT_FLAG_TRANSIENT);
-
- if (changed.IsEmpty() && event_type != POLICY)
+ if (changed.IsEmpty())
return;
UpdatedExtensionPermissionsInfo::Reason reason;
- events::HistogramValue histogram_value = events::UNKNOWN;
+ events::HistogramValue histogram_value;
const char* event_name = NULL;
- Profile* profile = Profile::FromBrowserContext(browser_context_);
if (event_type == REMOVED) {
reason = UpdatedExtensionPermissionsInfo::REMOVED;
histogram_value = events::PERMISSIONS_ON_REMOVED;
event_name = permissions::OnRemoved::kEventName;
- } else if (event_type == ADDED) {
+ } else {
+ CHECK_EQ(ADDED, event_type);
reason = UpdatedExtensionPermissionsInfo::ADDED;
histogram_value = events::PERMISSIONS_ON_ADDED;
event_name = permissions::OnAdded::kEventName;
- } else {
- DCHECK_EQ(POLICY, event_type);
- reason = UpdatedExtensionPermissionsInfo::POLICY;
}
// Notify other APIs or interested parties.
- UpdatedExtensionPermissionsInfo info =
- UpdatedExtensionPermissionsInfo(extension, changed, reason);
+ UpdatedExtensionPermissionsInfo info = UpdatedExtensionPermissionsInfo(
+ extension, changed, reason);
+ Profile* profile = Profile::FromBrowserContext(browser_context_);
content::NotificationService::current()->Notify(
extensions::NOTIFICATION_EXTENSION_PERMISSIONS_UPDATED,
content::Source<Profile>(profile),
@@ -325,14 +290,6 @@
extension->permissions_data()->active_permissions());
params.withheld_permissions = ExtensionMsg_PermissionSetStruct(
extension->permissions_data()->withheld_permissions());
- params.uses_default_policy_host_restrictions =
- extension->permissions_data()->UsesDefaultPolicyHostRestrictions();
- if (!params.uses_default_policy_host_restrictions) {
- params.policy_blocked_hosts =
- extension->permissions_data()->policy_blocked_hosts();
- params.policy_allowed_hosts =
- extension->permissions_data()->policy_allowed_hosts();
- }
// Send the new permissions to the renderers.
for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator());
@@ -344,35 +301,8 @@
}
}
- // Trigger the onAdded and onRemoved events in the extension. We explicitly
- // don't do this for policy-related events.
- if (event_name)
- DispatchEvent(extension->id(), histogram_value, event_name, changed);
-}
-
-// Notify the renderers that extension policy (policy_blocked_hosts) is updated
-// and provide new set of hosts.
-void PermissionsUpdater::NotifyDefaultPolicyHostRestrictionsUpdated(
- const URLPatternSet& default_runtime_blocked_hosts,
- const URLPatternSet& default_runtime_allowed_hosts) {
- DCHECK_EQ(0, init_flag_ & INIT_FLAG_TRANSIENT);
-
- Profile* profile = Profile::FromBrowserContext(browser_context_);
-
- ExtensionMsg_UpdateDefaultPolicyHostRestrictions_Params params;
- params.default_policy_blocked_hosts = default_runtime_blocked_hosts;
- params.default_policy_allowed_hosts = default_runtime_allowed_hosts;
-
- // Send the new policy to the renderers.
- for (RenderProcessHost::iterator host_iterator(
- RenderProcessHost::AllHostsIterator());
- !host_iterator.IsAtEnd(); host_iterator.Advance()) {
- RenderProcessHost* host = host_iterator.GetCurrentValue();
- if (profile->IsSameProfile(
- Profile::FromBrowserContext(host->GetBrowserContext()))) {
- host->Send(new ExtensionMsg_UpdateDefaultPolicyHostRestrictions(params));
- }
- }
+ // Trigger the onAdded and onRemoved events in the extension.
+ DispatchEvent(extension->id(), histogram_value, event_name, changed);
}
} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/permissions_updater.h ('k') | chrome/browser/extensions/permissions_updater_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698