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 | |
9 #include <algorithm> | 8 #include <algorithm> |
10 #include <map> | 9 #include <map> |
| 10 #include <utility> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "base/prefs/pref_service.h" | 18 #include "base/prefs/pref_service.h" |
19 #include "base/stl_util.h" | 19 #include "base/stl_util.h" |
20 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 DCHECK(!setting_string.empty()); | 374 DCHECK(!setting_string.empty()); |
375 | 375 |
376 exception->SetString(kSetting, setting_string); | 376 exception->SetString(kSetting, setting_string); |
377 exception->SetString(kOrigin, requesting_origin.spec()); | 377 exception->SetString(kOrigin, requesting_origin.spec()); |
378 exception->SetString(kEmbeddingOrigin, embedding_origin.spec()); | 378 exception->SetString(kEmbeddingOrigin, embedding_origin.spec()); |
379 exception->SetString(kSource, provider_name); | 379 exception->SetString(kSource, provider_name); |
380 if (object) { | 380 if (object) { |
381 exception->SetString(kObjectName, name); | 381 exception->SetString(kObjectName, name); |
382 exception->Set(kObject, object->CreateDeepCopy()); | 382 exception->Set(kObject, object->CreateDeepCopy()); |
383 } | 383 } |
384 return exception.Pass(); | 384 return exception; |
385 } | 385 } |
386 | 386 |
387 // Returns true whenever the |extension| is hosted and has |permission|. | 387 // Returns true whenever the |extension| is hosted and has |permission|. |
388 // Must have the AppFilter signature. | 388 // Must have the AppFilter signature. |
389 template <APIPermission::ID permission> | 389 template <APIPermission::ID permission> |
390 bool HostedAppHasPermission(const extensions::Extension& extension, | 390 bool HostedAppHasPermission(const extensions::Extension& extension, |
391 content::BrowserContext* /* context */) { | 391 content::BrowserContext* /* context */) { |
392 return extension.is_hosted_app() && | 392 return extension.is_hosted_app() && |
393 extension.permissions_data()->HasAPIPermission(permission); | 393 extension.permissions_data()->HasAPIPermission(permission); |
394 } | 394 } |
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1177 requesting_origin, embedding_origin, source, | 1177 requesting_origin, embedding_origin, source, |
1178 sorted_objects_entry.first, sorted_objects_entry.second)); | 1178 sorted_objects_entry.first, sorted_objects_entry.second)); |
1179 } | 1179 } |
1180 } | 1180 } |
1181 } | 1181 } |
1182 } | 1182 } |
1183 | 1183 |
1184 base::ListValue exceptions; | 1184 base::ListValue exceptions; |
1185 for (auto& one_provider_exceptions : all_provider_exceptions) { | 1185 for (auto& one_provider_exceptions : all_provider_exceptions) { |
1186 for (auto& exception : one_provider_exceptions) | 1186 for (auto& exception : one_provider_exceptions) |
1187 exceptions.Append(exception.Pass()); | 1187 exceptions.Append(std::move(exception)); |
1188 } | 1188 } |
1189 | 1189 |
1190 base::StringValue type_string(chooser_type.name); | 1190 base::StringValue type_string(chooser_type.name); |
1191 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", type_string, | 1191 web_ui()->CallJavascriptFunction("ContentSettings.setExceptions", type_string, |
1192 exceptions); | 1192 exceptions); |
1193 } | 1193 } |
1194 | 1194 |
1195 void ContentSettingsHandler::UpdateZoomLevelsExceptionsView() { | 1195 void ContentSettingsHandler::UpdateZoomLevelsExceptionsView() { |
1196 base::ListValue zoom_levels_exceptions; | 1196 base::ListValue zoom_levels_exceptions; |
1197 | 1197 |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1417 if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || | 1417 if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || |
1418 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) { | 1418 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) { |
1419 auto& policy_exceptions = all_provider_exceptions | 1419 auto& policy_exceptions = all_provider_exceptions |
1420 [HostContentSettingsMap::GetProviderTypeFromSource(kPolicyProviderId)]; | 1420 [HostContentSettingsMap::GetProviderTypeFromSource(kPolicyProviderId)]; |
1421 DCHECK(policy_exceptions.empty()); | 1421 DCHECK(policy_exceptions.empty()); |
1422 GetPolicyAllowedUrls(type, &policy_exceptions); | 1422 GetPolicyAllowedUrls(type, &policy_exceptions); |
1423 } | 1423 } |
1424 | 1424 |
1425 for (auto& one_provider_exceptions : all_provider_exceptions) { | 1425 for (auto& one_provider_exceptions : all_provider_exceptions) { |
1426 for (auto& exception : one_provider_exceptions) | 1426 for (auto& exception : one_provider_exceptions) |
1427 exceptions->Append(exception.Pass()); | 1427 exceptions->Append(std::move(exception)); |
1428 } | 1428 } |
1429 } | 1429 } |
1430 | 1430 |
1431 void ContentSettingsHandler::RemoveExceptionFromHostContentSettingsMap( | 1431 void ContentSettingsHandler::RemoveExceptionFromHostContentSettingsMap( |
1432 const base::ListValue* args, | 1432 const base::ListValue* args, |
1433 ContentSettingsType type) { | 1433 ContentSettingsType type) { |
1434 std::string mode; | 1434 std::string mode; |
1435 bool rv = args->GetString(1, &mode); | 1435 bool rv = args->GetString(1, &mode); |
1436 DCHECK(rv); | 1436 DCHECK(rv); |
1437 | 1437 |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1799 | 1799 |
1800 // Exceptions apply only when the feature is enabled. | 1800 // Exceptions apply only when the feature is enabled. |
1801 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); | 1801 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); |
1802 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); | 1802 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); |
1803 web_ui()->CallJavascriptFunction( | 1803 web_ui()->CallJavascriptFunction( |
1804 "ContentSettings.enableProtectedContentExceptions", | 1804 "ContentSettings.enableProtectedContentExceptions", |
1805 base::FundamentalValue(enable_exceptions)); | 1805 base::FundamentalValue(enable_exceptions)); |
1806 } | 1806 } |
1807 | 1807 |
1808 } // namespace options | 1808 } // namespace options |
OLD | NEW |