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

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

Powered by Google App Engine
This is Rietveld 408576698