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

Unified Diff: chrome/browser/ui/webui/options/content_settings_handler.cc

Issue 1855393006: [Chrome Settings UI] If User Exceptions are not allowed, prevent editing / viewing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Making ExceptionsList.allowEdit_ a private member. Created 4 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/ui/webui/options/content_settings_handler.cc
diff --git a/chrome/browser/ui/webui/options/content_settings_handler.cc b/chrome/browser/ui/webui/options/content_settings_handler.cc
index 04bc2a1086f2bc0ac94ba7b8dc45514c25d7d297..7cb004959a79f636f94b260eee56cdd4526cc53d 100644
--- a/chrome/browser/ui/webui/options/content_settings_handler.cc
+++ b/chrome/browser/ui/webui/options/content_settings_handler.cc
@@ -878,6 +878,16 @@ void ContentSettingsHandler::UpdateSettingDefaultFromModel(
web_ui()->CallJavascriptFunction(
"ContentSettings.setContentFilterSettingsValue", filter_settings);
+
+ // We assume that special cases covered above to get |provider_id| are not
+ // needed in AreUserExceptionsAllowedForType().
+ bool maybe_enable_exceptions =
+ GetContentSettingsMap()->AreUserExceptionsAllowedForType(type);
+
+ web_ui()->CallJavascriptFunction(
+ "ContentSettings.setUserExceptionsAllowed",
+ base::StringValue(ContentSettingsTypeToGroupName(type)),
+ base::FundamentalValue(maybe_enable_exceptions));
}
void ContentSettingsHandler::UpdateMediaSettingsFromPrefs(
@@ -963,8 +973,7 @@ void ContentSettingsHandler::UpdateGeolocationExceptionsView() {
// Don't add default settings.
if (i->primary_pattern == ContentSettingsPattern::Wildcard() &&
i->secondary_pattern == ContentSettingsPattern::Wildcard() &&
- i
- ->source != site_settings::kPreferencesSource) {
+ i->source != site_settings::kPreferencesSource) {
continue;
}
all_patterns_settings[std::make_pair(i->primary_pattern, i->source)]
@@ -1475,6 +1484,12 @@ void ContentSettingsHandler::RemoveException(const base::ListValue* args) {
std::string type_string;
CHECK(args->GetString(0, &type_string));
+ ContentSettingsType type = ContentSettingsTypeFromGroupName(type_string);
+
+ // If user exceptions are disabled for |type|, don't remove.
+ if (!GetContentSettingsMap()->AreUserExceptionsAllowedForType(type))
+ return;
+
// Zoom levels are no actual content type so we need to handle them
// separately. They would not be recognized by
// ContentSettingsTypeFromGroupName.
@@ -1490,7 +1505,6 @@ void ContentSettingsHandler::RemoveException(const base::ListValue* args) {
return;
}
- ContentSettingsType type = ContentSettingsTypeFromGroupName(type_string);
RemoveExceptionFromHostContentSettingsMap(args, type);
WebSiteSettingsUmaUtil::LogPermissionChange(
@@ -1514,6 +1528,10 @@ void ContentSettingsHandler::SetException(const base::ListValue* args) {
type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) {
NOTREACHED();
} else {
+ // If user exceptions are disabled for |type|, don't set.
+ if (!GetContentSettingsMap()->AreUserExceptionsAllowedForType(type))
+ return;
+
HostContentSettingsMap* settings_map =
mode == "normal" ? GetContentSettingsMap() :
GetOTRContentSettingsMap();
« no previous file with comments | « chrome/browser/resources/options/content_settings_exceptions_area.js ('k') | ui/webui/resources/js/cr/ui/array_data_model.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698