Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/media/protected_media_identifier_permission_context.h" | 5 #include "chrome/browser/media/protected_media_identifier_permission_context.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/user_metrics.h" | 8 #include "base/metrics/user_metrics.h" |
| 9 #include "base/strings/string_split.h" | |
| 9 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 11 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 11 #include "chrome/browser/permissions/permission_util.h" | 12 #include "chrome/browser/permissions/permission_util.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
| 14 #include "components/prefs/pref_service.h" | 15 #include "components/prefs/pref_service.h" |
| 15 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 16 #include "content/public/browser/render_frame_host.h" | 17 #include "content/public/browser/render_frame_host.h" |
| 17 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 19 #include "media/base/media_switches.h" | |
| 20 #include "net/base/url_util.h" | |
| 18 #if defined(OS_CHROMEOS) | 21 #if defined(OS_CHROMEOS) |
| 19 #include <utility> | 22 #include <utility> |
| 20 | 23 |
| 21 #include "chrome/browser/chromeos/attestation/platform_verification_dialog.h" | 24 #include "chrome/browser/chromeos/attestation/platform_verification_dialog.h" |
| 22 #include "chrome/browser/chromeos/settings/cros_settings.h" | 25 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 23 #include "chromeos/chromeos_switches.h" | 26 #include "chromeos/chromeos_switches.h" |
| 24 #include "chromeos/settings/cros_settings_names.h" | 27 #include "chromeos/settings/cros_settings_names.h" |
| 25 #include "components/pref_registry/pref_registry_syncable.h" | 28 #include "components/pref_registry/pref_registry_syncable.h" |
| 26 #include "components/user_prefs/user_prefs.h" | 29 #include "components/user_prefs/user_prefs.h" |
| 27 #include "ui/views/widget/widget.h" | 30 #include "ui/views/widget/widget.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 return CONTENT_SETTING_BLOCK; | 97 return CONTENT_SETTING_BLOCK; |
| 95 } | 98 } |
| 96 | 99 |
| 97 ContentSetting content_setting = | 100 ContentSetting content_setting = |
| 98 PermissionContextBase::GetPermissionStatusInternal( | 101 PermissionContextBase::GetPermissionStatusInternal( |
| 99 render_frame_host, requesting_origin, embedding_origin); | 102 render_frame_host, requesting_origin, embedding_origin); |
| 100 DCHECK(content_setting == CONTENT_SETTING_ALLOW || | 103 DCHECK(content_setting == CONTENT_SETTING_ALLOW || |
| 101 content_setting == CONTENT_SETTING_BLOCK || | 104 content_setting == CONTENT_SETTING_BLOCK || |
| 102 content_setting == CONTENT_SETTING_ASK); | 105 content_setting == CONTENT_SETTING_ASK); |
| 103 | 106 |
| 107 // For automated testing of protected content - having a prompt that requires | |
| 108 // user intervention is problematic. If the domain has been whitelisted as | |
| 109 // safe - suppress the request and allow. | |
| 110 const base::CommandLine& command_line = | |
| 111 *base::CommandLine::ForCurrentProcess(); | |
| 112 if (content_setting == CONTENT_SETTING_ASK && | |
| 113 command_line.HasSwitch( | |
| 114 switches::kDisableInfobarForProtectedMediaIdentifierForDomain)) { | |
| 115 // Convert the switch value to a vector or URLs | |
|
Joey Parrish
2017/04/19 17:15:52
typo: vector _of_ URLs
Vaage
2017/04/19 17:26:22
Done.
| |
| 116 std::vector<std::string> origins; | |
| 117 std::string whitelist = command_line.GetSwitchValueASCII( | |
| 118 switches::kDisableInfobarForProtectedMediaIdentifierForDomain); | |
| 119 for (const std::string& origin : base::SplitString( | |
| 120 whitelist, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { | |
| 121 origins.push_back(origin); | |
| 122 } | |
| 123 | |
| 124 // Only if both requesting and embedding are allowed, allow the prompt to | |
| 125 // be skipped. | |
| 126 bool found_requesting = false; | |
| 127 bool found_embedding = false; | |
| 128 for (size_t i = 0; i < origins.size(); i++) { | |
| 129 found_requesting |= origins.at(i) == requesting_origin.host(); | |
| 130 found_embedding |= origins.at(i) == embedding_origin.host(); | |
|
Joey Parrish
2017/04/19 17:15:53
Have you confirmed that host() includes the port?
Vaage
2017/04/19 17:26:22
If I am correct, host() does not include informati
Joey Parrish
2017/04/19 17:51:17
Good question. I thought so, but let's discuss of
| |
| 131 } | |
| 132 | |
| 133 if (found_requesting && found_embedding) { | |
| 134 content_setting = CONTENT_SETTING_ALLOW; | |
| 135 } | |
| 136 } | |
| 137 | |
| 104 return content_setting; | 138 return content_setting; |
| 105 } | 139 } |
| 106 | 140 |
| 107 void ProtectedMediaIdentifierPermissionContext::CancelPermissionRequest( | 141 void ProtectedMediaIdentifierPermissionContext::CancelPermissionRequest( |
| 108 content::WebContents* web_contents, | 142 content::WebContents* web_contents, |
| 109 const PermissionRequestID& id) { | 143 const PermissionRequestID& id) { |
| 110 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 144 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 111 | 145 |
| 112 #if defined(OS_CHROMEOS) | 146 #if defined(OS_CHROMEOS) |
| 113 PendingRequestMap::iterator request = pending_requests_.find(web_contents); | 147 PendingRequestMap::iterator request = pending_requests_.find(web_contents); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 content_setting = CONTENT_SETTING_BLOCK; | 258 content_setting = CONTENT_SETTING_BLOCK; |
| 225 persist = true; | 259 persist = true; |
| 226 break; | 260 break; |
| 227 } | 261 } |
| 228 | 262 |
| 229 NotifyPermissionSet( | 263 NotifyPermissionSet( |
| 230 id, requesting_origin, embedding_origin, callback, | 264 id, requesting_origin, embedding_origin, callback, |
| 231 persist, content_setting); | 265 persist, content_setting); |
| 232 } | 266 } |
| 233 #endif | 267 #endif |
| OLD | NEW |