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

Side by Side Diff: chrome/browser/ui/webui/options/content_settings_handler.cc

Issue 2525943002: Display content settings for extensions with extension name. (Closed)
Patch Set: fix missing . Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/options/content_settings_handler.h" 5 #include "chrome/browser/ui/webui/options/content_settings_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 // This is mainly here to keep this function ideologically parallel to 935 // This is mainly here to keep this function ideologically parallel to
936 // UpdateExceptionsViewFromHostContentSettingsMap(). 936 // UpdateExceptionsViewFromHostContentSettingsMap().
937 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS); 937 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
938 } 938 }
939 939
940 void ContentSettingsHandler::CompareMediaExceptionsWithFlash( 940 void ContentSettingsHandler::CompareMediaExceptionsWithFlash(
941 ContentSettingsType type) { 941 ContentSettingsType type) {
942 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type); 942 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type);
943 HostContentSettingsMap* settings_map = 943 HostContentSettingsMap* settings_map =
944 HostContentSettingsMapFactory::GetForProfile(GetProfile()); 944 HostContentSettingsMapFactory::GetForProfile(GetProfile());
945 945 const auto* extension_registry =
946 extensions::ExtensionRegistry::Get(GetProfile());
946 base::ListValue exceptions; 947 base::ListValue exceptions;
947 site_settings::GetExceptionsFromHostContentSettingsMap(settings_map, type, 948 site_settings::GetExceptionsFromHostContentSettingsMap(
948 web_ui(), /*incognito=*/false, /*filter=*/nullptr, &exceptions); 949 settings_map, type, extension_registry, web_ui(), /*incognito=*/false,
950 /*filter=*/nullptr, &exceptions);
949 951
950 settings.exceptions.clear(); 952 settings.exceptions.clear();
951 for (base::ListValue::const_iterator entry = exceptions.begin(); 953 for (base::ListValue::const_iterator entry = exceptions.begin();
952 entry != exceptions.end(); ++entry) { 954 entry != exceptions.end(); ++entry) {
953 base::DictionaryValue* dict = nullptr; 955 base::DictionaryValue* dict = nullptr;
954 bool valid_dict = (*entry)->GetAsDictionary(&dict); 956 bool valid_dict = (*entry)->GetAsDictionary(&dict);
955 DCHECK(valid_dict); 957 DCHECK(valid_dict);
956 958
957 std::string origin; 959 std::string origin;
958 std::string setting; 960 std::string setting;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 base::StringValue type_string(kZoomContentType); 1084 base::StringValue type_string(kZoomContentType);
1083 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions", 1085 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions",
1084 type_string, zoom_levels_exceptions); 1086 type_string, zoom_levels_exceptions);
1085 } 1087 }
1086 1088
1087 void ContentSettingsHandler::UpdateExceptionsViewFromHostContentSettingsMap( 1089 void ContentSettingsHandler::UpdateExceptionsViewFromHostContentSettingsMap(
1088 ContentSettingsType type) { 1090 ContentSettingsType type) {
1089 base::ListValue exceptions; 1091 base::ListValue exceptions;
1090 HostContentSettingsMap* settings_map = 1092 HostContentSettingsMap* settings_map =
1091 HostContentSettingsMapFactory::GetForProfile(GetProfile()); 1093 HostContentSettingsMapFactory::GetForProfile(GetProfile());
1092 site_settings::GetExceptionsFromHostContentSettingsMap(settings_map, type, 1094 const auto* extension_registry =
1093 web_ui(), /*incognito=*/false, /*filter=*/nullptr, &exceptions); 1095 extensions::ExtensionRegistry::Get(GetProfile());
1096 site_settings::GetExceptionsFromHostContentSettingsMap(
1097 settings_map, type, extension_registry, web_ui(), /*incognito=*/false,
1098 /*filter=*/nullptr, &exceptions);
1094 base::StringValue type_string( 1099 base::StringValue type_string(
1095 site_settings::ContentSettingsTypeToGroupName(type)); 1100 site_settings::ContentSettingsTypeToGroupName(type));
1096 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions", 1101 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions",
1097 type_string, exceptions); 1102 type_string, exceptions);
1098 1103
1099 UpdateExceptionsViewFromOTRHostContentSettingsMap(type); 1104 UpdateExceptionsViewFromOTRHostContentSettingsMap(type);
1100 1105
1101 #if defined(OS_CHROMEOS) 1106 #if defined(OS_CHROMEOS)
1102 // Also the default for protected contents is managed in another place. 1107 // Also the default for protected contents is managed in another place.
1103 if (type == CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER) 1108 if (type == CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER)
1104 return; 1109 return;
1105 #endif 1110 #endif
1106 1111
1107 // The default may also have changed (we won't get a separate notification). 1112 // The default may also have changed (we won't get a separate notification).
1108 // If it hasn't changed, this call will be harmless. 1113 // If it hasn't changed, this call will be harmless.
1109 UpdateSettingDefaultFromModel(type); 1114 UpdateSettingDefaultFromModel(type);
1110 } 1115 }
1111 1116
1112 void ContentSettingsHandler::UpdateExceptionsViewFromOTRHostContentSettingsMap( 1117 void ContentSettingsHandler::UpdateExceptionsViewFromOTRHostContentSettingsMap(
1113 ContentSettingsType type) { 1118 ContentSettingsType type) {
1114 const HostContentSettingsMap* otr_settings_map = 1119 const HostContentSettingsMap* otr_settings_map =
1115 HostContentSettingsMapFactory::GetForProfile(GetOTRProfile()); 1120 HostContentSettingsMapFactory::GetForProfile(GetOTRProfile());
1116 if (!otr_settings_map) 1121 if (!otr_settings_map)
1117 return; 1122 return;
1123 const auto* extension_registry =
1124 extensions::ExtensionRegistry::Get(GetOTRProfile());
1118 base::ListValue exceptions; 1125 base::ListValue exceptions;
1119 site_settings::GetExceptionsFromHostContentSettingsMap(otr_settings_map, type, 1126 site_settings::GetExceptionsFromHostContentSettingsMap(
1120 web_ui(), /*incognito=*/true, /*filter=*/nullptr, &exceptions); 1127 otr_settings_map, type, extension_registry, web_ui(), /*incognito=*/true,
1128 /*filter=*/nullptr, &exceptions);
1121 base::StringValue type_string( 1129 base::StringValue type_string(
1122 site_settings::ContentSettingsTypeToGroupName(type)); 1130 site_settings::ContentSettingsTypeToGroupName(type));
1123 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setOTRExceptions", 1131 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setOTRExceptions",
1124 type_string, exceptions); 1132 type_string, exceptions);
1125 } 1133 }
1126 1134
1127 void ContentSettingsHandler::RemoveExceptionFromHostContentSettingsMap( 1135 void ContentSettingsHandler::RemoveExceptionFromHostContentSettingsMap(
1128 const base::ListValue* args, 1136 const base::ListValue* args,
1129 ContentSettingsType type) { 1137 ContentSettingsType type) {
1130 std::string mode; 1138 std::string mode;
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 1500
1493 // Exceptions apply only when the feature is enabled. 1501 // Exceptions apply only when the feature is enabled.
1494 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); 1502 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui()));
1495 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); 1503 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM);
1496 web_ui()->CallJavascriptFunctionUnsafe( 1504 web_ui()->CallJavascriptFunctionUnsafe(
1497 "ContentSettings.enableProtectedContentExceptions", 1505 "ContentSettings.enableProtectedContentExceptions",
1498 base::FundamentalValue(enable_exceptions)); 1506 base::FundamentalValue(enable_exceptions));
1499 } 1507 }
1500 1508
1501 } // namespace options 1509 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698