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

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

Issue 243803004: options: loosen up ContentSettingsHandler::RemoveException() as the JS sometimes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: asdf Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 // in a HostContentSettingsMap-controlled exceptions table (e.g., cookies). 162 // in a HostContentSettingsMap-controlled exceptions table (e.g., cookies).
163 // Ownership of the pointer is passed to the caller. 163 // Ownership of the pointer is passed to the caller.
164 base::DictionaryValue* GetExceptionForPage( 164 base::DictionaryValue* GetExceptionForPage(
165 const ContentSettingsPattern& pattern, 165 const ContentSettingsPattern& pattern,
166 const ContentSettingsPattern& secondary_pattern, 166 const ContentSettingsPattern& secondary_pattern,
167 const ContentSetting& setting, 167 const ContentSetting& setting,
168 const std::string& provider_name) { 168 const std::string& provider_name) {
169 base::DictionaryValue* exception = new base::DictionaryValue(); 169 base::DictionaryValue* exception = new base::DictionaryValue();
170 exception->SetString(kOrigin, pattern.ToString()); 170 exception->SetString(kOrigin, pattern.ToString());
171 exception->SetString(kEmbeddingOrigin, 171 exception->SetString(kEmbeddingOrigin,
172 secondary_pattern == ContentSettingsPattern::Wildcard() 172 secondary_pattern == ContentSettingsPattern::Wildcard() ?
173 ? std::string() 173 std::string() :
174 : secondary_pattern.ToString()); 174 secondary_pattern.ToString());
175 exception->SetString(kSetting, ContentSettingToString(setting)); 175 exception->SetString(kSetting, ContentSettingToString(setting));
176 exception->SetString(kSource, provider_name); 176 exception->SetString(kSource, provider_name);
177 return exception; 177 return exception;
178 } 178 }
179 179
180 // Create a DictionaryValue* that will act as a data source for a single row 180 // Create a DictionaryValue* that will act as a data source for a single row
181 // in the Geolocation exceptions table. Ownership of the pointer is passed to 181 // in the Geolocation exceptions table. Ownership of the pointer is passed to
182 // the caller. 182 // the caller.
183 base::DictionaryValue* GetGeolocationExceptionForPage( 183 base::DictionaryValue* GetGeolocationExceptionForPage(
184 const ContentSettingsPattern& origin, 184 const ContentSettingsPattern& origin,
(...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 const base::ListValue* args, 1202 const base::ListValue* args,
1203 ContentSettingsType type) { 1203 ContentSettingsType type) {
1204 std::string mode; 1204 std::string mode;
1205 bool rv = args->GetString(1, &mode); 1205 bool rv = args->GetString(1, &mode);
1206 DCHECK(rv); 1206 DCHECK(rv);
1207 1207
1208 std::string pattern; 1208 std::string pattern;
1209 rv = args->GetString(2, &pattern); 1209 rv = args->GetString(2, &pattern);
1210 DCHECK(rv); 1210 DCHECK(rv);
1211 1211
1212 // The third argument to this handler is optional.
1212 std::string secondary_pattern; 1213 std::string secondary_pattern;
1213 rv = args->GetString(3, &secondary_pattern); 1214 if (args->GetSize() == 3U) {
1214 DCHECK(rv); 1215 rv = args->GetString(3, &secondary_pattern);
1216 DCHECK(rv);
1217 }
1215 1218
1216 HostContentSettingsMap* settings_map = 1219 HostContentSettingsMap* settings_map =
1217 mode == "normal" ? GetContentSettingsMap() : 1220 mode == "normal" ? GetContentSettingsMap() :
1218 GetOTRContentSettingsMap(); 1221 GetOTRContentSettingsMap();
1219 if (settings_map) { 1222 if (settings_map) {
1220 settings_map->SetWebsiteSetting( 1223 settings_map->SetWebsiteSetting(
1221 ContentSettingsPattern::FromString(pattern), 1224 ContentSettingsPattern::FromString(pattern),
1222 secondary_pattern.empty() 1225 secondary_pattern.empty() ?
1223 ? ContentSettingsPattern::Wildcard() 1226 ContentSettingsPattern::Wildcard() :
1224 : ContentSettingsPattern::FromString(secondary_pattern), 1227 ContentSettingsPattern::FromString(secondary_pattern),
1225 type, 1228 type,
1226 std::string(), 1229 std::string(),
1227 NULL); 1230 NULL);
1228 } 1231 }
1229 } 1232 }
1230 1233
1231 void ContentSettingsHandler::RemoveZoomLevelException( 1234 void ContentSettingsHandler::RemoveZoomLevelException(
1232 const base::ListValue* args) { 1235 const base::ListValue* args) {
1233 std::string mode; 1236 std::string mode;
1234 bool rv = args->GetString(1, &mode); 1237 bool rv = args->GetString(1, &mode);
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
1561 void ContentSettingsHandler::UpdateProtectedContentExceptionsButton() { 1564 void ContentSettingsHandler::UpdateProtectedContentExceptionsButton() {
1562 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); 1565 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
1563 // Exceptions apply only when the feature is enabled. 1566 // Exceptions apply only when the feature is enabled.
1564 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); 1567 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM);
1565 web_ui()->CallJavascriptFunction( 1568 web_ui()->CallJavascriptFunction(
1566 "ContentSettings.enableProtectedContentExceptions", 1569 "ContentSettings.enableProtectedContentExceptions",
1567 base::FundamentalValue(enable_exceptions)); 1570 base::FundamentalValue(enable_exceptions));
1568 } 1571 }
1569 1572
1570 } // namespace options 1573 } // namespace options
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698