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

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

Issue 2021343003: MD Site Settings: Add five new top level categories (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback and add icons Created 4 years, 6 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 namespace { 93 namespace {
94 94
95 struct ContentSettingWithExceptions { 95 struct ContentSettingWithExceptions {
96 ContentSettingWithExceptions(bool otr, UserMetricsAction action) 96 ContentSettingWithExceptions(bool otr, UserMetricsAction action)
97 : has_otr_exceptions(otr), uma(action) {} 97 : has_otr_exceptions(otr), uma(action) {}
98 bool has_otr_exceptions; 98 bool has_otr_exceptions;
99 UserMetricsAction uma; 99 UserMetricsAction uma;
100 }; 100 };
101 101
102 struct ContentSettingsTypeNameEntry {
103 ContentSettingsType type;
104 const char* name;
105 };
106
107 // Maps from the UI string to the object it represents (for sorting purposes). 102 // Maps from the UI string to the object it represents (for sorting purposes).
108 typedef std::multimap<std::string, const base::DictionaryValue*> SortedObjects; 103 typedef std::multimap<std::string, const base::DictionaryValue*> SortedObjects;
109 // Maps from a secondary URL to the set of objects it has permission to access. 104 // Maps from a secondary URL to the set of objects it has permission to access.
110 typedef std::map<GURL, SortedObjects> OneOriginObjects; 105 typedef std::map<GURL, SortedObjects> OneOriginObjects;
111 // Maps from a primary URL/source pair to a OneOriginObjects. All the mappings 106 // Maps from a primary URL/source pair to a OneOriginObjects. All the mappings
112 // in OneOriginObjects share the given primary URL and source. 107 // in OneOriginObjects share the given primary URL and source.
113 typedef std::map<std::pair<GURL, std::string>, OneOriginObjects> 108 typedef std::map<std::pair<GURL, std::string>, OneOriginObjects>
114 AllOriginObjects; 109 AllOriginObjects;
115 110
116 // The AppFilter is used in AddExceptionsGrantedByHostedApps() to choose 111 // The AppFilter is used in AddExceptionsGrantedByHostedApps() to choose
117 // extensions which should have their extent displayed. 112 // extensions which should have their extent displayed.
118 typedef bool (*AppFilter)(const extensions::Extension& app, 113 typedef bool (*AppFilter)(const extensions::Extension& app,
119 content::BrowserContext* profile); 114 content::BrowserContext* profile);
120 115
121 const char kExceptionsLearnMoreUrl[] = 116 const char kExceptionsLearnMoreUrl[] =
122 "https://support.google.com/chrome/?p=settings_manage_exceptions"; 117 "https://support.google.com/chrome/?p=settings_manage_exceptions";
123 118
124 const char kAppName[] = "appName"; 119 const char kAppName[] = "appName";
125 const char kAppId[] = "appId"; 120 const char kAppId[] = "appId";
126 const char kZoom[] = "zoom"; 121 const char kZoom[] = "zoom";
127 const char kObject[] = "object"; 122 const char kObject[] = "object";
128 const char kObjectName[] = "objectName"; 123 const char kObjectName[] = "objectName";
129 124
130 const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = {
131 {CONTENT_SETTINGS_TYPE_COOKIES, "cookies"},
132 {CONTENT_SETTINGS_TYPE_IMAGES, "images"},
133 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, "javascript"},
134 {CONTENT_SETTINGS_TYPE_PLUGINS, "plugins"},
135 {CONTENT_SETTINGS_TYPE_POPUPS, "popups"},
136 {CONTENT_SETTINGS_TYPE_GEOLOCATION, "location"},
137 {CONTENT_SETTINGS_TYPE_NOTIFICATIONS, "notifications"},
138 {CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, "auto-select-certificate"},
139 {CONTENT_SETTINGS_TYPE_FULLSCREEN, "fullscreen"},
140 {CONTENT_SETTINGS_TYPE_MOUSELOCK, "mouselock"},
141 {CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS, "register-protocol-handler"},
142 {CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, "media-stream-mic"},
143 {CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, "media-stream-camera"},
144 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, "ppapi-broker"},
145 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, "multiple-automatic-downloads"},
146 {CONTENT_SETTINGS_TYPE_MIDI_SYSEX, "midi-sysex"},
147 {CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, "push-messaging"},
148 {CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS, "ssl-cert-decisions"},
149 #if defined(OS_CHROMEOS)
150 {CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, "protectedContent"},
151 #endif
152 {CONTENT_SETTINGS_TYPE_KEYGEN, "keygen"},
153 {CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC, "background-sync"},
154 };
155
156 ChooserContextBase* GetUsbChooserContext(Profile* profile) { 125 ChooserContextBase* GetUsbChooserContext(Profile* profile) {
157 return UsbChooserContextFactory::GetForProfile(profile); 126 return UsbChooserContextFactory::GetForProfile(profile);
158 } 127 }
159 128
160 const ContentSettingsHandler::ChooserTypeNameEntry kChooserTypeGroupNames[] = { 129 const ContentSettingsHandler::ChooserTypeNameEntry kChooserTypeGroupNames[] = {
161 {CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, &GetUsbChooserContext, 130 {CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, &GetUsbChooserContext,
162 "usb-devices", "name"}, 131 "usb-devices", "name"},
163 }; 132 };
164 133
165 // A pseudo content type. We use it to display data like a content setting even 134 // A pseudo content type. We use it to display data like a content setting even
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 UserMetricsAction("Options_DefaultBackgroundSyncSettingChanged")))); 236 UserMetricsAction("Options_DefaultBackgroundSyncSettingChanged"))));
268 } 237 }
269 238
270 return exceptions_info_map; 239 return exceptions_info_map;
271 } 240 }
272 241
273 content::BrowserContext* GetBrowserContext(content::WebUI* web_ui) { 242 content::BrowserContext* GetBrowserContext(content::WebUI* web_ui) {
274 return web_ui->GetWebContents()->GetBrowserContext(); 243 return web_ui->GetWebContents()->GetBrowserContext();
275 } 244 }
276 245
277 ContentSettingsType ContentSettingsTypeFromGroupName(const std::string& name) {
278 for (size_t i = 0; i < arraysize(kContentSettingsTypeGroupNames); ++i) {
279 if (name == kContentSettingsTypeGroupNames[i].name)
280 return kContentSettingsTypeGroupNames[i].type;
281 }
282
283 NOTREACHED() << name << " is not a recognized content settings type.";
284 return CONTENT_SETTINGS_TYPE_DEFAULT;
285 }
286
287 const ContentSettingsHandler::ChooserTypeNameEntry* ChooserTypeFromGroupName( 246 const ContentSettingsHandler::ChooserTypeNameEntry* ChooserTypeFromGroupName(
288 const std::string& name) { 247 const std::string& name) {
289 for (const auto& chooser_type : kChooserTypeGroupNames) { 248 for (const auto& chooser_type : kChooserTypeGroupNames) {
290 if (chooser_type.name == name) 249 if (chooser_type.name == name)
291 return &chooser_type; 250 return &chooser_type;
292 } 251 }
293 return nullptr; 252 return nullptr;
294 } 253 }
295 254
296 // Create a DictionaryValue* that will act as a data source for a single row 255 // Create a DictionaryValue* that will act as a data source for a single row
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 provider_id = site_settings::kPolicyProviderId; 824 provider_id = site_settings::kPolicyProviderId;
866 } 825 }
867 } 826 }
868 827
869 base::DictionaryValue filter_settings; 828 base::DictionaryValue filter_settings;
870 829
871 std::string setting_string = 830 std::string setting_string =
872 content_settings::ContentSettingToString(default_setting); 831 content_settings::ContentSettingToString(default_setting);
873 DCHECK(!setting_string.empty()); 832 DCHECK(!setting_string.empty());
874 833
875 filter_settings.SetString(ContentSettingsTypeToGroupName(type) + ".value",
876 setting_string);
877 filter_settings.SetString( 834 filter_settings.SetString(
878 ContentSettingsTypeToGroupName(type) + ".managedBy", provider_id); 835 site_settings::ContentSettingsTypeToGroupName(type) + ".value",
836 setting_string);
837 filter_settings.SetString(
838 site_settings::ContentSettingsTypeToGroupName(type) + ".managedBy",
839 provider_id);
879 840
880 web_ui()->CallJavascriptFunction( 841 web_ui()->CallJavascriptFunction(
881 "ContentSettings.setContentFilterSettingsValue", filter_settings); 842 "ContentSettings.setContentFilterSettingsValue", filter_settings);
882 } 843 }
883 844
884 void ContentSettingsHandler::UpdateMediaSettingsFromPrefs( 845 void ContentSettingsHandler::UpdateMediaSettingsFromPrefs(
885 ContentSettingsType type) { 846 ContentSettingsType type) {
886 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); 847 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui()));
887 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type); 848 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type);
888 std::string policy_pref = (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) 849 std::string policy_pref = (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 ++j) { 961 ++j) {
1001 // Skip the non-embedded setting which we already added above. 962 // Skip the non-embedded setting which we already added above.
1002 if (j == parent) 963 if (j == parent)
1003 continue; 964 continue;
1004 965
1005 exceptions.Append(GetGeolocationExceptionForPage( 966 exceptions.Append(GetGeolocationExceptionForPage(
1006 primary_pattern, j->first, j->second)); 967 primary_pattern, j->first, j->second));
1007 } 968 }
1008 } 969 }
1009 970
1010 base::StringValue type_string( 971 base::StringValue type_string(site_settings::ContentSettingsTypeToGroupName(
1011 ContentSettingsTypeToGroupName(CONTENT_SETTINGS_TYPE_GEOLOCATION)); 972 CONTENT_SETTINGS_TYPE_GEOLOCATION));
1012 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", 973 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions",
1013 type_string, exceptions); 974 type_string, exceptions);
1014 975
1015 // This is mainly here to keep this function ideologically parallel to 976 // This is mainly here to keep this function ideologically parallel to
1016 // UpdateExceptionsViewFromHostContentSettingsMap(). 977 // UpdateExceptionsViewFromHostContentSettingsMap().
1017 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_GEOLOCATION); 978 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_GEOLOCATION);
1018 } 979 }
1019 980
1020 void ContentSettingsHandler::UpdateNotificationExceptionsView() { 981 void ContentSettingsHandler::UpdateNotificationExceptionsView() {
1021 Profile* profile = Profile::FromWebUI(web_ui()); 982 Profile* profile = Profile::FromWebUI(web_ui());
(...skipping 18 matching lines...) Expand all
1040 continue; 1001 continue;
1041 } 1002 }
1042 1003
1043 exceptions.Append( 1004 exceptions.Append(
1044 GetNotificationExceptionForPage(i->primary_pattern, 1005 GetNotificationExceptionForPage(i->primary_pattern,
1045 i->secondary_pattern, 1006 i->secondary_pattern,
1046 i->setting, 1007 i->setting,
1047 i->source)); 1008 i->source));
1048 } 1009 }
1049 1010
1050 base::StringValue type_string( 1011 base::StringValue type_string(site_settings::ContentSettingsTypeToGroupName(
1051 ContentSettingsTypeToGroupName(CONTENT_SETTINGS_TYPE_NOTIFICATIONS)); 1012 CONTENT_SETTINGS_TYPE_NOTIFICATIONS));
1052 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", 1013 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions",
1053 type_string, exceptions); 1014 type_string, exceptions);
1054 1015
1055 // This is mainly here to keep this function ideologically parallel to 1016 // This is mainly here to keep this function ideologically parallel to
1056 // UpdateExceptionsViewFromHostContentSettingsMap(). 1017 // UpdateExceptionsViewFromHostContentSettingsMap().
1057 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS); 1018 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
1058 } 1019 }
1059 1020
1060 void ContentSettingsHandler::CompareMediaExceptionsWithFlash( 1021 void ContentSettingsHandler::CompareMediaExceptionsWithFlash(
1061 ContentSettingsType type) { 1022 ContentSettingsType type) {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1199 base::StringValue type_string(kZoomContentType); 1160 base::StringValue type_string(kZoomContentType);
1200 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", 1161 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions",
1201 type_string, zoom_levels_exceptions); 1162 type_string, zoom_levels_exceptions);
1202 } 1163 }
1203 1164
1204 void ContentSettingsHandler::UpdateExceptionsViewFromHostContentSettingsMap( 1165 void ContentSettingsHandler::UpdateExceptionsViewFromHostContentSettingsMap(
1205 ContentSettingsType type) { 1166 ContentSettingsType type) {
1206 base::ListValue exceptions; 1167 base::ListValue exceptions;
1207 site_settings::GetExceptionsFromHostContentSettingsMap( 1168 site_settings::GetExceptionsFromHostContentSettingsMap(
1208 GetContentSettingsMap(), type, web_ui(), &exceptions); 1169 GetContentSettingsMap(), type, web_ui(), &exceptions);
1209 base::StringValue type_string(ContentSettingsTypeToGroupName(type)); 1170 base::StringValue type_string(
1171 site_settings::ContentSettingsTypeToGroupName(type));
1210 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", type_string, 1172 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", type_string,
1211 exceptions); 1173 exceptions);
1212 1174
1213 UpdateExceptionsViewFromOTRHostContentSettingsMap(type); 1175 UpdateExceptionsViewFromOTRHostContentSettingsMap(type);
1214 1176
1215 // TODO(koz): The default for fullscreen is always 'ask'. 1177 // TODO(koz): The default for fullscreen is always 'ask'.
1216 // http://crbug.com/104683 1178 // http://crbug.com/104683
1217 if (type == CONTENT_SETTINGS_TYPE_FULLSCREEN) 1179 if (type == CONTENT_SETTINGS_TYPE_FULLSCREEN)
1218 return; 1180 return;
1219 1181
1220 #if defined(OS_CHROMEOS) 1182 #if defined(OS_CHROMEOS)
1221 // Also the default for protected contents is managed in another place. 1183 // Also the default for protected contents is managed in another place.
1222 if (type == CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER) 1184 if (type == CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER)
1223 return; 1185 return;
1224 #endif 1186 #endif
1225 1187
1226 // The default may also have changed (we won't get a separate notification). 1188 // The default may also have changed (we won't get a separate notification).
1227 // If it hasn't changed, this call will be harmless. 1189 // If it hasn't changed, this call will be harmless.
1228 UpdateSettingDefaultFromModel(type); 1190 UpdateSettingDefaultFromModel(type);
1229 } 1191 }
1230 1192
1231 void ContentSettingsHandler::UpdateExceptionsViewFromOTRHostContentSettingsMap( 1193 void ContentSettingsHandler::UpdateExceptionsViewFromOTRHostContentSettingsMap(
1232 ContentSettingsType type) { 1194 ContentSettingsType type) {
1233 const HostContentSettingsMap* otr_settings_map = GetOTRContentSettingsMap(); 1195 const HostContentSettingsMap* otr_settings_map = GetOTRContentSettingsMap();
1234 if (!otr_settings_map) 1196 if (!otr_settings_map)
1235 return; 1197 return;
1236 base::ListValue exceptions; 1198 base::ListValue exceptions;
1237 site_settings::GetExceptionsFromHostContentSettingsMap( 1199 site_settings::GetExceptionsFromHostContentSettingsMap(
1238 otr_settings_map, type, web_ui(), &exceptions); 1200 otr_settings_map, type, web_ui(), &exceptions);
1239 base::StringValue type_string(ContentSettingsTypeToGroupName(type)); 1201 base::StringValue type_string(
1202 site_settings::ContentSettingsTypeToGroupName(type));
1240 web_ui()->CallJavascriptFunction("ContentSettings.setOTRExceptions", 1203 web_ui()->CallJavascriptFunction("ContentSettings.setOTRExceptions",
1241 type_string, exceptions); 1204 type_string, exceptions);
1242 } 1205 }
1243 1206
1244 void ContentSettingsHandler::GetChooserExceptionsFromProfile( 1207 void ContentSettingsHandler::GetChooserExceptionsFromProfile(
1245 bool incognito, 1208 bool incognito,
1246 const ChooserTypeNameEntry& chooser_type, 1209 const ChooserTypeNameEntry& chooser_type,
1247 base::ListValue* exceptions) { 1210 base::ListValue* exceptions) {
1248 Profile* profile = Profile::FromWebUI(web_ui()); 1211 Profile* profile = Profile::FromWebUI(web_ui());
1249 if (incognito) { 1212 if (incognito) {
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1442 args->GetString(1, &setting))) { 1405 args->GetString(1, &setting))) {
1443 NOTREACHED(); 1406 NOTREACHED();
1444 return; 1407 return;
1445 } 1408 }
1446 1409
1447 ContentSetting default_setting; 1410 ContentSetting default_setting;
1448 bool result = 1411 bool result =
1449 content_settings::ContentSettingFromString(setting, &default_setting); 1412 content_settings::ContentSettingFromString(setting, &default_setting);
1450 DCHECK(result); 1413 DCHECK(result);
1451 1414
1452 ContentSettingsType content_type = ContentSettingsTypeFromGroupName(group); 1415 ContentSettingsType content_type =
1416 site_settings::ContentSettingsTypeFromGroupName(group);
1453 Profile* profile = Profile::FromWebUI(web_ui()); 1417 Profile* profile = Profile::FromWebUI(web_ui());
1454 1418
1455 #if defined(OS_CHROMEOS) 1419 #if defined(OS_CHROMEOS)
1456 // ChromeOS special case : in Guest mode settings are opened in Incognito 1420 // ChromeOS special case : in Guest mode settings are opened in Incognito
1457 // mode, so we need original profile to actually modify settings. 1421 // mode, so we need original profile to actually modify settings.
1458 if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) 1422 if (user_manager::UserManager::Get()->IsLoggedInAsGuest())
1459 profile = profile->GetOriginalProfile(); 1423 profile = profile->GetOriginalProfile();
1460 #endif 1424 #endif
1461 1425
1462 HostContentSettingsMap* map = 1426 HostContentSettingsMap* map =
(...skipping 18 matching lines...) Expand all
1481 return; 1445 return;
1482 } 1446 }
1483 1447
1484 const ChooserTypeNameEntry* chooser_type = 1448 const ChooserTypeNameEntry* chooser_type =
1485 ChooserTypeFromGroupName(type_string); 1449 ChooserTypeFromGroupName(type_string);
1486 if (chooser_type) { 1450 if (chooser_type) {
1487 RemoveChooserException(chooser_type, args); 1451 RemoveChooserException(chooser_type, args);
1488 return; 1452 return;
1489 } 1453 }
1490 1454
1491 ContentSettingsType type = ContentSettingsTypeFromGroupName(type_string); 1455 ContentSettingsType type =
1456 site_settings::ContentSettingsTypeFromGroupName(type_string);
1492 RemoveExceptionFromHostContentSettingsMap(args, type); 1457 RemoveExceptionFromHostContentSettingsMap(args, type);
1493 1458
1494 WebSiteSettingsUmaUtil::LogPermissionChange( 1459 WebSiteSettingsUmaUtil::LogPermissionChange(
1495 type, ContentSetting::CONTENT_SETTING_DEFAULT); 1460 type, ContentSetting::CONTENT_SETTING_DEFAULT);
1496 } 1461 }
1497 1462
1498 void ContentSettingsHandler::SetException(const base::ListValue* args) { 1463 void ContentSettingsHandler::SetException(const base::ListValue* args) {
1499 std::string type_string; 1464 std::string type_string;
1500 CHECK(args->GetString(0, &type_string)); 1465 CHECK(args->GetString(0, &type_string));
1501 std::string mode; 1466 std::string mode;
1502 CHECK(args->GetString(1, &mode)); 1467 CHECK(args->GetString(1, &mode));
1503 std::string pattern; 1468 std::string pattern;
1504 CHECK(args->GetString(2, &pattern)); 1469 CHECK(args->GetString(2, &pattern));
1505 std::string setting; 1470 std::string setting;
1506 CHECK(args->GetString(3, &setting)); 1471 CHECK(args->GetString(3, &setting));
1507 1472
1508 ContentSettingsType type = ContentSettingsTypeFromGroupName(type_string); 1473 ContentSettingsType type =
1474 site_settings::ContentSettingsTypeFromGroupName(type_string);
1509 1475
1510 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION || 1476 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION ||
1511 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || 1477 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC ||
1512 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) { 1478 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) {
1513 NOTREACHED(); 1479 NOTREACHED();
1514 } else { 1480 } else {
1515 HostContentSettingsMap* settings_map = 1481 HostContentSettingsMap* settings_map =
1516 mode == "normal" ? GetContentSettingsMap() : 1482 mode == "normal" ? GetContentSettingsMap() :
1517 GetOTRContentSettingsMap(); 1483 GetOTRContentSettingsMap();
1518 1484
(...skipping 27 matching lines...) Expand all
1546 ContentSettingsPattern::FromString(pattern_string); 1512 ContentSettingsPattern::FromString(pattern_string);
1547 1513
1548 web_ui()->CallJavascriptFunction( 1514 web_ui()->CallJavascriptFunction(
1549 "ContentSettings.patternValidityCheckComplete", 1515 "ContentSettings.patternValidityCheckComplete",
1550 base::StringValue(type_string), 1516 base::StringValue(type_string),
1551 base::StringValue(mode_string), 1517 base::StringValue(mode_string),
1552 base::StringValue(pattern_string), 1518 base::StringValue(pattern_string),
1553 base::FundamentalValue(pattern.IsValid())); 1519 base::FundamentalValue(pattern.IsValid()));
1554 } 1520 }
1555 1521
1556 // static
1557 std::string ContentSettingsHandler::ContentSettingsTypeToGroupName(
1558 ContentSettingsType type) {
1559 for (size_t i = 0; i < arraysize(kContentSettingsTypeGroupNames); ++i) {
1560 if (type == kContentSettingsTypeGroupNames[i].type)
1561 return kContentSettingsTypeGroupNames[i].name;
1562 }
1563
1564 NOTREACHED();
1565 return std::string();
1566 }
1567
1568 HostContentSettingsMap* ContentSettingsHandler::GetContentSettingsMap() { 1522 HostContentSettingsMap* ContentSettingsHandler::GetContentSettingsMap() {
1569 return HostContentSettingsMapFactory::GetForProfile( 1523 return HostContentSettingsMapFactory::GetForProfile(
1570 Profile::FromWebUI(web_ui())); 1524 Profile::FromWebUI(web_ui()));
1571 } 1525 }
1572 1526
1573 ProtocolHandlerRegistry* ContentSettingsHandler::GetProtocolHandlerRegistry() { 1527 ProtocolHandlerRegistry* ContentSettingsHandler::GetProtocolHandlerRegistry() {
1574 return ProtocolHandlerRegistryFactory::GetForBrowserContext( 1528 return ProtocolHandlerRegistryFactory::GetForBrowserContext(
1575 GetBrowserContext(web_ui())); 1529 GetBrowserContext(web_ui()));
1576 } 1530 }
1577 1531
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1683 ShowFlashMediaLink(EXCEPTIONS, type, true); 1637 ShowFlashMediaLink(EXCEPTIONS, type, true);
1684 } 1638 }
1685 } 1639 }
1686 1640
1687 void ContentSettingsHandler::UpdateMediaDeviceDropdownVisibility( 1641 void ContentSettingsHandler::UpdateMediaDeviceDropdownVisibility(
1688 ContentSettingsType type) { 1642 ContentSettingsType type) {
1689 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type); 1643 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type);
1690 1644
1691 web_ui()->CallJavascriptFunction( 1645 web_ui()->CallJavascriptFunction(
1692 "ContentSettings.setDevicesMenuVisibility", 1646 "ContentSettings.setDevicesMenuVisibility",
1693 base::StringValue(ContentSettingsTypeToGroupName(type)), 1647 base::StringValue(site_settings::ContentSettingsTypeToGroupName(type)),
1694 base::FundamentalValue(!settings.policy_disable)); 1648 base::FundamentalValue(!settings.policy_disable));
1695 } 1649 }
1696 1650
1697 void ContentSettingsHandler::UpdateProtectedContentExceptionsButton() { 1651 void ContentSettingsHandler::UpdateProtectedContentExceptionsButton() {
1698 #if defined(OS_CHROMEOS) 1652 #if defined(OS_CHROMEOS)
1699 // Guests cannot modify exceptions. UIAccountTweaks will disabled the button. 1653 // Guests cannot modify exceptions. UIAccountTweaks will disabled the button.
1700 if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) 1654 if (user_manager::UserManager::Get()->IsLoggedInAsGuest())
1701 return; 1655 return;
1702 #endif 1656 #endif
1703 1657
1704 // Exceptions apply only when the feature is enabled. 1658 // Exceptions apply only when the feature is enabled.
1705 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); 1659 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui()));
1706 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); 1660 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM);
1707 web_ui()->CallJavascriptFunction( 1661 web_ui()->CallJavascriptFunction(
1708 "ContentSettings.enableProtectedContentExceptions", 1662 "ContentSettings.enableProtectedContentExceptions",
1709 base::FundamentalValue(enable_exceptions)); 1663 base::FundamentalValue(enable_exceptions));
1710 } 1664 }
1711 1665
1712 } // namespace options 1666 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698