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" |
14 #include "chrome/common/chrome_switches.h" | |
13 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
14 #include "components/prefs/pref_service.h" | 16 #include "components/prefs/pref_service.h" |
15 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
16 #include "content/public/browser/render_frame_host.h" | 18 #include "content/public/browser/render_frame_host.h" |
17 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
20 #include "media/base/media_switches.h" | |
21 #include "net/base/url_util.h" | |
18 #if defined(OS_CHROMEOS) | 22 #if defined(OS_CHROMEOS) |
19 #include <utility> | 23 #include <utility> |
20 | 24 |
21 #include "chrome/browser/chromeos/attestation/platform_verification_dialog.h" | 25 #include "chrome/browser/chromeos/attestation/platform_verification_dialog.h" |
22 #include "chrome/browser/chromeos/settings/cros_settings.h" | 26 #include "chrome/browser/chromeos/settings/cros_settings.h" |
23 #include "chromeos/chromeos_switches.h" | 27 #include "chromeos/chromeos_switches.h" |
24 #include "chromeos/settings/cros_settings_names.h" | 28 #include "chromeos/settings/cros_settings_names.h" |
25 #include "components/pref_registry/pref_registry_syncable.h" | 29 #include "components/pref_registry/pref_registry_syncable.h" |
26 #include "components/user_prefs/user_prefs.h" | 30 #include "components/user_prefs/user_prefs.h" |
27 #include "ui/views/widget/widget.h" | 31 #include "ui/views/widget/widget.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 return CONTENT_SETTING_BLOCK; | 98 return CONTENT_SETTING_BLOCK; |
95 } | 99 } |
96 | 100 |
97 ContentSetting content_setting = | 101 ContentSetting content_setting = |
98 PermissionContextBase::GetPermissionStatusInternal( | 102 PermissionContextBase::GetPermissionStatusInternal( |
99 render_frame_host, requesting_origin, embedding_origin); | 103 render_frame_host, requesting_origin, embedding_origin); |
100 DCHECK(content_setting == CONTENT_SETTING_ALLOW || | 104 DCHECK(content_setting == CONTENT_SETTING_ALLOW || |
101 content_setting == CONTENT_SETTING_BLOCK || | 105 content_setting == CONTENT_SETTING_BLOCK || |
102 content_setting == CONTENT_SETTING_ASK); | 106 content_setting == CONTENT_SETTING_ASK); |
103 | 107 |
108 // For automated testing of protected content - having a prompt that | |
109 // requires user intervention is problematic. If the domain has been | |
110 // whitelisted as safe - suppress the request and allow. | |
111 if (content_setting == CONTENT_SETTING_ASK && | |
112 IsOriginWhitelisted(requesting_origin)) { | |
113 content_setting = CONTENT_SETTING_ALLOW; | |
114 } | |
115 | |
104 return content_setting; | 116 return content_setting; |
105 } | 117 } |
106 | 118 |
119 bool ProtectedMediaIdentifierPermissionContext::IsOriginWhitelisted( | |
120 const GURL& requesting_origin) { | |
121 const base::CommandLine& command_line = | |
122 *base::CommandLine::ForCurrentProcess(); | |
123 | |
124 if (command_line.GetSwitchValueASCII(switches::kUserDataDir).empty()) { | |
125 return false; | |
126 } | |
127 | |
128 const std::string whitelist = command_line.GetSwitchValueASCII( | |
129 switches::kDisableInfobarForProtectedMediaIdentifierForDomain); | |
130 | |
131 for (const std::string& origin : base::SplitString( | |
raymes
2017/05/07 22:07:26
nit: origin->domain
Vaage
2017/05/08 16:51:51
Done.
| |
132 whitelist, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY)) { | |
133 if (requesting_origin.DomainIs(origin)) { | |
134 return true; | |
135 } | |
136 } | |
137 | |
138 return false; | |
139 } | |
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); |
114 if (request == pending_requests_.end() || (request->second.second != id)) | 148 if (request == pending_requests_.end() || (request->second.second != id)) |
115 return; | 149 return; |
116 | 150 |
(...skipping 107 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 |