Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: chrome/browser/media/protected_media_identifier_permission_context.cc

Issue 1007163003: media: Check kDisableInfobarForProtectedMediaIdentifier in ProtectedMediaIdentifierPermissionContex… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@proxy_decryptor_request_permission
Patch Set: comments addressed Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/media/cdm/browser_cdm_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 8 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/pref_names.h" 10 #include "chrome/common/pref_names.h"
11 #include "components/content_settings/core/common/permission_request_id.h" 11 #include "components/content_settings/core/common/permission_request_id.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 15
16 #if defined(OS_CHROMEOS) 16 #if defined(OS_CHROMEOS)
17 #include <utility> 17 #include <utility>
18 18
19 #include "chrome/browser/chromeos/attestation/platform_verification_dialog.h" 19 #include "chrome/browser/chromeos/attestation/platform_verification_dialog.h"
20 #include "chrome/browser/chromeos/settings/cros_settings.h" 20 #include "chrome/browser/chromeos/settings/cros_settings.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 25 #elif defined(OS_ANDROID)
26 using chromeos::attestation::PlatformVerificationDialog; 26 #include "base/command_line.h"
27 #include "media/base/media_switches.h"
28 #else
29 #error This file currently only supports Chrome OS and Android.
27 #endif 30 #endif
28 31
29 ProtectedMediaIdentifierPermissionContext:: 32 ProtectedMediaIdentifierPermissionContext::
30 ProtectedMediaIdentifierPermissionContext(Profile* profile) 33 ProtectedMediaIdentifierPermissionContext(Profile* profile)
31 : PermissionContextBase(profile, 34 : PermissionContextBase(profile,
32 CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER) 35 CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER)
33 #if defined(OS_CHROMEOS) 36 #if defined(OS_CHROMEOS)
34 , 37 ,
35 weak_factory_(this) 38 weak_factory_(this)
36 #endif 39 #endif
37 { 40 {
38 } 41 }
39 42
40 ProtectedMediaIdentifierPermissionContext:: 43 ProtectedMediaIdentifierPermissionContext::
41 ~ProtectedMediaIdentifierPermissionContext() { 44 ~ProtectedMediaIdentifierPermissionContext() {
42 } 45 }
43 46
44 #if defined(OS_CHROMEOS) 47 #if defined(OS_CHROMEOS)
48 using chromeos::attestation::PlatformVerificationDialog;
49
45 // static 50 // static
46 void ProtectedMediaIdentifierPermissionContext::RegisterProfilePrefs( 51 void ProtectedMediaIdentifierPermissionContext::RegisterProfilePrefs(
47 user_prefs::PrefRegistrySyncable* prefs) { 52 user_prefs::PrefRegistrySyncable* prefs) {
48 prefs->RegisterBooleanPref(prefs::kRAConsentGranted, 53 prefs->RegisterBooleanPref(prefs::kRAConsentGranted,
49 false, // Default value. 54 false, // Default value.
50 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 55 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
51 } 56 }
52 #endif 57 #endif
53 58
54 void ProtectedMediaIdentifierPermissionContext::RequestPermission( 59 void ProtectedMediaIdentifierPermissionContext::RequestPermission(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // TODO(xhwang): Remove when http://crbug.com/454847 is fixed. 96 // TODO(xhwang): Remove when http://crbug.com/454847 is fixed.
92 views::Widget* widget = PlatformVerificationDialog::ShowDialog( 97 views::Widget* widget = PlatformVerificationDialog::ShowDialog(
93 web_contents, requesting_origin, 98 web_contents, requesting_origin,
94 base::Bind(&ProtectedMediaIdentifierPermissionContext:: 99 base::Bind(&ProtectedMediaIdentifierPermissionContext::
95 OnPlatformVerificationConsentResponse, 100 OnPlatformVerificationConsentResponse,
96 weak_factory_.GetWeakPtr(), web_contents, id, 101 weak_factory_.GetWeakPtr(), web_contents, id,
97 requesting_origin, embedding_origin, callback)); 102 requesting_origin, embedding_origin, callback));
98 pending_requests_.insert( 103 pending_requests_.insert(
99 std::make_pair(web_contents, std::make_pair(widget, id))); 104 std::make_pair(web_contents, std::make_pair(widget, id)));
100 #else 105 #else
106 DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch(
ddorwin 2015/03/17 02:43:09 Note: This only works because the file only suppor
xhwang 2015/03/17 21:43:42 Acknowledged.
107 switches::kDisableInfobarForProtectedMediaIdentifier));
101 PermissionContextBase::RequestPermission(web_contents, id, requesting_origin, 108 PermissionContextBase::RequestPermission(web_contents, id, requesting_origin,
102 user_gesture, callback); 109 user_gesture, callback);
103 #endif 110 #endif
104 } 111 }
105 112
106 ContentSetting ProtectedMediaIdentifierPermissionContext::GetPermissionStatus( 113 ContentSetting ProtectedMediaIdentifierPermissionContext::GetPermissionStatus(
107 const GURL& requesting_origin, 114 const GURL& requesting_origin,
108 const GURL& embedding_origin) const { 115 const GURL& embedding_origin) const {
109 DVLOG(1) << __FUNCTION__ << ": (" << requesting_origin.spec() << ", " 116 DVLOG(1) << __FUNCTION__ << ": (" << requesting_origin.spec() << ", "
110 << embedding_origin.spec() << ")"; 117 << embedding_origin.spec() << ")";
111 118
112 if (!requesting_origin.is_valid() || !embedding_origin.is_valid() || 119 if (!requesting_origin.is_valid() || !embedding_origin.is_valid() ||
113 !IsProtectedMediaIdentifierEnabled()) { 120 !IsProtectedMediaIdentifierEnabled()) {
114 return CONTENT_SETTING_BLOCK; 121 return CONTENT_SETTING_BLOCK;
115 } 122 }
116 123
117 ContentSetting content_setting = PermissionContextBase::GetPermissionStatus( 124 ContentSetting content_setting = PermissionContextBase::GetPermissionStatus(
118 requesting_origin, embedding_origin); 125 requesting_origin, embedding_origin);
119 DCHECK(content_setting == CONTENT_SETTING_ALLOW || 126 DCHECK(content_setting == CONTENT_SETTING_ALLOW ||
120 content_setting == CONTENT_SETTING_BLOCK || 127 content_setting == CONTENT_SETTING_BLOCK ||
121 content_setting == CONTENT_SETTING_ASK); 128 content_setting == CONTENT_SETTING_ASK);
122 129
123 #if defined(OS_CHROMEOS) 130 #if defined(OS_CHROMEOS)
124 if (content_setting == CONTENT_SETTING_ALLOW) { 131 // Check kRAConsentGranted here because it's possible that user dismissed
125 // Check kRAConsentGranted here because it's possible that user dismissed 132 // the dialog triggered by RequestPermission() and the content setting is
126 // the dialog triggered by RequestPermission() and the content setting is 133 // set to "allow" by server sync. In this case, we should still "ask".
127 // set to "allow" by server sync. In this case, we should still "ask". 134 if (content_setting == CONTENT_SETTING_ALLOW &&
128 if (profile()->GetPrefs()->GetBoolean(prefs::kRAConsentGranted)) 135 !profile()->GetPrefs()->GetBoolean(prefs::kRAConsentGranted)) {
129 return CONTENT_SETTING_ALLOW; 136 content_setting = CONTENT_SETTING_ASK;
130 else 137 }
131 return CONTENT_SETTING_ASK; 138 #elif defined(OS_ANDROID)
139 // When kDisableInfobarForProtectedMediaIdentifier is enabled, do not "ask"
140 // the user and always "allow".
141 if (content_setting == CONTENT_SETTING_ASK &&
142 base::CommandLine::ForCurrentProcess()->HasSwitch(
143 switches::kDisableInfobarForProtectedMediaIdentifier)) {
144 content_setting = CONTENT_SETTING_ALLOW;
132 } 145 }
133 #endif 146 #endif
134 147
135 return content_setting; 148 return content_setting;
136 } 149 }
137 150
138 void ProtectedMediaIdentifierPermissionContext::CancelPermissionRequest( 151 void ProtectedMediaIdentifierPermissionContext::CancelPermissionRequest(
139 content::WebContents* web_contents, 152 content::WebContents* web_contents,
140 const PermissionRequestID& id) { 153 const PermissionRequestID& id) {
141 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 154 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 pref_service->SetBoolean(prefs::kRAConsentGranted, true); 230 pref_service->SetBoolean(prefs::kRAConsentGranted, true);
218 } 231 }
219 232
220 void ProtectedMediaIdentifierPermissionContext:: 233 void ProtectedMediaIdentifierPermissionContext::
221 OnPlatformVerificationConsentResponse( 234 OnPlatformVerificationConsentResponse(
222 content::WebContents* web_contents, 235 content::WebContents* web_contents,
223 const PermissionRequestID& id, 236 const PermissionRequestID& id,
224 const GURL& requesting_origin, 237 const GURL& requesting_origin,
225 const GURL& embedding_origin, 238 const GURL& embedding_origin,
226 const BrowserPermissionCallback& callback, 239 const BrowserPermissionCallback& callback,
227 chromeos::attestation::PlatformVerificationDialog::ConsentResponse 240 PlatformVerificationDialog::ConsentResponse response) {
228 response) {
229 // The request may have been canceled. Drop the callback in that case. 241 // The request may have been canceled. Drop the callback in that case.
230 PendingRequestMap::iterator request = pending_requests_.find(web_contents); 242 PendingRequestMap::iterator request = pending_requests_.find(web_contents);
231 if (request == pending_requests_.end()) 243 if (request == pending_requests_.end())
232 return; 244 return;
233 245
234 DCHECK(request->second.second.Equals(id)); 246 DCHECK(request->second.second.Equals(id));
235 pending_requests_.erase(request); 247 pending_requests_.erase(request);
236 248
237 ContentSetting content_setting = CONTENT_SETTING_ASK; 249 ContentSetting content_setting = CONTENT_SETTING_ASK;
238 bool persist = false; // Whether the ContentSetting should be saved. 250 bool persist = false; // Whether the ContentSetting should be saved.
(...skipping 17 matching lines...) Expand all
256 content_setting = CONTENT_SETTING_BLOCK; 268 content_setting = CONTENT_SETTING_BLOCK;
257 persist = true; 269 persist = true;
258 break; 270 break;
259 } 271 }
260 272
261 NotifyPermissionSet( 273 NotifyPermissionSet(
262 id, requesting_origin, embedding_origin, callback, 274 id, requesting_origin, embedding_origin, callback,
263 persist, content_setting); 275 persist, content_setting);
264 } 276 }
265 #endif 277 #endif
OLDNEW
« no previous file with comments | « no previous file | content/browser/media/cdm/browser_cdm_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698