OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 args->GetString(3, &secondary_pattern); |
Lei Zhang
2014/04/25 02:28:16
This can fail either before 3 is out of bounds or
Dan Beam
2014/04/25 04:11:08
Done.
| |
1214 DCHECK(rv); | |
1215 | 1215 |
1216 HostContentSettingsMap* settings_map = | 1216 HostContentSettingsMap* settings_map = |
1217 mode == "normal" ? GetContentSettingsMap() : | 1217 mode == "normal" ? GetContentSettingsMap() : |
1218 GetOTRContentSettingsMap(); | 1218 GetOTRContentSettingsMap(); |
1219 if (settings_map) { | 1219 if (settings_map) { |
1220 settings_map->SetWebsiteSetting( | 1220 settings_map->SetWebsiteSetting( |
1221 ContentSettingsPattern::FromString(pattern), | 1221 ContentSettingsPattern::FromString(pattern), |
1222 secondary_pattern.empty() | 1222 secondary_pattern.empty() ? |
1223 ? ContentSettingsPattern::Wildcard() | 1223 ContentSettingsPattern::Wildcard() : |
1224 : ContentSettingsPattern::FromString(secondary_pattern), | 1224 ContentSettingsPattern::FromString(secondary_pattern), |
1225 type, | 1225 type, |
1226 std::string(), | 1226 std::string(), |
1227 NULL); | 1227 NULL); |
1228 } | 1228 } |
1229 } | 1229 } |
1230 | 1230 |
1231 void ContentSettingsHandler::RemoveZoomLevelException( | 1231 void ContentSettingsHandler::RemoveZoomLevelException( |
1232 const base::ListValue* args) { | 1232 const base::ListValue* args) { |
1233 std::string mode; | 1233 std::string mode; |
1234 bool rv = args->GetString(1, &mode); | 1234 bool rv = args->GetString(1, &mode); |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1561 void ContentSettingsHandler::UpdateProtectedContentExceptionsButton() { | 1561 void ContentSettingsHandler::UpdateProtectedContentExceptionsButton() { |
1562 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); | 1562 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); |
1563 // Exceptions apply only when the feature is enabled. | 1563 // Exceptions apply only when the feature is enabled. |
1564 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); | 1564 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); |
1565 web_ui()->CallJavascriptFunction( | 1565 web_ui()->CallJavascriptFunction( |
1566 "ContentSettings.enableProtectedContentExceptions", | 1566 "ContentSettings.enableProtectedContentExceptions", |
1567 base::FundamentalValue(enable_exceptions)); | 1567 base::FundamentalValue(enable_exceptions)); |
1568 } | 1568 } |
1569 | 1569 |
1570 } // namespace options | 1570 } // namespace options |
OLD | NEW |