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

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: Fix test 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 930 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(settings_map, type,
951 web_ui(), &exceptions); 951 web_ui(), false,
stevenjb 2016/09/01 15:47:55 false /* not incognito */ here and elsewhere.
Finnur 2016/09/01 16:48:17 Done.
952 &exceptions);
952 953
953 settings.exceptions.clear(); 954 settings.exceptions.clear();
954 for (base::ListValue::const_iterator entry = exceptions.begin(); 955 for (base::ListValue::const_iterator entry = exceptions.begin();
955 entry != exceptions.end(); ++entry) { 956 entry != exceptions.end(); ++entry) {
956 base::DictionaryValue* dict = nullptr; 957 base::DictionaryValue* dict = nullptr;
957 bool valid_dict = (*entry)->GetAsDictionary(&dict); 958 bool valid_dict = (*entry)->GetAsDictionary(&dict);
958 DCHECK(valid_dict); 959 DCHECK(valid_dict);
959 960
960 std::string origin; 961 std::string origin;
961 std::string setting; 962 std::string setting;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions", 1087 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions",
1087 type_string, zoom_levels_exceptions); 1088 type_string, zoom_levels_exceptions);
1088 } 1089 }
1089 1090
1090 void ContentSettingsHandler::UpdateExceptionsViewFromHostContentSettingsMap( 1091 void ContentSettingsHandler::UpdateExceptionsViewFromHostContentSettingsMap(
1091 ContentSettingsType type) { 1092 ContentSettingsType type) {
1092 base::ListValue exceptions; 1093 base::ListValue exceptions;
1093 HostContentSettingsMap* settings_map = 1094 HostContentSettingsMap* settings_map =
1094 HostContentSettingsMapFactory::GetForProfile(GetProfile()); 1095 HostContentSettingsMapFactory::GetForProfile(GetProfile());
1095 site_settings::GetExceptionsFromHostContentSettingsMap(settings_map, type, 1096 site_settings::GetExceptionsFromHostContentSettingsMap(settings_map, type,
1096 web_ui(), &exceptions); 1097 web_ui(), false,
1098 &exceptions);
1097 base::StringValue type_string( 1099 base::StringValue type_string(
1098 site_settings::ContentSettingsTypeToGroupName(type)); 1100 site_settings::ContentSettingsTypeToGroupName(type));
1099 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions", 1101 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions",
1100 1102
1101 type_string, exceptions); 1103 type_string, exceptions);
1102 1104
1103 UpdateExceptionsViewFromOTRHostContentSettingsMap(type); 1105 UpdateExceptionsViewFromOTRHostContentSettingsMap(type);
1104 1106
1105 // Fullscreen and mouse lock have no global settings to update. 1107 // Fullscreen and mouse lock have no global settings to update.
1106 // TODO(mgiuca): Delete this after removing these content settings entirely 1108 // TODO(mgiuca): Delete this after removing these content settings entirely
(...skipping 15 matching lines...) Expand all
1122 } 1124 }
1123 1125
1124 void ContentSettingsHandler::UpdateExceptionsViewFromOTRHostContentSettingsMap( 1126 void ContentSettingsHandler::UpdateExceptionsViewFromOTRHostContentSettingsMap(
1125 ContentSettingsType type) { 1127 ContentSettingsType type) {
1126 const HostContentSettingsMap* otr_settings_map = 1128 const HostContentSettingsMap* otr_settings_map =
1127 HostContentSettingsMapFactory::GetForProfile(GetOTRProfile()); 1129 HostContentSettingsMapFactory::GetForProfile(GetOTRProfile());
1128 if (!otr_settings_map) 1130 if (!otr_settings_map)
1129 return; 1131 return;
1130 base::ListValue exceptions; 1132 base::ListValue exceptions;
1131 site_settings::GetExceptionsFromHostContentSettingsMap( 1133 site_settings::GetExceptionsFromHostContentSettingsMap(
1132 otr_settings_map, type, web_ui(), &exceptions); 1134 otr_settings_map, type, web_ui(), true, &exceptions);
1133 base::StringValue type_string( 1135 base::StringValue type_string(
1134 site_settings::ContentSettingsTypeToGroupName(type)); 1136 site_settings::ContentSettingsTypeToGroupName(type));
1135 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setOTRExceptions", 1137 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setOTRExceptions",
1136 type_string, exceptions); 1138 type_string, exceptions);
1137 } 1139 }
1138 1140
1139 void ContentSettingsHandler::RemoveExceptionFromHostContentSettingsMap( 1141 void ContentSettingsHandler::RemoveExceptionFromHostContentSettingsMap(
1140 const base::ListValue* args, 1142 const base::ListValue* args,
1141 ContentSettingsType type) { 1143 ContentSettingsType type) {
1142 std::string mode; 1144 std::string mode;
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
1504 1506
1505 // Exceptions apply only when the feature is enabled. 1507 // Exceptions apply only when the feature is enabled.
1506 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); 1508 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui()));
1507 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); 1509 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM);
1508 web_ui()->CallJavascriptFunctionUnsafe( 1510 web_ui()->CallJavascriptFunctionUnsafe(
1509 "ContentSettings.enableProtectedContentExceptions", 1511 "ContentSettings.enableProtectedContentExceptions",
1510 base::FundamentalValue(enable_exceptions)); 1512 base::FundamentalValue(enable_exceptions));
1511 } 1513 }
1512 1514
1513 } // namespace options 1515 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698