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 "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 #elif defined(OS_CHROMEOS) | |
| 19 #include <utility> | 21 #include <utility> |
| 20 | 22 |
| 21 #include "chrome/browser/chromeos/attestation/platform_verification_dialog.h" | 23 #include "chrome/browser/chromeos/attestation/platform_verification_dialog.h" |
| 22 #include "chrome/browser/chromeos/settings/cros_settings.h" | 24 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 23 #include "chromeos/chromeos_switches.h" | 25 #include "chromeos/chromeos_switches.h" |
| 24 #include "chromeos/settings/cros_settings_names.h" | 26 #include "chromeos/settings/cros_settings_names.h" |
| 25 #include "components/pref_registry/pref_registry_syncable.h" | 27 #include "components/pref_registry/pref_registry_syncable.h" |
| 26 #include "components/user_prefs/user_prefs.h" | 28 #include "components/user_prefs/user_prefs.h" |
| 27 #include "ui/views/widget/widget.h" | 29 #include "ui/views/widget/widget.h" |
| 28 #elif !defined(OS_ANDROID) | 30 #else |
| 29 #error This file currently only supports Chrome OS and Android. | 31 #error This file currently only supports Chrome OS and Android. |
| 30 #endif | 32 #endif |
| 31 | 33 |
| 32 #if defined(OS_CHROMEOS) | 34 #if defined(OS_CHROMEOS) |
| 33 using chromeos::attestation::PlatformVerificationDialog; | 35 using chromeos::attestation::PlatformVerificationDialog; |
| 34 #endif | 36 #endif |
| 35 | 37 |
| 36 ProtectedMediaIdentifierPermissionContext:: | 38 ProtectedMediaIdentifierPermissionContext:: |
| 37 ProtectedMediaIdentifierPermissionContext(Profile* profile) | 39 ProtectedMediaIdentifierPermissionContext(Profile* profile) |
| 38 : PermissionContextBase(profile, | 40 : PermissionContextBase(profile, |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 return CONTENT_SETTING_BLOCK; | 96 return CONTENT_SETTING_BLOCK; |
| 95 } | 97 } |
| 96 | 98 |
| 97 ContentSetting content_setting = | 99 ContentSetting content_setting = |
| 98 PermissionContextBase::GetPermissionStatusInternal( | 100 PermissionContextBase::GetPermissionStatusInternal( |
| 99 render_frame_host, requesting_origin, embedding_origin); | 101 render_frame_host, requesting_origin, embedding_origin); |
| 100 DCHECK(content_setting == CONTENT_SETTING_ALLOW || | 102 DCHECK(content_setting == CONTENT_SETTING_ALLOW || |
| 101 content_setting == CONTENT_SETTING_BLOCK || | 103 content_setting == CONTENT_SETTING_BLOCK || |
| 102 content_setting == CONTENT_SETTING_ASK); | 104 content_setting == CONTENT_SETTING_ASK); |
| 103 | 105 |
| 106 #if defined(OS_ANDROID) | |
|
Joey Parrish
2017/04/17 19:45:18
I am of the opinion that this could be useful in o
Vaage
2017/04/19 16:55:47
Done.
| |
| 107 const bool isLocal = requesting_origin.host() == "localhost" && | |
| 108 embedding_origin.host() == "localhost"; | |
|
Joey Parrish
2017/04/17 19:45:18
I found this, for context: https://groups.google.c
Vaage
2017/04/19 16:55:47
Done.
| |
| 109 | |
| 110 // For testing of protected content, always allow content from localhost | |
| 111 // if the switch has been set. | |
| 112 const bool allowLocalContent = | |
| 113 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 114 switches::kDisableInfobarForProtectedMediaIdentifierForLocalhost); | |
| 115 | |
| 116 if (allowLocalContent && isLocal && content_setting == CONTENT_SETTING_ASK) { | |
| 117 content_setting = CONTENT_SETTING_ALLOW; | |
| 118 } | |
| 119 #endif | |
| 120 | |
| 104 return content_setting; | 121 return content_setting; |
| 105 } | 122 } |
| 106 | 123 |
| 107 void ProtectedMediaIdentifierPermissionContext::CancelPermissionRequest( | 124 void ProtectedMediaIdentifierPermissionContext::CancelPermissionRequest( |
| 108 content::WebContents* web_contents, | 125 content::WebContents* web_contents, |
| 109 const PermissionRequestID& id) { | 126 const PermissionRequestID& id) { |
| 110 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 127 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 111 | 128 |
| 112 #if defined(OS_CHROMEOS) | 129 #if defined(OS_CHROMEOS) |
| 113 PendingRequestMap::iterator request = pending_requests_.find(web_contents); | 130 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; | 241 content_setting = CONTENT_SETTING_BLOCK; |
| 225 persist = true; | 242 persist = true; |
| 226 break; | 243 break; |
| 227 } | 244 } |
| 228 | 245 |
| 229 NotifyPermissionSet( | 246 NotifyPermissionSet( |
| 230 id, requesting_origin, embedding_origin, callback, | 247 id, requesting_origin, embedding_origin, callback, |
| 231 persist, content_setting); | 248 persist, content_setting); |
| 232 } | 249 } |
| 233 #endif | 250 #endif |
| OLD | NEW |