| 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 <utility> | 10 #include <utility> |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 bool HostedAppHasPermission(const extensions::Extension& extension, | 327 bool HostedAppHasPermission(const extensions::Extension& extension, |
| 328 content::BrowserContext* /* context */) { | 328 content::BrowserContext* /* context */) { |
| 329 return extension.is_hosted_app() && | 329 return extension.is_hosted_app() && |
| 330 extension.permissions_data()->HasAPIPermission(permission); | 330 extension.permissions_data()->HasAPIPermission(permission); |
| 331 } | 331 } |
| 332 | 332 |
| 333 // Add an "Allow"-entry to the list of |exceptions| for a |url_pattern| from | 333 // Add an "Allow"-entry to the list of |exceptions| for a |url_pattern| from |
| 334 // the web extent of a hosted |app|. | 334 // the web extent of a hosted |app|. |
| 335 void AddExceptionForHostedApp(const std::string& url_pattern, | 335 void AddExceptionForHostedApp(const std::string& url_pattern, |
| 336 const extensions::Extension& app, base::ListValue* exceptions) { | 336 const extensions::Extension& app, base::ListValue* exceptions) { |
| 337 base::DictionaryValue* exception = new base::DictionaryValue(); | 337 std::unique_ptr<base::DictionaryValue> exception(new base::DictionaryValue()); |
| 338 | 338 |
| 339 std::string setting_string = | 339 std::string setting_string = |
| 340 content_settings::ContentSettingToString(CONTENT_SETTING_ALLOW); | 340 content_settings::ContentSettingToString(CONTENT_SETTING_ALLOW); |
| 341 DCHECK(!setting_string.empty()); | 341 DCHECK(!setting_string.empty()); |
| 342 | 342 |
| 343 exception->SetString(site_settings::kSetting, setting_string); | 343 exception->SetString(site_settings::kSetting, setting_string); |
| 344 exception->SetString(site_settings::kOrigin, url_pattern); | 344 exception->SetString(site_settings::kOrigin, url_pattern); |
| 345 exception->SetString(site_settings::kEmbeddingOrigin, url_pattern); | 345 exception->SetString(site_settings::kEmbeddingOrigin, url_pattern); |
| 346 exception->SetString(site_settings::kSource, "HostedApp"); | 346 exception->SetString(site_settings::kSource, "HostedApp"); |
| 347 exception->SetString(kAppName, app.name()); | 347 exception->SetString(kAppName, app.name()); |
| 348 exception->SetString(kAppId, app.id()); | 348 exception->SetString(kAppId, app.id()); |
| 349 exceptions->Append(exception); | 349 exceptions->Append(std::move(exception)); |
| 350 } | 350 } |
| 351 | 351 |
| 352 // Asks the |profile| for hosted apps which have the |permission| set, and | 352 // Asks the |profile| for hosted apps which have the |permission| set, and |
| 353 // adds their web extent and launch URL to the |exceptions| list. | 353 // adds their web extent and launch URL to the |exceptions| list. |
| 354 void AddExceptionsGrantedByHostedApps(content::BrowserContext* context, | 354 void AddExceptionsGrantedByHostedApps(content::BrowserContext* context, |
| 355 AppFilter app_filter, | 355 AppFilter app_filter, |
| 356 base::ListValue* exceptions) { | 356 base::ListValue* exceptions) { |
| 357 const extensions::ExtensionSet& extensions = | 357 const extensions::ExtensionSet& extensions = |
| 358 extensions::ExtensionRegistry::Get(context)->enabled_extensions(); | 358 extensions::ExtensionRegistry::Get(context)->enabled_extensions(); |
| 359 for (extensions::ExtensionSet::const_iterator extension = extensions.begin(); | 359 for (extensions::ExtensionSet::const_iterator extension = extensions.begin(); |
| (...skipping 1285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1645 | 1645 |
| 1646 // Exceptions apply only when the feature is enabled. | 1646 // Exceptions apply only when the feature is enabled. |
| 1647 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); | 1647 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); |
| 1648 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); | 1648 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); |
| 1649 web_ui()->CallJavascriptFunctionUnsafe( | 1649 web_ui()->CallJavascriptFunctionUnsafe( |
| 1650 "ContentSettings.enableProtectedContentExceptions", | 1650 "ContentSettings.enableProtectedContentExceptions", |
| 1651 base::FundamentalValue(enable_exceptions)); | 1651 base::FundamentalValue(enable_exceptions)); |
| 1652 } | 1652 } |
| 1653 | 1653 |
| 1654 } // namespace options | 1654 } // namespace options |
| OLD | NEW |