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" |
12 #include "chrome/browser/media/protected_media_identifier_whitelist.h" | |
11 #include "chrome/browser/permissions/permission_util.h" | 13 #include "chrome/browser/permissions/permission_util.h" |
12 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/common/chrome_switches.h" | |
13 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
14 #include "components/prefs/pref_service.h" | 17 #include "components/prefs/pref_service.h" |
15 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
16 #include "content/public/browser/render_frame_host.h" | 19 #include "content/public/browser/render_frame_host.h" |
17 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
21 #include "media/base/media_switches.h" | |
22 #include "net/base/url_util.h" | |
18 #if defined(OS_CHROMEOS) | 23 #if defined(OS_CHROMEOS) |
19 #include <utility> | 24 #include <utility> |
20 | 25 |
21 #include "chrome/browser/chromeos/attestation/platform_verification_dialog.h" | 26 #include "chrome/browser/chromeos/attestation/platform_verification_dialog.h" |
22 #include "chrome/browser/chromeos/settings/cros_settings.h" | 27 #include "chrome/browser/chromeos/settings/cros_settings.h" |
23 #include "chromeos/chromeos_switches.h" | 28 #include "chromeos/chromeos_switches.h" |
24 #include "chromeos/settings/cros_settings_names.h" | 29 #include "chromeos/settings/cros_settings_names.h" |
25 #include "components/pref_registry/pref_registry_syncable.h" | 30 #include "components/pref_registry/pref_registry_syncable.h" |
26 #include "components/user_prefs/user_prefs.h" | 31 #include "components/user_prefs/user_prefs.h" |
27 #include "ui/views/widget/widget.h" | 32 #include "ui/views/widget/widget.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 return CONTENT_SETTING_BLOCK; | 99 return CONTENT_SETTING_BLOCK; |
95 } | 100 } |
96 | 101 |
97 ContentSetting content_setting = | 102 ContentSetting content_setting = |
98 PermissionContextBase::GetPermissionStatusInternal( | 103 PermissionContextBase::GetPermissionStatusInternal( |
99 render_frame_host, requesting_origin, embedding_origin); | 104 render_frame_host, requesting_origin, embedding_origin); |
100 DCHECK(content_setting == CONTENT_SETTING_ALLOW || | 105 DCHECK(content_setting == CONTENT_SETTING_ALLOW || |
101 content_setting == CONTENT_SETTING_BLOCK || | 106 content_setting == CONTENT_SETTING_BLOCK || |
102 content_setting == CONTENT_SETTING_ASK); | 107 content_setting == CONTENT_SETTING_ASK); |
103 | 108 |
109 if (content_setting == CONTENT_SETTING_ASK) { | |
110 // For automated testing of protected content - having a prompt that | |
111 // requires user intervention is problematic. If the domain has been | |
112 // whitelisted as safe - suppress the request and allow. | |
113 ProtectedMediaIdentifierWhitelist whitelist; | |
114 content_setting = whitelist.IsOriginWhitelisted(requesting_origin) | |
115 ? CONTENT_SETTING_ALLOW | |
116 : CONTENT_SETTING_ASK; | |
117 } | |
xhwang
2017/05/04 22:10:59
If you make IsOriginWhitelisted() as a static func
Vaage
2017/05/05 16:10:03
Done.
| |
118 | |
104 return content_setting; | 119 return content_setting; |
105 } | 120 } |
106 | 121 |
107 void ProtectedMediaIdentifierPermissionContext::CancelPermissionRequest( | 122 void ProtectedMediaIdentifierPermissionContext::CancelPermissionRequest( |
108 content::WebContents* web_contents, | 123 content::WebContents* web_contents, |
109 const PermissionRequestID& id) { | 124 const PermissionRequestID& id) { |
110 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 125 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
111 | 126 |
112 #if defined(OS_CHROMEOS) | 127 #if defined(OS_CHROMEOS) |
113 PendingRequestMap::iterator request = pending_requests_.find(web_contents); | 128 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; | 239 content_setting = CONTENT_SETTING_BLOCK; |
225 persist = true; | 240 persist = true; |
226 break; | 241 break; |
227 } | 242 } |
228 | 243 |
229 NotifyPermissionSet( | 244 NotifyPermissionSet( |
230 id, requesting_origin, embedding_origin, callback, | 245 id, requesting_origin, embedding_origin, callback, |
231 persist, content_setting); | 246 persist, content_setting); |
232 } | 247 } |
233 #endif | 248 #endif |
OLD | NEW |