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 "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
11 #include "chrome/browser/permissions/permission_util.h" | 11 #include "chrome/browser/permissions/permission_util.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
14 #include "components/prefs/pref_service.h" | 14 #include "components/prefs/pref_service.h" |
15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
16 #include "content/public/browser/render_frame_host.h" | 16 #include "content/public/browser/render_frame_host.h" |
17 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
18 #if defined(OS_CHROMEOS) | 18 #if defined(OS_ANDROID) |
19 #include "media/base/media_switches.h" | |
20 #include "net/base/url_util.h" | |
21 #elif 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" |
28 #elif !defined(OS_ANDROID) | 31 #else |
29 #error This file currently only supports Chrome OS and Android. | 32 #error This file currently only supports Chrome OS and Android. |
30 #endif | 33 #endif |
31 | 34 |
32 #if defined(OS_CHROMEOS) | 35 #if defined(OS_CHROMEOS) |
33 using chromeos::attestation::PlatformVerificationDialog; | 36 using chromeos::attestation::PlatformVerificationDialog; |
34 #endif | 37 #endif |
35 | 38 |
36 ProtectedMediaIdentifierPermissionContext:: | 39 ProtectedMediaIdentifierPermissionContext:: |
37 ProtectedMediaIdentifierPermissionContext(Profile* profile) | 40 ProtectedMediaIdentifierPermissionContext(Profile* profile) |
38 : PermissionContextBase(profile, | 41 : PermissionContextBase(profile, |
(...skipping 55 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 #if defined(OS_ANDROID) | |
raymes
2017/04/19 01:24:19
nit: these should have no identation
| |
108 const bool isLocal = net::IsLocalHost(requesting_origin.host()) && | |
109 net::IsLoaclHost(embedding_origin.host()); | |
raymes
2017/04/19 01:24:19
nit: localhost is misspelt.
| |
110 | |
111 // For testing of protected content, always allow content from localhost | |
112 // if the switch has been set. | |
113 const bool allowLocalContent = | |
114 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
115 switches::kDisableInfobarForProtectedMediaIdentifierForLocalhost); | |
raymes
2017/04/17 22:10:11
Could you elaborate on what kind of test is this n
Joey Parrish
2017/04/17 22:49:37
This is for automated testing of protected content
raymes
2017/04/19 01:24:19
Thanks for explaining. I think this is ok because
| |
116 | |
117 if (allowLocalContent && isLocal && content_setting == CONTENT_SETTING_ASK) { | |
118 content_setting = CONTENT_SETTING_ALLOW; | |
119 } | |
120 #endif | |
121 | |
104 return content_setting; | 122 return content_setting; |
105 } | 123 } |
106 | 124 |
107 void ProtectedMediaIdentifierPermissionContext::CancelPermissionRequest( | 125 void ProtectedMediaIdentifierPermissionContext::CancelPermissionRequest( |
108 content::WebContents* web_contents, | 126 content::WebContents* web_contents, |
109 const PermissionRequestID& id) { | 127 const PermissionRequestID& id) { |
110 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 128 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
111 | 129 |
112 #if defined(OS_CHROMEOS) | 130 #if defined(OS_CHROMEOS) |
113 PendingRequestMap::iterator request = pending_requests_.find(web_contents); | 131 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; | 242 content_setting = CONTENT_SETTING_BLOCK; |
225 persist = true; | 243 persist = true; |
226 break; | 244 break; |
227 } | 245 } |
228 | 246 |
229 NotifyPermissionSet( | 247 NotifyPermissionSet( |
230 id, requesting_origin, embedding_origin, callback, | 248 id, requesting_origin, embedding_origin, callback, |
231 persist, content_setting); | 249 persist, content_setting); |
232 } | 250 } |
233 #endif | 251 #endif |
OLD | NEW |