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

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

Issue 1372353004: Making structure for ContentSettings and its corresponding strings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 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 <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 {"manageHandlers", IDS_HANDLERS_MANAGE}, 345 {"manageHandlers", IDS_HANDLERS_MANAGE},
346 {"exceptionPatternHeader", IDS_EXCEPTIONS_PATTERN_HEADER}, 346 {"exceptionPatternHeader", IDS_EXCEPTIONS_PATTERN_HEADER},
347 {"exceptionBehaviorHeader", IDS_EXCEPTIONS_ACTION_HEADER}, 347 {"exceptionBehaviorHeader", IDS_EXCEPTIONS_ACTION_HEADER},
348 {"exceptionZoomHeader", IDS_EXCEPTIONS_ZOOM_HEADER}, 348 {"exceptionZoomHeader", IDS_EXCEPTIONS_ZOOM_HEADER},
349 {"embeddedOnHost", IDS_EXCEPTIONS_GEOLOCATION_EMBEDDED_ON_HOST}, 349 {"embeddedOnHost", IDS_EXCEPTIONS_GEOLOCATION_EMBEDDED_ON_HOST},
350 // Cookies filter. 350 // Cookies filter.
351 {"cookiesTabLabel", IDS_COOKIES_TAB_LABEL}, 351 {"cookiesTabLabel", IDS_COOKIES_TAB_LABEL},
352 {"cookiesHeader", IDS_COOKIES_HEADER}, 352 {"cookiesHeader", IDS_COOKIES_HEADER},
353 {"cookiesAllow", IDS_COOKIES_ALLOW_RADIO}, 353 {"cookiesAllow", IDS_COOKIES_ALLOW_RADIO},
354 {"cookiesBlock", IDS_COOKIES_BLOCK_RADIO}, 354 {"cookiesBlock", IDS_COOKIES_BLOCK_RADIO},
355 {"cookiesSession", IDS_COOKIES_SESSION_ONLY_RADIO}, 355 {"cookiesSessionOnly", IDS_COOKIES_SESSION_ONLY_RADIO},
356 {"cookiesBlock3rdParty", IDS_COOKIES_BLOCK_3RDPARTY_CHKBOX}, 356 {"cookiesBlock3rdParty", IDS_COOKIES_BLOCK_3RDPARTY_CHKBOX},
357 {"cookiesShowCookies", IDS_COOKIES_SHOW_COOKIES_BUTTON}, 357 {"cookiesShowCookies", IDS_COOKIES_SHOW_COOKIES_BUTTON},
358 {"flashStorageSettings", IDS_FLASH_STORAGE_SETTINGS}, 358 {"flashStorageSettings", IDS_FLASH_STORAGE_SETTINGS},
359 {"flashStorageUrl", IDS_FLASH_STORAGE_URL}, 359 {"flashStorageUrl", IDS_FLASH_STORAGE_URL},
360 #if defined(ENABLE_GOOGLE_NOW) 360 #if defined(ENABLE_GOOGLE_NOW)
361 {"googleGeolocationAccessEnable", 361 {"googleGeolocationAccessEnable",
362 IDS_GEOLOCATION_GOOGLE_ACCESS_ENABLE_CHKBOX}, 362 IDS_GEOLOCATION_GOOGLE_ACCESS_ENABLE_CHKBOX},
363 #endif 363 #endif
364 // Image filter. 364 // Image filter.
365 {"imagesTabLabel", IDS_IMAGES_TAB_LABEL}, 365 {"imagesTabLabel", IDS_IMAGES_TAB_LABEL},
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 ->Get(CONTENT_SETTINGS_TYPE_PLUGINS) 467 ->Get(CONTENT_SETTINGS_TYPE_PLUGINS)
468 ->default_value_pref_name()); 468 ->default_value_pref_name());
469 469
470 int default_value = CONTENT_SETTING_DEFAULT; 470 int default_value = CONTENT_SETTING_DEFAULT;
471 bool success = default_pref->GetAsInteger(&default_value); 471 bool success = default_pref->GetAsInteger(&default_value);
472 DCHECK(success); 472 DCHECK(success);
473 DCHECK_NE(CONTENT_SETTING_DEFAULT, default_value); 473 DCHECK_NE(CONTENT_SETTING_DEFAULT, default_value);
474 474
475 int plugin_ids = default_value == CONTENT_SETTING_DETECT_IMPORTANT_CONTENT ? 475 int plugin_ids = default_value == CONTENT_SETTING_DETECT_IMPORTANT_CONTENT ?
476 IDS_PLUGIN_DETECT_RECOMMENDED_RADIO : IDS_PLUGIN_DETECT_RADIO; 476 IDS_PLUGIN_DETECT_RECOMMENDED_RADIO : IDS_PLUGIN_DETECT_RADIO;
477 localized_strings->SetString("pluginsDetect", 477 localized_strings->SetString("pluginsDetectImportantContent",
478 l10n_util::GetStringUTF16(plugin_ids)); 478 l10n_util::GetStringUTF16(plugin_ids));
479 479
480 RegisterTitle(localized_strings, "contentSettingsPage", 480 RegisterTitle(localized_strings, "contentSettingsPage",
481 IDS_CONTENT_SETTINGS_TITLE); 481 IDS_CONTENT_SETTINGS_TITLE);
482 482
483 // Register titles for each of the individual settings whose exception 483 // Register titles for each of the individual settings whose exception
484 // dialogs will be processed by |ContentSettingsHandler|. 484 // dialogs will be processed by |ContentSettingsHandler|.
485 RegisterTitle(localized_strings, "cookies", 485 RegisterTitle(localized_strings, "cookies",
486 IDS_COOKIES_TAB_LABEL); 486 IDS_COOKIES_TAB_LABEL);
487 RegisterTitle(localized_strings, "images", 487 RegisterTitle(localized_strings, "images",
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 entry != exceptions.end(); ++entry) { 912 entry != exceptions.end(); ++entry) {
913 base::DictionaryValue* dict = nullptr; 913 base::DictionaryValue* dict = nullptr;
914 bool valid_dict = (*entry)->GetAsDictionary(&dict); 914 bool valid_dict = (*entry)->GetAsDictionary(&dict);
915 DCHECK(valid_dict); 915 DCHECK(valid_dict);
916 916
917 std::string origin; 917 std::string origin;
918 std::string setting; 918 std::string setting;
919 dict->GetString(kOrigin, &origin); 919 dict->GetString(kOrigin, &origin);
920 dict->GetString(kSetting, &setting); 920 dict->GetString(kSetting, &setting);
921 921
922 ContentSetting setting_type = CONTENT_SETTING_DEFAULT;
923 bool result =
924 content_settings::ContentSettingFromString(setting, &setting_type);
925 DCHECK(result);
926
922 settings.exceptions.push_back(MediaException( 927 settings.exceptions.push_back(MediaException(
923 ContentSettingsPattern::FromString(origin), 928 ContentSettingsPattern::FromString(origin),
924 ContentSettingFromString(setting))); 929 setting_type));
925 } 930 }
926 931
927 PepperFlashContentSettingsUtils::SortMediaExceptions( 932 PepperFlashContentSettingsUtils::SortMediaExceptions(
928 &settings.exceptions); 933 &settings.exceptions);
929 934
930 settings.exceptions_initialized = true; 935 settings.exceptions_initialized = true;
931 UpdateFlashMediaLinksVisibility(type); 936 UpdateFlashMediaLinksVisibility(type);
932 } 937 }
933 938
934 void ContentSettingsHandler::UpdateMIDISysExExceptionsView() { 939 void ContentSettingsHandler::UpdateMIDISysExExceptionsView() {
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 1319
1315 void ContentSettingsHandler::SetContentFilter(const base::ListValue* args) { 1320 void ContentSettingsHandler::SetContentFilter(const base::ListValue* args) {
1316 DCHECK_EQ(2U, args->GetSize()); 1321 DCHECK_EQ(2U, args->GetSize());
1317 std::string group, setting; 1322 std::string group, setting;
1318 if (!(args->GetString(0, &group) && 1323 if (!(args->GetString(0, &group) &&
1319 args->GetString(1, &setting))) { 1324 args->GetString(1, &setting))) {
1320 NOTREACHED(); 1325 NOTREACHED();
1321 return; 1326 return;
1322 } 1327 }
1323 1328
1324 ContentSetting default_setting = ContentSettingFromString(setting); 1329 ContentSetting default_setting = CONTENT_SETTING_DEFAULT;
1330 bool result =
1331 content_settings::ContentSettingFromString(setting, &default_setting);
1332 DCHECK(result);
1333
1325 ContentSettingsType content_type = ContentSettingsTypeFromGroupName(group); 1334 ContentSettingsType content_type = ContentSettingsTypeFromGroupName(group);
1326 Profile* profile = Profile::FromWebUI(web_ui()); 1335 Profile* profile = Profile::FromWebUI(web_ui());
1327 1336
1328 #if defined(OS_CHROMEOS) 1337 #if defined(OS_CHROMEOS)
1329 // ChromeOS special case : in Guest mode settings are opened in Incognito 1338 // ChromeOS special case : in Guest mode settings are opened in Incognito
1330 // mode, so we need original profile to actually modify settings. 1339 // mode, so we need original profile to actually modify settings.
1331 if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) 1340 if (user_manager::UserManager::Get()->IsLoggedInAsGuest())
1332 profile = profile->GetOriginalProfile(); 1341 profile = profile->GetOriginalProfile();
1333 #endif 1342 #endif
1334 1343
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1437 NOTREACHED(); 1446 NOTREACHED();
1438 } else { 1447 } else {
1439 HostContentSettingsMap* settings_map = 1448 HostContentSettingsMap* settings_map =
1440 mode == "normal" ? GetContentSettingsMap() : 1449 mode == "normal" ? GetContentSettingsMap() :
1441 GetOTRContentSettingsMap(); 1450 GetOTRContentSettingsMap();
1442 1451
1443 // The settings map could be null if the mode was OTR but the OTR profile 1452 // The settings map could be null if the mode was OTR but the OTR profile
1444 // got destroyed before we received this message. 1453 // got destroyed before we received this message.
1445 if (!settings_map) 1454 if (!settings_map)
1446 return; 1455 return;
1456
1457 ContentSetting setting_type = CONTENT_SETTING_DEFAULT;
1458 bool result =
1459 content_settings::ContentSettingFromString(setting, &setting_type);
1460 DCHECK(result);
1461
1447 settings_map->SetContentSetting(ContentSettingsPattern::FromString(pattern), 1462 settings_map->SetContentSetting(ContentSettingsPattern::FromString(pattern),
1448 ContentSettingsPattern::Wildcard(), 1463 ContentSettingsPattern::Wildcard(),
1449 type, 1464 type,
1450 std::string(), 1465 std::string(),
1451 ContentSettingFromString(setting)); 1466 setting_type);
1452 } 1467 }
1453 } 1468 }
1454 1469
1455 void ContentSettingsHandler::CheckExceptionPatternValidity( 1470 void ContentSettingsHandler::CheckExceptionPatternValidity(
1456 const base::ListValue* args) { 1471 const base::ListValue* args) {
1457 std::string type_string; 1472 std::string type_string;
1458 CHECK(args->GetString(0, &type_string)); 1473 CHECK(args->GetString(0, &type_string));
1459 std::string mode_string; 1474 std::string mode_string;
1460 CHECK(args->GetString(1, &mode_string)); 1475 CHECK(args->GetString(1, &mode_string));
1461 std::string pattern_string; 1476 std::string pattern_string;
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1622 1637
1623 // Exceptions apply only when the feature is enabled. 1638 // Exceptions apply only when the feature is enabled.
1624 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); 1639 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui()));
1625 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); 1640 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM);
1626 web_ui()->CallJavascriptFunction( 1641 web_ui()->CallJavascriptFunction(
1627 "ContentSettings.enableProtectedContentExceptions", 1642 "ContentSettings.enableProtectedContentExceptions",
1628 base::FundamentalValue(enable_exceptions)); 1643 base::FundamentalValue(enable_exceptions));
1629 } 1644 }
1630 1645
1631 } // namespace options 1646 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698