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 <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
179 const ContentSettingsPattern& pattern, | 179 const ContentSettingsPattern& pattern, |
180 const ContentSettingsPattern& secondary_pattern, | 180 const ContentSettingsPattern& secondary_pattern, |
181 const ContentSetting& setting, | 181 const ContentSetting& setting, |
182 const std::string& provider_name) { | 182 const std::string& provider_name) { |
183 base::DictionaryValue* exception = new base::DictionaryValue(); | 183 base::DictionaryValue* exception = new base::DictionaryValue(); |
184 exception->SetString(kOrigin, pattern.ToString()); | 184 exception->SetString(kOrigin, pattern.ToString()); |
185 exception->SetString(kEmbeddingOrigin, | 185 exception->SetString(kEmbeddingOrigin, |
186 secondary_pattern == ContentSettingsPattern::Wildcard() ? | 186 secondary_pattern == ContentSettingsPattern::Wildcard() ? |
187 std::string() : | 187 std::string() : |
188 secondary_pattern.ToString()); | 188 secondary_pattern.ToString()); |
189 exception->SetString(kSetting, ContentSettingToString(setting)); | 189 |
190 std::string setting_string; | |
191 bool return_value = | |
Bernhard Bauer
2015/10/07 11:38:21
Call this variable |success| maybe? |return_value|
Deepak
2015/10/07 13:54:43
Done.
| |
192 content_settings::ContentSettingToString(setting, &setting_string); | |
193 DCHECK(return_value); | |
194 | |
195 exception->SetString(kSetting, setting_string); | |
190 exception->SetString(kSource, provider_name); | 196 exception->SetString(kSource, provider_name); |
191 return make_scoped_ptr(exception); | 197 return make_scoped_ptr(exception); |
192 } | 198 } |
193 | 199 |
194 // Create a DictionaryValue* that will act as a data source for a single row | 200 // Create a DictionaryValue* that will act as a data source for a single row |
195 // in the Geolocation exceptions table. | 201 // in the Geolocation exceptions table. |
196 scoped_ptr<base::DictionaryValue> GetGeolocationExceptionForPage( | 202 scoped_ptr<base::DictionaryValue> GetGeolocationExceptionForPage( |
197 const ContentSettingsPattern& origin, | 203 const ContentSettingsPattern& origin, |
198 const ContentSettingsPattern& embedding_origin, | 204 const ContentSettingsPattern& embedding_origin, |
199 ContentSetting setting) { | 205 ContentSetting setting) { |
200 base::DictionaryValue* exception = new base::DictionaryValue(); | 206 base::DictionaryValue* exception = new base::DictionaryValue(); |
201 exception->SetString(kSetting, ContentSettingToString(setting)); | 207 |
208 std::string setting_string; | |
209 bool return_value = | |
210 content_settings::ContentSettingToString(setting, &setting_string); | |
211 DCHECK(return_value); | |
212 | |
213 exception->SetString(kSetting, setting_string); | |
202 exception->SetString(kOrigin, origin.ToString()); | 214 exception->SetString(kOrigin, origin.ToString()); |
203 exception->SetString(kEmbeddingOrigin, embedding_origin.ToString()); | 215 exception->SetString(kEmbeddingOrigin, embedding_origin.ToString()); |
204 return make_scoped_ptr(exception); | 216 return make_scoped_ptr(exception); |
205 } | 217 } |
206 | 218 |
207 // Create a DictionaryValue* that will act as a data source for a single row | 219 // Create a DictionaryValue* that will act as a data source for a single row |
208 // in the desktop notifications exceptions table. | 220 // in the desktop notifications exceptions table. |
209 scoped_ptr<base::DictionaryValue> GetNotificationExceptionForPage( | 221 scoped_ptr<base::DictionaryValue> GetNotificationExceptionForPage( |
210 const ContentSettingsPattern& primary_pattern, | 222 const ContentSettingsPattern& primary_pattern, |
211 const ContentSettingsPattern& secondary_pattern, | 223 const ContentSettingsPattern& secondary_pattern, |
212 ContentSetting setting, | 224 ContentSetting setting, |
213 const std::string& provider_name) { | 225 const std::string& provider_name) { |
214 std::string embedding_origin; | 226 std::string embedding_origin; |
215 if (secondary_pattern != ContentSettingsPattern::Wildcard()) | 227 if (secondary_pattern != ContentSettingsPattern::Wildcard()) |
216 embedding_origin = secondary_pattern.ToString(); | 228 embedding_origin = secondary_pattern.ToString(); |
217 | 229 |
218 base::DictionaryValue* exception = new base::DictionaryValue(); | 230 base::DictionaryValue* exception = new base::DictionaryValue(); |
219 exception->SetString(kSetting, ContentSettingToString(setting)); | 231 |
232 std::string setting_string; | |
233 bool return_value = | |
234 content_settings::ContentSettingToString(setting, &setting_string); | |
235 DCHECK(return_value); | |
236 | |
237 exception->SetString(kSetting, setting_string); | |
220 exception->SetString(kOrigin, primary_pattern.ToString()); | 238 exception->SetString(kOrigin, primary_pattern.ToString()); |
221 exception->SetString(kEmbeddingOrigin, embedding_origin); | 239 exception->SetString(kEmbeddingOrigin, embedding_origin); |
222 exception->SetString(kSource, provider_name); | 240 exception->SetString(kSource, provider_name); |
223 return make_scoped_ptr(exception); | 241 return make_scoped_ptr(exception); |
224 } | 242 } |
225 | 243 |
226 // Returns true whenever the |extension| is hosted and has |permission|. | 244 // Returns true whenever the |extension| is hosted and has |permission|. |
227 // Must have the AppFilter signature. | 245 // Must have the AppFilter signature. |
228 template <APIPermission::ID permission> | 246 template <APIPermission::ID permission> |
229 bool HostedAppHasPermission(const extensions::Extension& extension, | 247 bool HostedAppHasPermission(const extensions::Extension& extension, |
230 content::BrowserContext* /* context */) { | 248 content::BrowserContext* /* context */) { |
231 return extension.is_hosted_app() && | 249 return extension.is_hosted_app() && |
232 extension.permissions_data()->HasAPIPermission(permission); | 250 extension.permissions_data()->HasAPIPermission(permission); |
233 } | 251 } |
234 | 252 |
235 // Add an "Allow"-entry to the list of |exceptions| for a |url_pattern| from | 253 // Add an "Allow"-entry to the list of |exceptions| for a |url_pattern| from |
236 // the web extent of a hosted |app|. | 254 // the web extent of a hosted |app|. |
237 void AddExceptionForHostedApp(const std::string& url_pattern, | 255 void AddExceptionForHostedApp(const std::string& url_pattern, |
238 const extensions::Extension& app, base::ListValue* exceptions) { | 256 const extensions::Extension& app, base::ListValue* exceptions) { |
239 base::DictionaryValue* exception = new base::DictionaryValue(); | 257 base::DictionaryValue* exception = new base::DictionaryValue(); |
240 exception->SetString(kSetting, ContentSettingToString(CONTENT_SETTING_ALLOW)); | 258 |
259 std::string setting_string; | |
260 bool return_value = content_settings::ContentSettingToString( | |
261 CONTENT_SETTING_ALLOW, &setting_string); | |
262 DCHECK(return_value); | |
263 | |
264 exception->SetString(kSetting, setting_string); | |
241 exception->SetString(kOrigin, url_pattern); | 265 exception->SetString(kOrigin, url_pattern); |
242 exception->SetString(kEmbeddingOrigin, url_pattern); | 266 exception->SetString(kEmbeddingOrigin, url_pattern); |
243 exception->SetString(kSource, "HostedApp"); | 267 exception->SetString(kSource, "HostedApp"); |
244 exception->SetString(kAppName, app.name()); | 268 exception->SetString(kAppName, app.name()); |
245 exception->SetString(kAppId, app.id()); | 269 exception->SetString(kAppId, app.id()); |
246 exceptions->Append(exception); | 270 exceptions->Append(exception); |
247 } | 271 } |
248 | 272 |
249 // Asks the |profile| for hosted apps which have the |permission| set, and | 273 // Asks the |profile| for hosted apps which have the |permission| set, and |
250 // adds their web extent and launch URL to the |exceptions| list. | 274 // adds their web extent and launch URL to the |exceptions| list. |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
345 {"manageHandlers", IDS_HANDLERS_MANAGE}, | 369 {"manageHandlers", IDS_HANDLERS_MANAGE}, |
346 {"exceptionPatternHeader", IDS_EXCEPTIONS_PATTERN_HEADER}, | 370 {"exceptionPatternHeader", IDS_EXCEPTIONS_PATTERN_HEADER}, |
347 {"exceptionBehaviorHeader", IDS_EXCEPTIONS_ACTION_HEADER}, | 371 {"exceptionBehaviorHeader", IDS_EXCEPTIONS_ACTION_HEADER}, |
348 {"exceptionZoomHeader", IDS_EXCEPTIONS_ZOOM_HEADER}, | 372 {"exceptionZoomHeader", IDS_EXCEPTIONS_ZOOM_HEADER}, |
349 {"embeddedOnHost", IDS_EXCEPTIONS_GEOLOCATION_EMBEDDED_ON_HOST}, | 373 {"embeddedOnHost", IDS_EXCEPTIONS_GEOLOCATION_EMBEDDED_ON_HOST}, |
350 // Cookies filter. | 374 // Cookies filter. |
351 {"cookiesTabLabel", IDS_COOKIES_TAB_LABEL}, | 375 {"cookiesTabLabel", IDS_COOKIES_TAB_LABEL}, |
352 {"cookiesHeader", IDS_COOKIES_HEADER}, | 376 {"cookiesHeader", IDS_COOKIES_HEADER}, |
353 {"cookiesAllow", IDS_COOKIES_ALLOW_RADIO}, | 377 {"cookiesAllow", IDS_COOKIES_ALLOW_RADIO}, |
354 {"cookiesBlock", IDS_COOKIES_BLOCK_RADIO}, | 378 {"cookiesBlock", IDS_COOKIES_BLOCK_RADIO}, |
355 {"cookiesSession", IDS_COOKIES_SESSION_ONLY_RADIO}, | 379 {"cookiesSessionOnly", IDS_COOKIES_SESSION_ONLY_RADIO}, |
356 {"cookiesBlock3rdParty", IDS_COOKIES_BLOCK_3RDPARTY_CHKBOX}, | 380 {"cookiesBlock3rdParty", IDS_COOKIES_BLOCK_3RDPARTY_CHKBOX}, |
357 {"cookiesShowCookies", IDS_COOKIES_SHOW_COOKIES_BUTTON}, | 381 {"cookiesShowCookies", IDS_COOKIES_SHOW_COOKIES_BUTTON}, |
358 {"flashStorageSettings", IDS_FLASH_STORAGE_SETTINGS}, | 382 {"flashStorageSettings", IDS_FLASH_STORAGE_SETTINGS}, |
359 {"flashStorageUrl", IDS_FLASH_STORAGE_URL}, | 383 {"flashStorageUrl", IDS_FLASH_STORAGE_URL}, |
360 #if defined(ENABLE_GOOGLE_NOW) | 384 #if defined(ENABLE_GOOGLE_NOW) |
361 {"googleGeolocationAccessEnable", | 385 {"googleGeolocationAccessEnable", |
362 IDS_GEOLOCATION_GOOGLE_ACCESS_ENABLE_CHKBOX}, | 386 IDS_GEOLOCATION_GOOGLE_ACCESS_ENABLE_CHKBOX}, |
363 #endif | 387 #endif |
364 // Image filter. | 388 // Image filter. |
365 {"imagesTabLabel", IDS_IMAGES_TAB_LABEL}, | 389 {"imagesTabLabel", IDS_IMAGES_TAB_LABEL}, |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
467 ->Get(CONTENT_SETTINGS_TYPE_PLUGINS) | 491 ->Get(CONTENT_SETTINGS_TYPE_PLUGINS) |
468 ->default_value_pref_name()); | 492 ->default_value_pref_name()); |
469 | 493 |
470 int default_value = CONTENT_SETTING_DEFAULT; | 494 int default_value = CONTENT_SETTING_DEFAULT; |
471 bool success = default_pref->GetAsInteger(&default_value); | 495 bool success = default_pref->GetAsInteger(&default_value); |
472 DCHECK(success); | 496 DCHECK(success); |
473 DCHECK_NE(CONTENT_SETTING_DEFAULT, default_value); | 497 DCHECK_NE(CONTENT_SETTING_DEFAULT, default_value); |
474 | 498 |
475 int plugin_ids = default_value == CONTENT_SETTING_DETECT_IMPORTANT_CONTENT ? | 499 int plugin_ids = default_value == CONTENT_SETTING_DETECT_IMPORTANT_CONTENT ? |
476 IDS_PLUGIN_DETECT_RECOMMENDED_RADIO : IDS_PLUGIN_DETECT_RADIO; | 500 IDS_PLUGIN_DETECT_RECOMMENDED_RADIO : IDS_PLUGIN_DETECT_RADIO; |
477 localized_strings->SetString("pluginsDetect", | 501 localized_strings->SetString("pluginsDetectImportantContent", |
478 l10n_util::GetStringUTF16(plugin_ids)); | 502 l10n_util::GetStringUTF16(plugin_ids)); |
479 | 503 |
480 RegisterTitle(localized_strings, "contentSettingsPage", | 504 RegisterTitle(localized_strings, "contentSettingsPage", |
481 IDS_CONTENT_SETTINGS_TITLE); | 505 IDS_CONTENT_SETTINGS_TITLE); |
482 | 506 |
483 // Register titles for each of the individual settings whose exception | 507 // Register titles for each of the individual settings whose exception |
484 // dialogs will be processed by |ContentSettingsHandler|. | 508 // dialogs will be processed by |ContentSettingsHandler|. |
485 RegisterTitle(localized_strings, "cookies", | 509 RegisterTitle(localized_strings, "cookies", |
486 IDS_COOKIES_TAB_LABEL); | 510 IDS_COOKIES_TAB_LABEL); |
487 RegisterTitle(localized_strings, "images", | 511 RegisterTitle(localized_strings, "images", |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
708 if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || | 732 if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || |
709 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) { | 733 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) { |
710 UpdateMediaSettingsFromPrefs(type); | 734 UpdateMediaSettingsFromPrefs(type); |
711 if (media_settings_->forType(type).policy_disable) { | 735 if (media_settings_->forType(type).policy_disable) { |
712 default_setting = CONTENT_SETTING_BLOCK; | 736 default_setting = CONTENT_SETTING_BLOCK; |
713 provider_id = kPolicyProviderId; | 737 provider_id = kPolicyProviderId; |
714 } | 738 } |
715 } | 739 } |
716 | 740 |
717 base::DictionaryValue filter_settings; | 741 base::DictionaryValue filter_settings; |
742 | |
743 std::string setting_string; | |
744 bool return_value = content_settings::ContentSettingToString(default_setting, | |
745 &setting_string); | |
746 DCHECK(return_value); | |
747 | |
718 filter_settings.SetString(ContentSettingsTypeToGroupName(type) + ".value", | 748 filter_settings.SetString(ContentSettingsTypeToGroupName(type) + ".value", |
719 ContentSettingToString(default_setting)); | 749 setting_string); |
720 filter_settings.SetString( | 750 filter_settings.SetString( |
721 ContentSettingsTypeToGroupName(type) + ".managedBy", provider_id); | 751 ContentSettingsTypeToGroupName(type) + ".managedBy", provider_id); |
722 | 752 |
723 web_ui()->CallJavascriptFunction( | 753 web_ui()->CallJavascriptFunction( |
724 "ContentSettings.setContentFilterSettingsValue", filter_settings); | 754 "ContentSettings.setContentFilterSettingsValue", filter_settings); |
725 } | 755 } |
726 | 756 |
727 void ContentSettingsHandler::UpdateMediaSettingsFromPrefs( | 757 void ContentSettingsHandler::UpdateMediaSettingsFromPrefs( |
728 ContentSettingsType type) { | 758 ContentSettingsType type) { |
729 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); | 759 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
912 entry != exceptions.end(); ++entry) { | 942 entry != exceptions.end(); ++entry) { |
913 base::DictionaryValue* dict = nullptr; | 943 base::DictionaryValue* dict = nullptr; |
914 bool valid_dict = (*entry)->GetAsDictionary(&dict); | 944 bool valid_dict = (*entry)->GetAsDictionary(&dict); |
915 DCHECK(valid_dict); | 945 DCHECK(valid_dict); |
916 | 946 |
917 std::string origin; | 947 std::string origin; |
918 std::string setting; | 948 std::string setting; |
919 dict->GetString(kOrigin, &origin); | 949 dict->GetString(kOrigin, &origin); |
920 dict->GetString(kSetting, &setting); | 950 dict->GetString(kSetting, &setting); |
921 | 951 |
952 ContentSetting setting_type = CONTENT_SETTING_DEFAULT; | |
953 bool result = | |
954 content_settings::ContentSettingFromString(setting, &setting_type); | |
955 DCHECK(result); | |
956 | |
922 settings.exceptions.push_back(MediaException( | 957 settings.exceptions.push_back(MediaException( |
923 ContentSettingsPattern::FromString(origin), | 958 ContentSettingsPattern::FromString(origin), |
924 ContentSettingFromString(setting))); | 959 setting_type)); |
925 } | 960 } |
926 | 961 |
927 PepperFlashContentSettingsUtils::SortMediaExceptions( | 962 PepperFlashContentSettingsUtils::SortMediaExceptions( |
928 &settings.exceptions); | 963 &settings.exceptions); |
929 | 964 |
930 settings.exceptions_initialized = true; | 965 settings.exceptions_initialized = true; |
931 UpdateFlashMediaLinksVisibility(type); | 966 UpdateFlashMediaLinksVisibility(type); |
932 } | 967 } |
933 | 968 |
934 void ContentSettingsHandler::UpdateMIDISysExExceptionsView() { | 969 void ContentSettingsHandler::UpdateMIDISysExExceptionsView() { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1010 } | 1045 } |
1011 case content::HostZoomMap::ZOOM_CHANGED_FOR_SCHEME_AND_HOST: | 1046 case content::HostZoomMap::ZOOM_CHANGED_FOR_SCHEME_AND_HOST: |
1012 // These are not stored in preferences and get cleared on next browser | 1047 // These are not stored in preferences and get cleared on next browser |
1013 // start. Therefore, we don't care for them. | 1048 // start. Therefore, we don't care for them. |
1014 continue; | 1049 continue; |
1015 case content::HostZoomMap::PAGE_SCALE_IS_ONE_CHANGED: | 1050 case content::HostZoomMap::PAGE_SCALE_IS_ONE_CHANGED: |
1016 continue; | 1051 continue; |
1017 case content::HostZoomMap::ZOOM_CHANGED_TEMPORARY_ZOOM: | 1052 case content::HostZoomMap::ZOOM_CHANGED_TEMPORARY_ZOOM: |
1018 NOTREACHED(); | 1053 NOTREACHED(); |
1019 } | 1054 } |
1020 exception->SetString(kSetting, | 1055 |
1021 ContentSettingToString(CONTENT_SETTING_DEFAULT)); | 1056 std::string setting_string; |
1057 bool return_value = content_settings::ContentSettingToString( | |
1058 CONTENT_SETTING_DEFAULT, &setting_string); | |
1059 DCHECK(return_value); | |
1060 | |
1061 exception->SetString(kSetting, setting_string); | |
1022 | 1062 |
1023 // Calculate the zoom percent from the factor. Round up to the nearest whole | 1063 // Calculate the zoom percent from the factor. Round up to the nearest whole |
1024 // number. | 1064 // number. |
1025 int zoom_percent = static_cast<int>( | 1065 int zoom_percent = static_cast<int>( |
1026 content::ZoomLevelToZoomFactor(i->zoom_level) * 100 + 0.5); | 1066 content::ZoomLevelToZoomFactor(i->zoom_level) * 100 + 0.5); |
1027 exception->SetString( | 1067 exception->SetString( |
1028 kZoom, | 1068 kZoom, |
1029 l10n_util::GetStringFUTF16(IDS_ZOOM_PERCENT, | 1069 l10n_util::GetStringFUTF16(IDS_ZOOM_PERCENT, |
1030 base::IntToString16(zoom_percent))); | 1070 base::IntToString16(zoom_percent))); |
1031 exception->SetString(kSource, kPreferencesSource); | 1071 exception->SetString(kSource, kPreferencesSource); |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1314 | 1354 |
1315 void ContentSettingsHandler::SetContentFilter(const base::ListValue* args) { | 1355 void ContentSettingsHandler::SetContentFilter(const base::ListValue* args) { |
1316 DCHECK_EQ(2U, args->GetSize()); | 1356 DCHECK_EQ(2U, args->GetSize()); |
1317 std::string group, setting; | 1357 std::string group, setting; |
1318 if (!(args->GetString(0, &group) && | 1358 if (!(args->GetString(0, &group) && |
1319 args->GetString(1, &setting))) { | 1359 args->GetString(1, &setting))) { |
1320 NOTREACHED(); | 1360 NOTREACHED(); |
1321 return; | 1361 return; |
1322 } | 1362 } |
1323 | 1363 |
1324 ContentSetting default_setting = ContentSettingFromString(setting); | 1364 ContentSetting default_setting = CONTENT_SETTING_DEFAULT; |
1365 bool result = | |
1366 content_settings::ContentSettingFromString(setting, &default_setting); | |
1367 DCHECK(result); | |
1368 | |
1325 ContentSettingsType content_type = ContentSettingsTypeFromGroupName(group); | 1369 ContentSettingsType content_type = ContentSettingsTypeFromGroupName(group); |
1326 Profile* profile = Profile::FromWebUI(web_ui()); | 1370 Profile* profile = Profile::FromWebUI(web_ui()); |
1327 | 1371 |
1328 #if defined(OS_CHROMEOS) | 1372 #if defined(OS_CHROMEOS) |
1329 // ChromeOS special case : in Guest mode settings are opened in Incognito | 1373 // ChromeOS special case : in Guest mode settings are opened in Incognito |
1330 // mode, so we need original profile to actually modify settings. | 1374 // mode, so we need original profile to actually modify settings. |
1331 if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) | 1375 if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) |
1332 profile = profile->GetOriginalProfile(); | 1376 profile = profile->GetOriginalProfile(); |
1333 #endif | 1377 #endif |
1334 | 1378 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1437 NOTREACHED(); | 1481 NOTREACHED(); |
1438 } else { | 1482 } else { |
1439 HostContentSettingsMap* settings_map = | 1483 HostContentSettingsMap* settings_map = |
1440 mode == "normal" ? GetContentSettingsMap() : | 1484 mode == "normal" ? GetContentSettingsMap() : |
1441 GetOTRContentSettingsMap(); | 1485 GetOTRContentSettingsMap(); |
1442 | 1486 |
1443 // The settings map could be null if the mode was OTR but the OTR profile | 1487 // The settings map could be null if the mode was OTR but the OTR profile |
1444 // got destroyed before we received this message. | 1488 // got destroyed before we received this message. |
1445 if (!settings_map) | 1489 if (!settings_map) |
1446 return; | 1490 return; |
1491 | |
1492 ContentSetting setting_type = CONTENT_SETTING_DEFAULT; | |
1493 bool result = | |
1494 content_settings::ContentSettingFromString(setting, &setting_type); | |
1495 DCHECK(result); | |
1496 | |
1447 settings_map->SetContentSetting(ContentSettingsPattern::FromString(pattern), | 1497 settings_map->SetContentSetting(ContentSettingsPattern::FromString(pattern), |
1448 ContentSettingsPattern::Wildcard(), | 1498 ContentSettingsPattern::Wildcard(), |
1449 type, | 1499 type, |
1450 std::string(), | 1500 std::string(), |
1451 ContentSettingFromString(setting)); | 1501 setting_type); |
1452 } | 1502 } |
1453 } | 1503 } |
1454 | 1504 |
1455 void ContentSettingsHandler::CheckExceptionPatternValidity( | 1505 void ContentSettingsHandler::CheckExceptionPatternValidity( |
1456 const base::ListValue* args) { | 1506 const base::ListValue* args) { |
1457 std::string type_string; | 1507 std::string type_string; |
1458 CHECK(args->GetString(0, &type_string)); | 1508 CHECK(args->GetString(0, &type_string)); |
1459 std::string mode_string; | 1509 std::string mode_string; |
1460 CHECK(args->GetString(1, &mode_string)); | 1510 CHECK(args->GetString(1, &mode_string)); |
1461 std::string pattern_string; | 1511 std::string pattern_string; |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1622 | 1672 |
1623 // Exceptions apply only when the feature is enabled. | 1673 // Exceptions apply only when the feature is enabled. |
1624 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); | 1674 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); |
1625 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); | 1675 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); |
1626 web_ui()->CallJavascriptFunction( | 1676 web_ui()->CallJavascriptFunction( |
1627 "ContentSettings.enableProtectedContentExceptions", | 1677 "ContentSettings.enableProtectedContentExceptions", |
1628 base::FundamentalValue(enable_exceptions)); | 1678 base::FundamentalValue(enable_exceptions)); |
1629 } | 1679 } |
1630 | 1680 |
1631 } // namespace options | 1681 } // namespace options |
OLD | NEW |