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

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

Issue 1962163002: Revert of [Chrome Settings UI] If User Exceptions are not allowed, prevent editing / viewing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 860 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 content_settings::ContentSettingToString(default_setting); 871 content_settings::ContentSettingToString(default_setting);
872 DCHECK(!setting_string.empty()); 872 DCHECK(!setting_string.empty());
873 873
874 filter_settings.SetString(ContentSettingsTypeToGroupName(type) + ".value", 874 filter_settings.SetString(ContentSettingsTypeToGroupName(type) + ".value",
875 setting_string); 875 setting_string);
876 filter_settings.SetString( 876 filter_settings.SetString(
877 ContentSettingsTypeToGroupName(type) + ".managedBy", provider_id); 877 ContentSettingsTypeToGroupName(type) + ".managedBy", provider_id);
878 878
879 web_ui()->CallJavascriptFunction( 879 web_ui()->CallJavascriptFunction(
880 "ContentSettings.setContentFilterSettingsValue", filter_settings); 880 "ContentSettings.setContentFilterSettingsValue", filter_settings);
881
882 // We assume that special cases covered above to get |provider_id| are not
883 // needed in AreUserExceptionsAllowedForType().
884 bool maybe_enable_exceptions =
885 GetContentSettingsMap()->AreUserExceptionsAllowedForType(type);
886
887 web_ui()->CallJavascriptFunction(
888 "ContentSettings.setUserExceptionsAllowed",
889 base::StringValue(ContentSettingsTypeToGroupName(type)),
890 base::FundamentalValue(maybe_enable_exceptions));
891 } 881 }
892 882
893 void ContentSettingsHandler::UpdateMediaSettingsFromPrefs( 883 void ContentSettingsHandler::UpdateMediaSettingsFromPrefs(
894 ContentSettingsType type) { 884 ContentSettingsType type) {
895 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); 885 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui()));
896 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type); 886 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type);
897 std::string policy_pref = (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) 887 std::string policy_pref = (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)
898 ? prefs::kAudioCaptureAllowed 888 ? prefs::kAudioCaptureAllowed
899 : prefs::kVideoCaptureAllowed; 889 : prefs::kVideoCaptureAllowed;
900 890
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 std::string(), 956 std::string(),
967 &all_settings); 957 &all_settings);
968 958
969 // Group geolocation settings by primary_pattern. 959 // Group geolocation settings by primary_pattern.
970 site_settings::AllPatternsSettings all_patterns_settings; 960 site_settings::AllPatternsSettings all_patterns_settings;
971 for (ContentSettingsForOneType::iterator i = all_settings.begin(); 961 for (ContentSettingsForOneType::iterator i = all_settings.begin();
972 i != all_settings.end(); ++i) { 962 i != all_settings.end(); ++i) {
973 // Don't add default settings. 963 // Don't add default settings.
974 if (i->primary_pattern == ContentSettingsPattern::Wildcard() && 964 if (i->primary_pattern == ContentSettingsPattern::Wildcard() &&
975 i->secondary_pattern == ContentSettingsPattern::Wildcard() && 965 i->secondary_pattern == ContentSettingsPattern::Wildcard() &&
976 i->source != site_settings::kPreferencesSource) { 966 i
967 ->source != site_settings::kPreferencesSource) {
977 continue; 968 continue;
978 } 969 }
979 all_patterns_settings[std::make_pair(i->primary_pattern, i->source)] 970 all_patterns_settings[std::make_pair(i->primary_pattern, i->source)]
980 [i->secondary_pattern] = i->setting; 971 [i->secondary_pattern] = i->setting;
981 } 972 }
982 973
983 base::ListValue exceptions; 974 base::ListValue exceptions;
984 AddExceptionsGrantedByHostedApps( 975 AddExceptionsGrantedByHostedApps(
985 profile, 976 profile,
986 HostedAppHasPermission<APIPermission::kGeolocation>, 977 HostedAppHasPermission<APIPermission::kGeolocation>,
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
1477 const ExceptionsInfoMap& exceptions_info_map = GetExceptionsInfoMap(); 1468 const ExceptionsInfoMap& exceptions_info_map = GetExceptionsInfoMap();
1478 const auto& it = exceptions_info_map.find(content_type); 1469 const auto& it = exceptions_info_map.find(content_type);
1479 if (it != exceptions_info_map.end()) 1470 if (it != exceptions_info_map.end())
1480 content::RecordAction(it->second.uma); 1471 content::RecordAction(it->second.uma);
1481 } 1472 }
1482 1473
1483 void ContentSettingsHandler::RemoveException(const base::ListValue* args) { 1474 void ContentSettingsHandler::RemoveException(const base::ListValue* args) {
1484 std::string type_string; 1475 std::string type_string;
1485 CHECK(args->GetString(0, &type_string)); 1476 CHECK(args->GetString(0, &type_string));
1486 1477
1487 ContentSettingsType type = ContentSettingsTypeFromGroupName(type_string);
1488
1489 // If user exceptions are disabled for |type|, don't remove.
1490 if (!GetContentSettingsMap()->AreUserExceptionsAllowedForType(type))
1491 return;
1492
1493 // Zoom levels are no actual content type so we need to handle them 1478 // Zoom levels are no actual content type so we need to handle them
1494 // separately. They would not be recognized by 1479 // separately. They would not be recognized by
1495 // ContentSettingsTypeFromGroupName. 1480 // ContentSettingsTypeFromGroupName.
1496 if (type_string == kZoomContentType) { 1481 if (type_string == kZoomContentType) {
1497 RemoveZoomLevelException(args); 1482 RemoveZoomLevelException(args);
1498 return; 1483 return;
1499 } 1484 }
1500 1485
1501 const ChooserTypeNameEntry* chooser_type = 1486 const ChooserTypeNameEntry* chooser_type =
1502 ChooserTypeFromGroupName(type_string); 1487 ChooserTypeFromGroupName(type_string);
1503 if (chooser_type) { 1488 if (chooser_type) {
1504 RemoveChooserException(chooser_type, args); 1489 RemoveChooserException(chooser_type, args);
1505 return; 1490 return;
1506 } 1491 }
1507 1492
1493 ContentSettingsType type = ContentSettingsTypeFromGroupName(type_string);
1508 RemoveExceptionFromHostContentSettingsMap(args, type); 1494 RemoveExceptionFromHostContentSettingsMap(args, type);
1509 1495
1510 WebSiteSettingsUmaUtil::LogPermissionChange( 1496 WebSiteSettingsUmaUtil::LogPermissionChange(
1511 type, ContentSetting::CONTENT_SETTING_DEFAULT); 1497 type, ContentSetting::CONTENT_SETTING_DEFAULT);
1512 } 1498 }
1513 1499
1514 void ContentSettingsHandler::SetException(const base::ListValue* args) { 1500 void ContentSettingsHandler::SetException(const base::ListValue* args) {
1515 std::string type_string; 1501 std::string type_string;
1516 CHECK(args->GetString(0, &type_string)); 1502 CHECK(args->GetString(0, &type_string));
1517 std::string mode; 1503 std::string mode;
1518 CHECK(args->GetString(1, &mode)); 1504 CHECK(args->GetString(1, &mode));
1519 std::string pattern; 1505 std::string pattern;
1520 CHECK(args->GetString(2, &pattern)); 1506 CHECK(args->GetString(2, &pattern));
1521 std::string setting; 1507 std::string setting;
1522 CHECK(args->GetString(3, &setting)); 1508 CHECK(args->GetString(3, &setting));
1523 1509
1524 ContentSettingsType type = ContentSettingsTypeFromGroupName(type_string); 1510 ContentSettingsType type = ContentSettingsTypeFromGroupName(type_string);
1525 1511
1526 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION || 1512 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION ||
1527 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || 1513 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC ||
1528 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) { 1514 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) {
1529 NOTREACHED(); 1515 NOTREACHED();
1530 } else { 1516 } else {
1531 // If user exceptions are disabled for |type|, don't set.
1532 if (!GetContentSettingsMap()->AreUserExceptionsAllowedForType(type))
1533 return;
1534
1535 HostContentSettingsMap* settings_map = 1517 HostContentSettingsMap* settings_map =
1536 mode == "normal" ? GetContentSettingsMap() : 1518 mode == "normal" ? GetContentSettingsMap() :
1537 GetOTRContentSettingsMap(); 1519 GetOTRContentSettingsMap();
1538 1520
1539 // The settings map could be null if the mode was OTR but the OTR profile 1521 // The settings map could be null if the mode was OTR but the OTR profile
1540 // got destroyed before we received this message. 1522 // got destroyed before we received this message.
1541 if (!settings_map) 1523 if (!settings_map)
1542 return; 1524 return;
1543 1525
1544 ContentSetting setting_type; 1526 ContentSetting setting_type;
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1723 1705
1724 // Exceptions apply only when the feature is enabled. 1706 // Exceptions apply only when the feature is enabled.
1725 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); 1707 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui()));
1726 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); 1708 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM);
1727 web_ui()->CallJavascriptFunction( 1709 web_ui()->CallJavascriptFunction(
1728 "ContentSettings.enableProtectedContentExceptions", 1710 "ContentSettings.enableProtectedContentExceptions",
1729 base::FundamentalValue(enable_exceptions)); 1711 base::FundamentalValue(enable_exceptions));
1730 } 1712 }
1731 1713
1732 } // namespace options 1714 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/content_settings_exceptions_area.js ('k') | ui/webui/resources/js/cr/ui/array_data_model.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698