| 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/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 9 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/common/pref_names.h" | 11 #include "chrome/common/pref_names.h" |
| 12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 13 #include "content/public/browser/user_metrics.h" | 13 #include "content/public/browser/user_metrics.h" |
| 14 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 15 #if defined(OS_CHROMEOS) | 15 #if defined(OS_CHROMEOS) |
| 16 #include <utility> | 16 #include <utility> |
| 17 | 17 |
| 18 #include "chrome/browser/chromeos/attestation/platform_verification_dialog.h" | 18 #include "chrome/browser/chromeos/attestation/platform_verification_dialog.h" |
| 19 #include "chrome/browser/chromeos/settings/cros_settings.h" | 19 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 20 #include "chromeos/chromeos_switches.h" | 20 #include "chromeos/chromeos_switches.h" |
| 21 #include "chromeos/settings/cros_settings_names.h" | 21 #include "chromeos/settings/cros_settings_names.h" |
| 22 #include "components/pref_registry/pref_registry_syncable.h" | 22 #include "components/pref_registry/pref_registry_syncable.h" |
| 23 #include "components/user_prefs/user_prefs.h" | 23 #include "components/user_prefs/user_prefs.h" |
| 24 #include "ui/views/widget/widget.h" | 24 #include "ui/views/widget/widget.h" |
| 25 #elif defined(OS_ANDROID) | 25 #elif !defined(OS_ANDROID) |
| 26 #include "media/base/media_switches.h" | |
| 27 #else | |
| 28 #error This file currently only supports Chrome OS and Android. | 26 #error This file currently only supports Chrome OS and Android. |
| 29 #endif | 27 #endif |
| 30 | 28 |
| 31 #if defined(OS_CHROMEOS) | 29 #if defined(OS_CHROMEOS) |
| 32 using chromeos::attestation::PlatformVerificationDialog; | 30 using chromeos::attestation::PlatformVerificationDialog; |
| 33 #endif | 31 #endif |
| 34 | 32 |
| 35 ProtectedMediaIdentifierPermissionContext:: | 33 ProtectedMediaIdentifierPermissionContext:: |
| 36 ProtectedMediaIdentifierPermissionContext(Profile* profile) | 34 ProtectedMediaIdentifierPermissionContext(Profile* profile) |
| 37 : PermissionContextBase(profile, | 35 : PermissionContextBase(profile, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 // TODO(xhwang): Remove when http://crbug.com/454847 is fixed. | 85 // TODO(xhwang): Remove when http://crbug.com/454847 is fixed. |
| 88 views::Widget* widget = PlatformVerificationDialog::ShowDialog( | 86 views::Widget* widget = PlatformVerificationDialog::ShowDialog( |
| 89 web_contents, requesting_origin, | 87 web_contents, requesting_origin, |
| 90 base::Bind(&ProtectedMediaIdentifierPermissionContext:: | 88 base::Bind(&ProtectedMediaIdentifierPermissionContext:: |
| 91 OnPlatformVerificationConsentResponse, | 89 OnPlatformVerificationConsentResponse, |
| 92 weak_factory_.GetWeakPtr(), web_contents, id, | 90 weak_factory_.GetWeakPtr(), web_contents, id, |
| 93 requesting_origin, embedding_origin, callback)); | 91 requesting_origin, embedding_origin, callback)); |
| 94 pending_requests_.insert( | 92 pending_requests_.insert( |
| 95 std::make_pair(web_contents, std::make_pair(widget, id))); | 93 std::make_pair(web_contents, std::make_pair(widget, id))); |
| 96 #else | 94 #else |
| 97 DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 98 switches::kDisableInfobarForProtectedMediaIdentifier)); | |
| 99 PermissionContextBase::RequestPermission(web_contents, id, requesting_origin, | 95 PermissionContextBase::RequestPermission(web_contents, id, requesting_origin, |
| 100 user_gesture, callback); | 96 user_gesture, callback); |
| 101 #endif | 97 #endif |
| 102 } | 98 } |
| 103 | 99 |
| 104 ContentSetting ProtectedMediaIdentifierPermissionContext::GetPermissionStatus( | 100 ContentSetting ProtectedMediaIdentifierPermissionContext::GetPermissionStatus( |
| 105 const GURL& requesting_origin, | 101 const GURL& requesting_origin, |
| 106 const GURL& embedding_origin) const { | 102 const GURL& embedding_origin) const { |
| 107 DVLOG(1) << __FUNCTION__ << ": (" << requesting_origin.spec() << ", " | 103 DVLOG(1) << __FUNCTION__ << ": (" << requesting_origin.spec() << ", " |
| 108 << embedding_origin.spec() << ")"; | 104 << embedding_origin.spec() << ")"; |
| 109 | 105 |
| 110 if (!requesting_origin.is_valid() || !embedding_origin.is_valid() || | 106 if (!requesting_origin.is_valid() || !embedding_origin.is_valid() || |
| 111 !IsProtectedMediaIdentifierEnabled()) { | 107 !IsProtectedMediaIdentifierEnabled()) { |
| 112 return CONTENT_SETTING_BLOCK; | 108 return CONTENT_SETTING_BLOCK; |
| 113 } | 109 } |
| 114 | 110 |
| 115 ContentSetting content_setting = PermissionContextBase::GetPermissionStatus( | 111 ContentSetting content_setting = PermissionContextBase::GetPermissionStatus( |
| 116 requesting_origin, embedding_origin); | 112 requesting_origin, embedding_origin); |
| 117 DCHECK(content_setting == CONTENT_SETTING_ALLOW || | 113 DCHECK(content_setting == CONTENT_SETTING_ALLOW || |
| 118 content_setting == CONTENT_SETTING_BLOCK || | 114 content_setting == CONTENT_SETTING_BLOCK || |
| 119 content_setting == CONTENT_SETTING_ASK); | 115 content_setting == CONTENT_SETTING_ASK); |
| 120 | 116 |
| 121 #if defined(OS_ANDROID) | |
| 122 // When kDisableInfobarForProtectedMediaIdentifier is enabled, do not "ask" | |
| 123 // the user and always "allow". | |
| 124 if (content_setting == CONTENT_SETTING_ASK && | |
| 125 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 126 switches::kDisableInfobarForProtectedMediaIdentifier)) { | |
| 127 content_setting = CONTENT_SETTING_ALLOW; | |
| 128 } | |
| 129 #endif | |
| 130 | |
| 131 return content_setting; | 117 return content_setting; |
| 132 } | 118 } |
| 133 | 119 |
| 134 void ProtectedMediaIdentifierPermissionContext::CancelPermissionRequest( | 120 void ProtectedMediaIdentifierPermissionContext::CancelPermissionRequest( |
| 135 content::WebContents* web_contents, | 121 content::WebContents* web_contents, |
| 136 const PermissionRequestID& id) { | 122 const PermissionRequestID& id) { |
| 137 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 123 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 138 | 124 |
| 139 #if defined(OS_CHROMEOS) | 125 #if defined(OS_CHROMEOS) |
| 140 PendingRequestMap::iterator request = pending_requests_.find(web_contents); | 126 PendingRequestMap::iterator request = pending_requests_.find(web_contents); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 content_setting = CONTENT_SETTING_BLOCK; | 236 content_setting = CONTENT_SETTING_BLOCK; |
| 251 persist = true; | 237 persist = true; |
| 252 break; | 238 break; |
| 253 } | 239 } |
| 254 | 240 |
| 255 NotifyPermissionSet( | 241 NotifyPermissionSet( |
| 256 id, requesting_origin, embedding_origin, callback, | 242 id, requesting_origin, embedding_origin, callback, |
| 257 persist, content_setting); | 243 persist, content_setting); |
| 258 } | 244 } |
| 259 #endif | 245 #endif |
| OLD | NEW |