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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <map> | 10 #include <map> |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 content::BrowserContext* GetBrowserContext(content::WebUI* web_ui) { | 198 content::BrowserContext* GetBrowserContext(content::WebUI* web_ui) { |
199 return web_ui->GetWebContents()->GetBrowserContext(); | 199 return web_ui->GetWebContents()->GetBrowserContext(); |
200 } | 200 } |
201 | 201 |
202 // Create a DictionaryValue* that will act as a data source for a single row | 202 // Create a DictionaryValue* that will act as a data source for a single row |
203 // in the Geolocation exceptions table. | 203 // in the Geolocation exceptions table. |
204 std::unique_ptr<base::DictionaryValue> GetGeolocationExceptionForPage( | 204 std::unique_ptr<base::DictionaryValue> GetGeolocationExceptionForPage( |
205 const ContentSettingsPattern& origin, | 205 const ContentSettingsPattern& origin, |
206 const ContentSettingsPattern& embedding_origin, | 206 const ContentSettingsPattern& embedding_origin, |
207 ContentSetting setting) { | 207 ContentSetting setting) { |
208 base::DictionaryValue* exception = new base::DictionaryValue(); | 208 auto exception = base::MakeUnique<base::DictionaryValue>(); |
209 | 209 |
210 std::string setting_string = | 210 std::string setting_string = |
211 content_settings::ContentSettingToString(setting); | 211 content_settings::ContentSettingToString(setting); |
212 DCHECK(!setting_string.empty()); | 212 DCHECK(!setting_string.empty()); |
213 | 213 |
214 exception->SetString(site_settings::kSetting, setting_string); | 214 exception->SetString(site_settings::kSetting, setting_string); |
215 exception->SetString(site_settings::kOrigin, origin.ToString()); | 215 exception->SetString(site_settings::kOrigin, origin.ToString()); |
216 exception->SetString( | 216 exception->SetString( |
217 site_settings::kEmbeddingOrigin, embedding_origin.ToString()); | 217 site_settings::kEmbeddingOrigin, embedding_origin.ToString()); |
218 return base::WrapUnique(exception); | 218 return exception; |
219 } | 219 } |
220 | 220 |
221 // Create a DictionaryValue* that will act as a data source for a single row | 221 // Create a DictionaryValue* that will act as a data source for a single row |
222 // in the desktop notifications exceptions table. | 222 // in the desktop notifications exceptions table. |
223 std::unique_ptr<base::DictionaryValue> GetNotificationExceptionForPage( | 223 std::unique_ptr<base::DictionaryValue> GetNotificationExceptionForPage( |
224 const ContentSettingsPattern& primary_pattern, | 224 const ContentSettingsPattern& primary_pattern, |
225 const ContentSettingsPattern& secondary_pattern, | 225 const ContentSettingsPattern& secondary_pattern, |
226 ContentSetting setting, | 226 ContentSetting setting, |
227 const std::string& provider_name) { | 227 const std::string& provider_name) { |
228 std::string embedding_origin; | 228 std::string embedding_origin; |
229 if (secondary_pattern != ContentSettingsPattern::Wildcard()) | 229 if (secondary_pattern != ContentSettingsPattern::Wildcard()) |
230 embedding_origin = secondary_pattern.ToString(); | 230 embedding_origin = secondary_pattern.ToString(); |
231 | 231 |
232 base::DictionaryValue* exception = new base::DictionaryValue(); | 232 auto exception = base::MakeUnique<base::DictionaryValue>(); |
233 | 233 |
234 std::string setting_string = | 234 std::string setting_string = |
235 content_settings::ContentSettingToString(setting); | 235 content_settings::ContentSettingToString(setting); |
236 DCHECK(!setting_string.empty()); | 236 DCHECK(!setting_string.empty()); |
237 | 237 |
238 exception->SetString(site_settings::kSetting, setting_string); | 238 exception->SetString(site_settings::kSetting, setting_string); |
239 exception->SetString(site_settings::kOrigin, primary_pattern.ToString()); | 239 exception->SetString(site_settings::kOrigin, primary_pattern.ToString()); |
240 exception->SetString(site_settings::kEmbeddingOrigin, embedding_origin); | 240 exception->SetString(site_settings::kEmbeddingOrigin, embedding_origin); |
241 exception->SetString(site_settings::kSource, provider_name); | 241 exception->SetString(site_settings::kSource, provider_name); |
242 return base::WrapUnique(exception); | 242 return exception; |
243 } | 243 } |
244 | 244 |
245 // Returns true whenever the |extension| is hosted and has |permission|. | 245 // Returns true whenever the |extension| is hosted and has |permission|. |
246 // Must have the AppFilter signature. | 246 // Must have the AppFilter signature. |
247 template <APIPermission::ID permission> | 247 template <APIPermission::ID permission> |
248 bool HostedAppHasPermission(const extensions::Extension& extension, | 248 bool HostedAppHasPermission(const extensions::Extension& extension, |
249 content::BrowserContext* /* context */) { | 249 content::BrowserContext* /* context */) { |
250 return extension.is_hosted_app() && | 250 return extension.is_hosted_app() && |
251 extension.permissions_data()->HasAPIPermission(permission); | 251 extension.permissions_data()->HasAPIPermission(permission); |
252 } | 252 } |
(...skipping 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1485 | 1485 |
1486 // Exceptions apply only when the feature is enabled. | 1486 // Exceptions apply only when the feature is enabled. |
1487 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); | 1487 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); |
1488 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); | 1488 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); |
1489 web_ui()->CallJavascriptFunctionUnsafe( | 1489 web_ui()->CallJavascriptFunctionUnsafe( |
1490 "ContentSettings.enableProtectedContentExceptions", | 1490 "ContentSettings.enableProtectedContentExceptions", |
1491 base::Value(enable_exceptions)); | 1491 base::Value(enable_exceptions)); |
1492 } | 1492 } |
1493 | 1493 |
1494 } // namespace options | 1494 } // namespace options |
OLD | NEW |