| OLD | NEW |
| 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 <utility> | 10 #include <utility> |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 #include "components/user_manager/user_manager.h" | 77 #include "components/user_manager/user_manager.h" |
| 78 #endif | 78 #endif |
| 79 | 79 |
| 80 using base::UserMetricsAction; | 80 using base::UserMetricsAction; |
| 81 using content_settings::ContentSettingToString; | 81 using content_settings::ContentSettingToString; |
| 82 using content_settings::ContentSettingFromString; | 82 using content_settings::ContentSettingFromString; |
| 83 using extensions::APIPermission; | 83 using extensions::APIPermission; |
| 84 | 84 |
| 85 namespace options { | 85 namespace options { |
| 86 | 86 |
| 87 // This struct is declared early so that it can used by functions below. | |
| 88 struct ContentSettingsHandler::ChooserTypeNameEntry { | |
| 89 ContentSettingsType type; | |
| 90 ChooserContextBase* (*get_context)(Profile*); | |
| 91 const char* name; | |
| 92 const char* ui_name_key; | |
| 93 }; | |
| 94 | |
| 95 namespace { | 87 namespace { |
| 96 | 88 |
| 97 struct ContentSettingWithExceptions { | 89 struct ContentSettingWithExceptions { |
| 98 ContentSettingWithExceptions(bool otr, UserMetricsAction action) | 90 ContentSettingWithExceptions(bool otr, UserMetricsAction action) |
| 99 : has_otr_exceptions(otr), uma(action) {} | 91 : has_otr_exceptions(otr), uma(action) {} |
| 100 bool has_otr_exceptions; | 92 bool has_otr_exceptions; |
| 101 UserMetricsAction uma; | 93 UserMetricsAction uma; |
| 102 }; | 94 }; |
| 103 | 95 |
| 104 // Maps from the UI string to the object it represents (for sorting purposes). | |
| 105 typedef std::multimap<std::string, const base::DictionaryValue*> SortedObjects; | |
| 106 // Maps from a secondary URL to the set of objects it has permission to access. | |
| 107 typedef std::map<GURL, SortedObjects> OneOriginObjects; | |
| 108 // Maps from a primary URL/source pair to a OneOriginObjects. All the mappings | |
| 109 // in OneOriginObjects share the given primary URL and source. | |
| 110 typedef std::map<std::pair<GURL, std::string>, OneOriginObjects> | |
| 111 AllOriginObjects; | |
| 112 | |
| 113 // The AppFilter is used in AddExceptionsGrantedByHostedApps() to choose | 96 // The AppFilter is used in AddExceptionsGrantedByHostedApps() to choose |
| 114 // extensions which should have their extent displayed. | 97 // extensions which should have their extent displayed. |
| 115 typedef bool (*AppFilter)(const extensions::Extension& app, | 98 typedef bool (*AppFilter)(const extensions::Extension& app, |
| 116 content::BrowserContext* profile); | 99 content::BrowserContext* profile); |
| 117 | 100 |
| 118 const char kExceptionsLearnMoreUrl[] = | 101 const char kExceptionsLearnMoreUrl[] = |
| 119 "https://support.google.com/chrome/?p=settings_manage_exceptions"; | 102 "https://support.google.com/chrome/?p=settings_manage_exceptions"; |
| 120 | 103 |
| 121 const char kAppName[] = "appName"; | 104 const char kAppName[] = "appName"; |
| 122 const char kAppId[] = "appId"; | 105 const char kAppId[] = "appId"; |
| 123 const char kZoom[] = "zoom"; | 106 const char kZoom[] = "zoom"; |
| 124 const char kObject[] = "object"; | |
| 125 const char kObjectName[] = "objectName"; | |
| 126 | |
| 127 ChooserContextBase* GetUsbChooserContext(Profile* profile) { | |
| 128 return UsbChooserContextFactory::GetForProfile(profile); | |
| 129 } | |
| 130 | |
| 131 const ContentSettingsHandler::ChooserTypeNameEntry kChooserTypeGroupNames[] = { | |
| 132 {CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, &GetUsbChooserContext, | |
| 133 "usb-devices", "name"}, | |
| 134 }; | |
| 135 | 107 |
| 136 // A pseudo content type. We use it to display data like a content setting even | 108 // A pseudo content type. We use it to display data like a content setting even |
| 137 // though it is not a real content setting. | 109 // though it is not a real content setting. |
| 138 const char kZoomContentType[] = "zoomlevels"; | 110 const char kZoomContentType[] = "zoomlevels"; |
| 139 | 111 |
| 140 // Maps from a content settings type to a content setting with exceptions | 112 // Maps from a content settings type to a content setting with exceptions |
| 141 // struct. | 113 // struct. |
| 142 typedef std::map<ContentSettingsType, ContentSettingWithExceptions> | 114 typedef std::map<ContentSettingsType, ContentSettingWithExceptions> |
| 143 ExceptionsInfoMap; | 115 ExceptionsInfoMap; |
| 144 | 116 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 UserMetricsAction("Options_DefaultBackgroundSyncSettingChanged")))); | 205 UserMetricsAction("Options_DefaultBackgroundSyncSettingChanged")))); |
| 234 } | 206 } |
| 235 | 207 |
| 236 return exceptions_info_map; | 208 return exceptions_info_map; |
| 237 } | 209 } |
| 238 | 210 |
| 239 content::BrowserContext* GetBrowserContext(content::WebUI* web_ui) { | 211 content::BrowserContext* GetBrowserContext(content::WebUI* web_ui) { |
| 240 return web_ui->GetWebContents()->GetBrowserContext(); | 212 return web_ui->GetWebContents()->GetBrowserContext(); |
| 241 } | 213 } |
| 242 | 214 |
| 243 const ContentSettingsHandler::ChooserTypeNameEntry* ChooserTypeFromGroupName( | |
| 244 const std::string& name) { | |
| 245 for (const auto& chooser_type : kChooserTypeGroupNames) { | |
| 246 if (chooser_type.name == name) | |
| 247 return &chooser_type; | |
| 248 } | |
| 249 return nullptr; | |
| 250 } | |
| 251 | |
| 252 // Create a DictionaryValue* that will act as a data source for a single row | 215 // Create a DictionaryValue* that will act as a data source for a single row |
| 253 // in the Geolocation exceptions table. | 216 // in the Geolocation exceptions table. |
| 254 std::unique_ptr<base::DictionaryValue> GetGeolocationExceptionForPage( | 217 std::unique_ptr<base::DictionaryValue> GetGeolocationExceptionForPage( |
| 255 const ContentSettingsPattern& origin, | 218 const ContentSettingsPattern& origin, |
| 256 const ContentSettingsPattern& embedding_origin, | 219 const ContentSettingsPattern& embedding_origin, |
| 257 ContentSetting setting) { | 220 ContentSetting setting) { |
| 258 base::DictionaryValue* exception = new base::DictionaryValue(); | 221 base::DictionaryValue* exception = new base::DictionaryValue(); |
| 259 | 222 |
| 260 std::string setting_string = | 223 std::string setting_string = |
| 261 content_settings::ContentSettingToString(setting); | 224 content_settings::ContentSettingToString(setting); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 285 content_settings::ContentSettingToString(setting); | 248 content_settings::ContentSettingToString(setting); |
| 286 DCHECK(!setting_string.empty()); | 249 DCHECK(!setting_string.empty()); |
| 287 | 250 |
| 288 exception->SetString(site_settings::kSetting, setting_string); | 251 exception->SetString(site_settings::kSetting, setting_string); |
| 289 exception->SetString(site_settings::kOrigin, primary_pattern.ToString()); | 252 exception->SetString(site_settings::kOrigin, primary_pattern.ToString()); |
| 290 exception->SetString(site_settings::kEmbeddingOrigin, embedding_origin); | 253 exception->SetString(site_settings::kEmbeddingOrigin, embedding_origin); |
| 291 exception->SetString(site_settings::kSource, provider_name); | 254 exception->SetString(site_settings::kSource, provider_name); |
| 292 return base::WrapUnique(exception); | 255 return base::WrapUnique(exception); |
| 293 } | 256 } |
| 294 | 257 |
| 295 // Create a DictionaryValue* that will act as a data source for a single row | |
| 296 // in a chooser permission exceptions table. | |
| 297 std::unique_ptr<base::DictionaryValue> GetChooserExceptionForPage( | |
| 298 const GURL& requesting_origin, | |
| 299 const GURL& embedding_origin, | |
| 300 const std::string& provider_name, | |
| 301 const std::string& name, | |
| 302 const base::DictionaryValue* object) { | |
| 303 std::unique_ptr<base::DictionaryValue> exception(new base::DictionaryValue()); | |
| 304 | |
| 305 std::string setting_string = | |
| 306 content_settings::ContentSettingToString(CONTENT_SETTING_DEFAULT); | |
| 307 DCHECK(!setting_string.empty()); | |
| 308 | |
| 309 exception->SetString(site_settings::kSetting, setting_string); | |
| 310 exception->SetString(site_settings::kOrigin, requesting_origin.spec()); | |
| 311 exception->SetString( | |
| 312 site_settings::kEmbeddingOrigin, embedding_origin.spec()); | |
| 313 exception->SetString(site_settings::kSource, provider_name); | |
| 314 if (object) { | |
| 315 exception->SetString(kObjectName, name); | |
| 316 exception->Set(kObject, object->CreateDeepCopy()); | |
| 317 } | |
| 318 return exception; | |
| 319 } | |
| 320 | |
| 321 // Returns true whenever the |extension| is hosted and has |permission|. | 258 // Returns true whenever the |extension| is hosted and has |permission|. |
| 322 // Must have the AppFilter signature. | 259 // Must have the AppFilter signature. |
| 323 template <APIPermission::ID permission> | 260 template <APIPermission::ID permission> |
| 324 bool HostedAppHasPermission(const extensions::Extension& extension, | 261 bool HostedAppHasPermission(const extensions::Extension& extension, |
| 325 content::BrowserContext* /* context */) { | 262 content::BrowserContext* /* context */) { |
| 326 return extension.is_hosted_app() && | 263 return extension.is_hosted_app() && |
| 327 extension.permissions_data()->HasAPIPermission(permission); | 264 extension.permissions_data()->HasAPIPermission(permission); |
| 328 } | 265 } |
| 329 | 266 |
| 330 // Add an "Allow"-entry to the list of |exceptions| for a |url_pattern| from | 267 // Add an "Allow"-entry to the list of |exceptions| for a |url_pattern| from |
| (...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1043 UpdateFlashMediaLinksVisibility(type); | 980 UpdateFlashMediaLinksVisibility(type); |
| 1044 } | 981 } |
| 1045 | 982 |
| 1046 void ContentSettingsHandler::UpdateMIDISysExExceptionsView() { | 983 void ContentSettingsHandler::UpdateMIDISysExExceptionsView() { |
| 1047 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_MIDI_SYSEX); | 984 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_MIDI_SYSEX); |
| 1048 UpdateExceptionsViewFromHostContentSettingsMap( | 985 UpdateExceptionsViewFromHostContentSettingsMap( |
| 1049 CONTENT_SETTINGS_TYPE_MIDI_SYSEX); | 986 CONTENT_SETTINGS_TYPE_MIDI_SYSEX); |
| 1050 } | 987 } |
| 1051 | 988 |
| 1052 void ContentSettingsHandler::UpdateAllChooserExceptionsViewsFromModel() { | 989 void ContentSettingsHandler::UpdateAllChooserExceptionsViewsFromModel() { |
| 1053 for (const ChooserTypeNameEntry& chooser_type : kChooserTypeGroupNames) | 990 for (const site_settings::ChooserTypeNameEntry& chooser_type : |
| 991 site_settings::kChooserTypeGroupNames) |
| 1054 UpdateChooserExceptionsViewFromModel(chooser_type); | 992 UpdateChooserExceptionsViewFromModel(chooser_type); |
| 1055 } | 993 } |
| 1056 | 994 |
| 1057 void ContentSettingsHandler::UpdateAllOTRChooserExceptionsViewsFromModel() { | 995 void ContentSettingsHandler::UpdateAllOTRChooserExceptionsViewsFromModel() { |
| 1058 for (const ChooserTypeNameEntry& chooser_type : kChooserTypeGroupNames) | 996 for (const site_settings::ChooserTypeNameEntry& chooser_type : |
| 997 site_settings::kChooserTypeGroupNames) |
| 1059 UpdateOTRChooserExceptionsViewFromModel(chooser_type); | 998 UpdateOTRChooserExceptionsViewFromModel(chooser_type); |
| 1060 } | 999 } |
| 1061 | 1000 |
| 1062 void ContentSettingsHandler::UpdateChooserExceptionsViewFromModel( | 1001 void ContentSettingsHandler::UpdateChooserExceptionsViewFromModel( |
| 1063 const ChooserTypeNameEntry& chooser_type) { | 1002 const site_settings::ChooserTypeNameEntry& chooser_type) { |
| 1064 base::ListValue exceptions; | 1003 base::ListValue exceptions; |
| 1065 GetChooserExceptionsFromProfile(false, chooser_type, &exceptions); | 1004 site_settings::GetChooserExceptionsFromProfile( |
| 1005 Profile::FromWebUI(web_ui()), false, chooser_type, &exceptions); |
| 1066 base::StringValue type_string(chooser_type.name); | 1006 base::StringValue type_string(chooser_type.name); |
| 1067 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions", | 1007 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions", |
| 1068 type_string, exceptions); | 1008 type_string, exceptions); |
| 1069 | 1009 |
| 1070 UpdateOTRChooserExceptionsViewFromModel(chooser_type); | 1010 UpdateOTRChooserExceptionsViewFromModel(chooser_type); |
| 1071 } | 1011 } |
| 1072 | 1012 |
| 1073 void ContentSettingsHandler::UpdateOTRChooserExceptionsViewFromModel( | 1013 void ContentSettingsHandler::UpdateOTRChooserExceptionsViewFromModel( |
| 1074 const ChooserTypeNameEntry& chooser_type) { | 1014 const site_settings::ChooserTypeNameEntry& chooser_type) { |
| 1075 if (!Profile::FromWebUI(web_ui())->HasOffTheRecordProfile()) | 1015 if (!Profile::FromWebUI(web_ui())->HasOffTheRecordProfile()) |
| 1076 return; | 1016 return; |
| 1077 | 1017 |
| 1078 base::ListValue exceptions; | 1018 base::ListValue exceptions; |
| 1079 GetChooserExceptionsFromProfile(true, chooser_type, &exceptions); | 1019 site_settings::GetChooserExceptionsFromProfile( |
| 1020 Profile::FromWebUI(web_ui()), true, chooser_type, &exceptions); |
| 1080 base::StringValue type_string(chooser_type.name); | 1021 base::StringValue type_string(chooser_type.name); |
| 1081 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setOTRExceptions", | 1022 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setOTRExceptions", |
| 1082 type_string, exceptions); | 1023 type_string, exceptions); |
| 1083 } | 1024 } |
| 1084 | 1025 |
| 1085 void ContentSettingsHandler::UpdateZoomLevelsExceptionsView() { | 1026 void ContentSettingsHandler::UpdateZoomLevelsExceptionsView() { |
| 1086 base::ListValue zoom_levels_exceptions; | 1027 base::ListValue zoom_levels_exceptions; |
| 1087 | 1028 |
| 1088 content::HostZoomMap* host_zoom_map = | 1029 content::HostZoomMap* host_zoom_map = |
| 1089 content::HostZoomMap::GetDefaultForBrowserContext( | 1030 content::HostZoomMap::GetDefaultForBrowserContext( |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1189 return; | 1130 return; |
| 1190 base::ListValue exceptions; | 1131 base::ListValue exceptions; |
| 1191 site_settings::GetExceptionsFromHostContentSettingsMap( | 1132 site_settings::GetExceptionsFromHostContentSettingsMap( |
| 1192 otr_settings_map, type, web_ui(), &exceptions); | 1133 otr_settings_map, type, web_ui(), &exceptions); |
| 1193 base::StringValue type_string( | 1134 base::StringValue type_string( |
| 1194 site_settings::ContentSettingsTypeToGroupName(type)); | 1135 site_settings::ContentSettingsTypeToGroupName(type)); |
| 1195 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setOTRExceptions", | 1136 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setOTRExceptions", |
| 1196 type_string, exceptions); | 1137 type_string, exceptions); |
| 1197 } | 1138 } |
| 1198 | 1139 |
| 1199 void ContentSettingsHandler::GetChooserExceptionsFromProfile( | |
| 1200 bool incognito, | |
| 1201 const ChooserTypeNameEntry& chooser_type, | |
| 1202 base::ListValue* exceptions) { | |
| 1203 Profile* profile = Profile::FromWebUI(web_ui()); | |
| 1204 if (incognito) { | |
| 1205 if (profile->HasOffTheRecordProfile()) | |
| 1206 profile = profile->GetOffTheRecordProfile(); | |
| 1207 else | |
| 1208 return; | |
| 1209 } | |
| 1210 | |
| 1211 ChooserContextBase* chooser_context = chooser_type.get_context(profile); | |
| 1212 std::vector<std::unique_ptr<ChooserContextBase::Object>> objects = | |
| 1213 chooser_context->GetAllGrantedObjects(); | |
| 1214 AllOriginObjects all_origin_objects; | |
| 1215 for (const auto& object : objects) { | |
| 1216 std::string name; | |
| 1217 bool found = object->object.GetString(chooser_type.ui_name_key, &name); | |
| 1218 DCHECK(found); | |
| 1219 // It is safe for this structure to hold references into |objects| because | |
| 1220 // they are both destroyed at the end of this function. | |
| 1221 all_origin_objects[make_pair(object->requesting_origin, | |
| 1222 object->source)][object->embedding_origin] | |
| 1223 .insert(make_pair(name, &object->object)); | |
| 1224 } | |
| 1225 | |
| 1226 // Keep the exceptions sorted by provider so they will be displayed in | |
| 1227 // precedence order. | |
| 1228 std::vector<std::unique_ptr<base::DictionaryValue>> | |
| 1229 all_provider_exceptions[HostContentSettingsMap::NUM_PROVIDER_TYPES]; | |
| 1230 | |
| 1231 for (const auto& all_origin_objects_entry : all_origin_objects) { | |
| 1232 const GURL& requesting_origin = all_origin_objects_entry.first.first; | |
| 1233 const std::string& source = all_origin_objects_entry.first.second; | |
| 1234 const OneOriginObjects& one_origin_objects = | |
| 1235 all_origin_objects_entry.second; | |
| 1236 | |
| 1237 auto& this_provider_exceptions = all_provider_exceptions | |
| 1238 [HostContentSettingsMap::GetProviderTypeFromSource(source)]; | |
| 1239 | |
| 1240 // Add entries for any non-embedded origins. | |
| 1241 bool has_embedded_entries = false; | |
| 1242 for (const auto& one_origin_objects_entry : one_origin_objects) { | |
| 1243 const GURL& embedding_origin = one_origin_objects_entry.first; | |
| 1244 const SortedObjects& sorted_objects = one_origin_objects_entry.second; | |
| 1245 | |
| 1246 // Skip the embedded settings which will be added below. | |
| 1247 if (requesting_origin != embedding_origin) { | |
| 1248 has_embedded_entries = true; | |
| 1249 continue; | |
| 1250 } | |
| 1251 | |
| 1252 for (const auto& sorted_objects_entry : sorted_objects) { | |
| 1253 this_provider_exceptions.push_back(GetChooserExceptionForPage( | |
| 1254 requesting_origin, embedding_origin, source, | |
| 1255 sorted_objects_entry.first, sorted_objects_entry.second)); | |
| 1256 } | |
| 1257 } | |
| 1258 | |
| 1259 if (has_embedded_entries) { | |
| 1260 // Add a "parent" entry that simply acts as a heading for all entries | |
| 1261 // where |requesting_origin| has been embedded. | |
| 1262 this_provider_exceptions.push_back( | |
| 1263 GetChooserExceptionForPage(requesting_origin, requesting_origin, | |
| 1264 source, std::string(), nullptr)); | |
| 1265 | |
| 1266 // Add the "children" for any embedded settings. | |
| 1267 for (const auto& one_origin_objects_entry : one_origin_objects) { | |
| 1268 const GURL& embedding_origin = one_origin_objects_entry.first; | |
| 1269 const SortedObjects& sorted_objects = one_origin_objects_entry.second; | |
| 1270 | |
| 1271 // Skip the non-embedded setting which we already added above. | |
| 1272 if (requesting_origin == embedding_origin) | |
| 1273 continue; | |
| 1274 | |
| 1275 for (const auto& sorted_objects_entry : sorted_objects) { | |
| 1276 this_provider_exceptions.push_back(GetChooserExceptionForPage( | |
| 1277 requesting_origin, embedding_origin, source, | |
| 1278 sorted_objects_entry.first, sorted_objects_entry.second)); | |
| 1279 } | |
| 1280 } | |
| 1281 } | |
| 1282 } | |
| 1283 | |
| 1284 for (auto& one_provider_exceptions : all_provider_exceptions) { | |
| 1285 for (auto& exception : one_provider_exceptions) | |
| 1286 exceptions->Append(std::move(exception)); | |
| 1287 } | |
| 1288 } | |
| 1289 | |
| 1290 void ContentSettingsHandler::RemoveExceptionFromHostContentSettingsMap( | 1140 void ContentSettingsHandler::RemoveExceptionFromHostContentSettingsMap( |
| 1291 const base::ListValue* args, | 1141 const base::ListValue* args, |
| 1292 ContentSettingsType type) { | 1142 ContentSettingsType type) { |
| 1293 std::string mode; | 1143 std::string mode; |
| 1294 bool rv = args->GetString(1, &mode); | 1144 bool rv = args->GetString(1, &mode); |
| 1295 DCHECK(rv); | 1145 DCHECK(rv); |
| 1296 | 1146 |
| 1297 std::string pattern; | 1147 std::string pattern; |
| 1298 rv = args->GetString(2, &pattern); | 1148 rv = args->GetString(2, &pattern); |
| 1299 DCHECK(rv); | 1149 DCHECK(rv); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1343 | 1193 |
| 1344 content::HostZoomMap* host_zoom_map; | 1194 content::HostZoomMap* host_zoom_map; |
| 1345 host_zoom_map = | 1195 host_zoom_map = |
| 1346 content::HostZoomMap::GetDefaultForBrowserContext( | 1196 content::HostZoomMap::GetDefaultForBrowserContext( |
| 1347 GetBrowserContext(web_ui())); | 1197 GetBrowserContext(web_ui())); |
| 1348 double default_level = host_zoom_map->GetDefaultZoomLevel(); | 1198 double default_level = host_zoom_map->GetDefaultZoomLevel(); |
| 1349 host_zoom_map->SetZoomLevelForHost(pattern, default_level); | 1199 host_zoom_map->SetZoomLevelForHost(pattern, default_level); |
| 1350 } | 1200 } |
| 1351 | 1201 |
| 1352 void ContentSettingsHandler::RemoveChooserException( | 1202 void ContentSettingsHandler::RemoveChooserException( |
| 1353 const ChooserTypeNameEntry* chooser_type, | 1203 const site_settings::ChooserTypeNameEntry* chooser_type, |
| 1354 const base::ListValue* args) { | 1204 const base::ListValue* args) { |
| 1355 std::string mode; | 1205 std::string mode; |
| 1356 bool rv = args->GetString(1, &mode); | 1206 bool rv = args->GetString(1, &mode); |
| 1357 DCHECK(rv); | 1207 DCHECK(rv); |
| 1358 | 1208 |
| 1359 std::string requesting_origin_string; | 1209 std::string requesting_origin_string; |
| 1360 rv = args->GetString(2, &requesting_origin_string); | 1210 rv = args->GetString(2, &requesting_origin_string); |
| 1361 DCHECK(rv); | 1211 DCHECK(rv); |
| 1362 GURL requesting_origin(requesting_origin_string); | 1212 GURL requesting_origin(requesting_origin_string); |
| 1363 DCHECK(requesting_origin.is_valid()); | 1213 DCHECK(requesting_origin.is_valid()); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1438 CHECK(args->GetString(0, &type_string)); | 1288 CHECK(args->GetString(0, &type_string)); |
| 1439 | 1289 |
| 1440 // Zoom levels are no actual content type so we need to handle them | 1290 // Zoom levels are no actual content type so we need to handle them |
| 1441 // separately. They would not be recognized by | 1291 // separately. They would not be recognized by |
| 1442 // ContentSettingsTypeFromGroupName. | 1292 // ContentSettingsTypeFromGroupName. |
| 1443 if (type_string == kZoomContentType) { | 1293 if (type_string == kZoomContentType) { |
| 1444 RemoveZoomLevelException(args); | 1294 RemoveZoomLevelException(args); |
| 1445 return; | 1295 return; |
| 1446 } | 1296 } |
| 1447 | 1297 |
| 1448 const ChooserTypeNameEntry* chooser_type = | 1298 const site_settings::ChooserTypeNameEntry* chooser_type = |
| 1449 ChooserTypeFromGroupName(type_string); | 1299 site_settings::ChooserTypeFromGroupName(type_string); |
| 1450 if (chooser_type) { | 1300 if (chooser_type) { |
| 1451 RemoveChooserException(chooser_type, args); | 1301 RemoveChooserException(chooser_type, args); |
| 1452 return; | 1302 return; |
| 1453 } | 1303 } |
| 1454 | 1304 |
| 1455 ContentSettingsType type = | 1305 ContentSettingsType type = |
| 1456 site_settings::ContentSettingsTypeFromGroupName(type_string); | 1306 site_settings::ContentSettingsTypeFromGroupName(type_string); |
| 1457 RemoveExceptionFromHostContentSettingsMap(args, type); | 1307 RemoveExceptionFromHostContentSettingsMap(args, type); |
| 1458 | 1308 |
| 1459 WebSiteSettingsUmaUtil::LogPermissionChange( | 1309 WebSiteSettingsUmaUtil::LogPermissionChange( |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1655 | 1505 |
| 1656 // Exceptions apply only when the feature is enabled. | 1506 // Exceptions apply only when the feature is enabled. |
| 1657 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); | 1507 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); |
| 1658 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); | 1508 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); |
| 1659 web_ui()->CallJavascriptFunctionUnsafe( | 1509 web_ui()->CallJavascriptFunctionUnsafe( |
| 1660 "ContentSettings.enableProtectedContentExceptions", | 1510 "ContentSettings.enableProtectedContentExceptions", |
| 1661 base::FundamentalValue(enable_exceptions)); | 1511 base::FundamentalValue(enable_exceptions)); |
| 1662 } | 1512 } |
| 1663 | 1513 |
| 1664 } // namespace options | 1514 } // namespace options |
| OLD | NEW |