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

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

Issue 2298283002: Site Settings Desktop: Support adding exceptions for incognito mode. (Closed)
Patch Set: Address feedback Created 4 years, 3 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 929 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS); 940 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
941 } 941 }
942 942
943 void ContentSettingsHandler::CompareMediaExceptionsWithFlash( 943 void ContentSettingsHandler::CompareMediaExceptionsWithFlash(
944 ContentSettingsType type) { 944 ContentSettingsType type) {
945 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type); 945 MediaSettingsInfo::ForOneType& settings = media_settings_->forType(type);
946 HostContentSettingsMap* settings_map = 946 HostContentSettingsMap* settings_map =
947 HostContentSettingsMapFactory::GetForProfile(GetProfile()); 947 HostContentSettingsMapFactory::GetForProfile(GetProfile());
948 948
949 base::ListValue exceptions; 949 base::ListValue exceptions;
950 site_settings::GetExceptionsFromHostContentSettingsMap(settings_map, type, 950 site_settings::GetExceptionsFromHostContentSettingsMap(
951 web_ui(), &exceptions); 951 settings_map, type,
952 web_ui(),
953 false, // Incognito.
dschuyler 2016/09/01 23:13:49 We can use /* */ in the parameter list. That may a
Finnur 2016/09/02 15:44:14 Done.
954 &exceptions);
952 955
953 settings.exceptions.clear(); 956 settings.exceptions.clear();
954 for (base::ListValue::const_iterator entry = exceptions.begin(); 957 for (base::ListValue::const_iterator entry = exceptions.begin();
955 entry != exceptions.end(); ++entry) { 958 entry != exceptions.end(); ++entry) {
956 base::DictionaryValue* dict = nullptr; 959 base::DictionaryValue* dict = nullptr;
957 bool valid_dict = (*entry)->GetAsDictionary(&dict); 960 bool valid_dict = (*entry)->GetAsDictionary(&dict);
958 DCHECK(valid_dict); 961 DCHECK(valid_dict);
959 962
960 std::string origin; 963 std::string origin;
961 std::string setting; 964 std::string setting;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 base::StringValue type_string(kZoomContentType); 1088 base::StringValue type_string(kZoomContentType);
1086 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions", 1089 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions",
1087 type_string, zoom_levels_exceptions); 1090 type_string, zoom_levels_exceptions);
1088 } 1091 }
1089 1092
1090 void ContentSettingsHandler::UpdateExceptionsViewFromHostContentSettingsMap( 1093 void ContentSettingsHandler::UpdateExceptionsViewFromHostContentSettingsMap(
1091 ContentSettingsType type) { 1094 ContentSettingsType type) {
1092 base::ListValue exceptions; 1095 base::ListValue exceptions;
1093 HostContentSettingsMap* settings_map = 1096 HostContentSettingsMap* settings_map =
1094 HostContentSettingsMapFactory::GetForProfile(GetProfile()); 1097 HostContentSettingsMapFactory::GetForProfile(GetProfile());
1095 site_settings::GetExceptionsFromHostContentSettingsMap(settings_map, type, 1098 site_settings::GetExceptionsFromHostContentSettingsMap(
1096 web_ui(), &exceptions); 1099 settings_map, type,
1100 web_ui(),
1101 false, // Incognito.
1102 &exceptions);
1097 base::StringValue type_string( 1103 base::StringValue type_string(
1098 site_settings::ContentSettingsTypeToGroupName(type)); 1104 site_settings::ContentSettingsTypeToGroupName(type));
1099 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions", 1105 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions",
1100 1106
1101 type_string, exceptions); 1107 type_string, exceptions);
1102 1108
1103 UpdateExceptionsViewFromOTRHostContentSettingsMap(type); 1109 UpdateExceptionsViewFromOTRHostContentSettingsMap(type);
1104 1110
1105 // Fullscreen and mouse lock have no global settings to update. 1111 // Fullscreen and mouse lock have no global settings to update.
1106 // TODO(mgiuca): Delete this after removing these content settings entirely 1112 // TODO(mgiuca): Delete this after removing these content settings entirely
(...skipping 15 matching lines...) Expand all
1122 } 1128 }
1123 1129
1124 void ContentSettingsHandler::UpdateExceptionsViewFromOTRHostContentSettingsMap( 1130 void ContentSettingsHandler::UpdateExceptionsViewFromOTRHostContentSettingsMap(
1125 ContentSettingsType type) { 1131 ContentSettingsType type) {
1126 const HostContentSettingsMap* otr_settings_map = 1132 const HostContentSettingsMap* otr_settings_map =
1127 HostContentSettingsMapFactory::GetForProfile(GetOTRProfile()); 1133 HostContentSettingsMapFactory::GetForProfile(GetOTRProfile());
1128 if (!otr_settings_map) 1134 if (!otr_settings_map)
1129 return; 1135 return;
1130 base::ListValue exceptions; 1136 base::ListValue exceptions;
1131 site_settings::GetExceptionsFromHostContentSettingsMap( 1137 site_settings::GetExceptionsFromHostContentSettingsMap(
1132 otr_settings_map, type, web_ui(), &exceptions); 1138 otr_settings_map,
1139 type,
1140 web_ui(),
1141 true, // Incognito.
1142 &exceptions);
1133 base::StringValue type_string( 1143 base::StringValue type_string(
1134 site_settings::ContentSettingsTypeToGroupName(type)); 1144 site_settings::ContentSettingsTypeToGroupName(type));
1135 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setOTRExceptions", 1145 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setOTRExceptions",
1136 type_string, exceptions); 1146 type_string, exceptions);
1137 } 1147 }
1138 1148
1139 void ContentSettingsHandler::RemoveExceptionFromHostContentSettingsMap( 1149 void ContentSettingsHandler::RemoveExceptionFromHostContentSettingsMap(
1140 const base::ListValue* args, 1150 const base::ListValue* args,
1141 ContentSettingsType type) { 1151 ContentSettingsType type) {
1142 std::string mode; 1152 std::string mode;
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
1504 1514
1505 // Exceptions apply only when the feature is enabled. 1515 // Exceptions apply only when the feature is enabled.
1506 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); 1516 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui()));
1507 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); 1517 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM);
1508 web_ui()->CallJavascriptFunctionUnsafe( 1518 web_ui()->CallJavascriptFunctionUnsafe(
1509 "ContentSettings.enableProtectedContentExceptions", 1519 "ContentSettings.enableProtectedContentExceptions",
1510 base::FundamentalValue(enable_exceptions)); 1520 base::FundamentalValue(enable_exceptions));
1511 } 1521 }
1512 1522
1513 } // namespace options 1523 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698