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 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 media_ui_settings.SetString("bubbleText", std::string()); | 670 media_ui_settings.SetString("bubbleText", std::string()); |
671 | 671 |
672 web_ui()->CallJavascriptFunction("ContentSettings.updateMediaUI", | 672 web_ui()->CallJavascriptFunction("ContentSettings.updateMediaUI", |
673 media_ui_settings); | 673 media_ui_settings); |
674 } | 674 } |
675 | 675 |
676 std::string ContentSettingsHandler::GetSettingDefaultFromModel( | 676 std::string ContentSettingsHandler::GetSettingDefaultFromModel( |
677 ContentSettingsType type, std::string* provider_id) { | 677 ContentSettingsType type, std::string* provider_id) { |
678 Profile* profile = Profile::FromWebUI(web_ui()); | 678 Profile* profile = Profile::FromWebUI(web_ui()); |
679 ContentSetting default_setting; | 679 ContentSetting default_setting; |
680 if (type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { | 680 default_setting = |
681 default_setting = | 681 profile->GetHostContentSettingsMap()-> |
682 DesktopNotificationServiceFactory::GetForProfile(profile)-> | 682 GetDefaultContentSetting(type, provider_id); |
683 GetDefaultContentSetting(provider_id); | |
684 } else { | |
685 default_setting = | |
686 profile->GetHostContentSettingsMap()-> | |
687 GetDefaultContentSetting(type, provider_id); | |
688 } | |
689 | 683 |
690 return ContentSettingToString(default_setting); | 684 return ContentSettingToString(default_setting); |
691 } | 685 } |
692 | 686 |
693 void ContentSettingsHandler::UpdateHandlersEnabledRadios() { | 687 void ContentSettingsHandler::UpdateHandlersEnabledRadios() { |
694 base::FundamentalValue handlers_enabled( | 688 base::FundamentalValue handlers_enabled( |
695 GetProtocolHandlerRegistry()->enabled()); | 689 GetProtocolHandlerRegistry()->enabled()); |
696 | 690 |
697 web_ui()->CallJavascriptFunction( | 691 web_ui()->CallJavascriptFunction( |
698 "ContentSettings.updateHandlersEnabledRadios", | 692 "ContentSettings.updateHandlersEnabledRadios", |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1163 std::string origin; | 1157 std::string origin; |
1164 std::string setting; | 1158 std::string setting; |
1165 bool rv = args->GetString(1, &origin); | 1159 bool rv = args->GetString(1, &origin); |
1166 DCHECK(rv); | 1160 DCHECK(rv); |
1167 rv = args->GetString(2, &setting); | 1161 rv = args->GetString(2, &setting); |
1168 DCHECK(rv); | 1162 DCHECK(rv); |
1169 ContentSetting content_setting = ContentSettingFromString(setting); | 1163 ContentSetting content_setting = ContentSettingFromString(setting); |
1170 | 1164 |
1171 DCHECK(content_setting == CONTENT_SETTING_ALLOW || | 1165 DCHECK(content_setting == CONTENT_SETTING_ALLOW || |
1172 content_setting == CONTENT_SETTING_BLOCK); | 1166 content_setting == CONTENT_SETTING_BLOCK); |
1173 DesktopNotificationServiceFactory::GetForProfile(profile)-> | 1167 profile->GetHostContentSettingsMap()->SetContentSetting( |
1174 ClearSetting(ContentSettingsPattern::FromString(origin)); | 1168 ContentSettingsPattern::FromString(origin), |
| 1169 ContentSettingsPattern::Wildcard(), |
| 1170 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
| 1171 NO_RESOURCE_IDENTIFIER, |
| 1172 CONTENT_SETTING_DEFAULT); |
1175 } | 1173 } |
1176 | 1174 |
1177 void ContentSettingsHandler::RemoveMediaException(const base::ListValue* args) { | 1175 void ContentSettingsHandler::RemoveMediaException(const base::ListValue* args) { |
1178 std::string mode; | 1176 std::string mode; |
1179 bool rv = args->GetString(1, &mode); | 1177 bool rv = args->GetString(1, &mode); |
1180 DCHECK(rv); | 1178 DCHECK(rv); |
1181 | 1179 |
1182 std::string pattern; | 1180 std::string pattern; |
1183 rv = args->GetString(2, &pattern); | 1181 rv = args->GetString(2, &pattern); |
1184 DCHECK(rv); | 1182 DCHECK(rv); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1306 ContentSettingsType content_type = ContentSettingsTypeFromGroupName(group); | 1304 ContentSettingsType content_type = ContentSettingsTypeFromGroupName(group); |
1307 Profile* profile = Profile::FromWebUI(web_ui()); | 1305 Profile* profile = Profile::FromWebUI(web_ui()); |
1308 | 1306 |
1309 #if defined(OS_CHROMEOS) | 1307 #if defined(OS_CHROMEOS) |
1310 // ChromeOS special case : in Guest mode settings are opened in Incognito | 1308 // ChromeOS special case : in Guest mode settings are opened in Incognito |
1311 // mode, so we need original profile to actually modify settings. | 1309 // mode, so we need original profile to actually modify settings. |
1312 if (chromeos::UserManager::Get()->IsLoggedInAsGuest()) | 1310 if (chromeos::UserManager::Get()->IsLoggedInAsGuest()) |
1313 profile = profile->GetOriginalProfile(); | 1311 profile = profile->GetOriginalProfile(); |
1314 #endif | 1312 #endif |
1315 | 1313 |
1316 if (content_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { | 1314 |
1317 DesktopNotificationServiceFactory::GetForProfile(profile)-> | 1315 HostContentSettingsMap* map = profile->GetHostContentSettingsMap(); |
1318 SetDefaultContentSetting(default_setting); | 1316 ApplyWhitelist(content_type, default_setting); |
1319 } else { | 1317 map->SetDefaultContentSetting(content_type, default_setting); |
1320 HostContentSettingsMap* map = profile->GetHostContentSettingsMap(); | 1318 |
1321 ApplyWhitelist(content_type, default_setting); | |
1322 map->SetDefaultContentSetting(content_type, default_setting); | |
1323 } | |
1324 switch (content_type) { | 1319 switch (content_type) { |
1325 case CONTENT_SETTINGS_TYPE_COOKIES: | 1320 case CONTENT_SETTINGS_TYPE_COOKIES: |
1326 content::RecordAction( | 1321 content::RecordAction( |
1327 UserMetricsAction("Options_DefaultCookieSettingChanged")); | 1322 UserMetricsAction("Options_DefaultCookieSettingChanged")); |
1328 break; | 1323 break; |
1329 case CONTENT_SETTINGS_TYPE_IMAGES: | 1324 case CONTENT_SETTINGS_TYPE_IMAGES: |
1330 content::RecordAction( | 1325 content::RecordAction( |
1331 UserMetricsAction("Options_DefaultImagesSettingChanged")); | 1326 UserMetricsAction("Options_DefaultImagesSettingChanged")); |
1332 break; | 1327 break; |
1333 case CONTENT_SETTINGS_TYPE_JAVASCRIPT: | 1328 case CONTENT_SETTINGS_TYPE_JAVASCRIPT: |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1570 void ContentSettingsHandler::UpdateProtectedContentExceptionsButton() { | 1565 void ContentSettingsHandler::UpdateProtectedContentExceptionsButton() { |
1571 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); | 1566 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); |
1572 // Exceptions apply only when the feature is enabled. | 1567 // Exceptions apply only when the feature is enabled. |
1573 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); | 1568 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); |
1574 web_ui()->CallJavascriptFunction( | 1569 web_ui()->CallJavascriptFunction( |
1575 "ContentSettings.enableProtectedContentExceptions", | 1570 "ContentSettings.enableProtectedContentExceptions", |
1576 base::FundamentalValue(enable_exceptions)); | 1571 base::FundamentalValue(enable_exceptions)); |
1577 } | 1572 } |
1578 | 1573 |
1579 } // namespace options | 1574 } // namespace options |
OLD | NEW |