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

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

Issue 1024563005: media: Remove kRAConsentGranted pref. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase only Created 5 years, 8 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
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/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"
(...skipping 11 matching lines...) Expand all
22 #include "chromeos/settings/cros_settings_names.h" 22 #include "chromeos/settings/cros_settings_names.h"
23 #include "components/pref_registry/pref_registry_syncable.h" 23 #include "components/pref_registry/pref_registry_syncable.h"
24 #include "components/user_prefs/user_prefs.h" 24 #include "components/user_prefs/user_prefs.h"
25 #include "ui/views/widget/widget.h" 25 #include "ui/views/widget/widget.h"
26 #elif defined(OS_ANDROID) 26 #elif defined(OS_ANDROID)
27 #include "media/base/media_switches.h" 27 #include "media/base/media_switches.h"
28 #else 28 #else
29 #error This file currently only supports Chrome OS and Android. 29 #error This file currently only supports Chrome OS and Android.
30 #endif 30 #endif
31 31
32 #if defined(OS_CHROMEOS)
33 using chromeos::attestation::PlatformVerificationDialog;
34 #endif
35
32 ProtectedMediaIdentifierPermissionContext:: 36 ProtectedMediaIdentifierPermissionContext::
33 ProtectedMediaIdentifierPermissionContext(Profile* profile) 37 ProtectedMediaIdentifierPermissionContext(Profile* profile)
34 : PermissionContextBase(profile, 38 : PermissionContextBase(profile,
35 CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER) 39 CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER)
36 #if defined(OS_CHROMEOS) 40 #if defined(OS_CHROMEOS)
37 , 41 ,
38 weak_factory_(this) 42 weak_factory_(this)
39 #endif 43 #endif
40 { 44 {
41 } 45 }
42 46
43 ProtectedMediaIdentifierPermissionContext:: 47 ProtectedMediaIdentifierPermissionContext::
44 ~ProtectedMediaIdentifierPermissionContext() { 48 ~ProtectedMediaIdentifierPermissionContext() {
45 } 49 }
46 50
47 #if defined(OS_CHROMEOS)
48 using chromeos::attestation::PlatformVerificationDialog;
49
50 // static
51 void ProtectedMediaIdentifierPermissionContext::RegisterProfilePrefs(
52 user_prefs::PrefRegistrySyncable* prefs) {
53 prefs->RegisterBooleanPref(prefs::kRAConsentGranted,
54 false, // Default value.
55 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
56 }
57 #endif
58
59 void ProtectedMediaIdentifierPermissionContext::RequestPermission( 51 void ProtectedMediaIdentifierPermissionContext::RequestPermission(
60 content::WebContents* web_contents, 52 content::WebContents* web_contents,
61 const PermissionRequestID& id, 53 const PermissionRequestID& id,
62 const GURL& requesting_origin, 54 const GURL& requesting_origin,
63 bool user_gesture, 55 bool user_gesture,
64 const BrowserPermissionCallback& callback) { 56 const BrowserPermissionCallback& callback) {
65 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 57 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
66 58
67 GURL embedding_origin = web_contents->GetLastCommittedURL().GetOrigin(); 59 GURL embedding_origin = web_contents->GetLastCommittedURL().GetOrigin();
68 60
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 !IsProtectedMediaIdentifierEnabled()) { 112 !IsProtectedMediaIdentifierEnabled()) {
121 return CONTENT_SETTING_BLOCK; 113 return CONTENT_SETTING_BLOCK;
122 } 114 }
123 115
124 ContentSetting content_setting = PermissionContextBase::GetPermissionStatus( 116 ContentSetting content_setting = PermissionContextBase::GetPermissionStatus(
125 requesting_origin, embedding_origin); 117 requesting_origin, embedding_origin);
126 DCHECK(content_setting == CONTENT_SETTING_ALLOW || 118 DCHECK(content_setting == CONTENT_SETTING_ALLOW ||
127 content_setting == CONTENT_SETTING_BLOCK || 119 content_setting == CONTENT_SETTING_BLOCK ||
128 content_setting == CONTENT_SETTING_ASK); 120 content_setting == CONTENT_SETTING_ASK);
129 121
130 #if defined(OS_CHROMEOS) 122 #if defined(OS_ANDROID)
131 // Check kRAConsentGranted here because it's possible that user dismissed
132 // the dialog triggered by RequestPermission() and the content setting is
133 // set to "allow" by server sync. In this case, we should still "ask".
134 if (content_setting == CONTENT_SETTING_ALLOW &&
135 !profile()->GetPrefs()->GetBoolean(prefs::kRAConsentGranted)) {
136 content_setting = CONTENT_SETTING_ASK;
137 }
138 #elif defined(OS_ANDROID)
139 // When kDisableInfobarForProtectedMediaIdentifier is enabled, do not "ask" 123 // When kDisableInfobarForProtectedMediaIdentifier is enabled, do not "ask"
140 // the user and always "allow". 124 // the user and always "allow".
141 if (content_setting == CONTENT_SETTING_ASK && 125 if (content_setting == CONTENT_SETTING_ASK &&
142 base::CommandLine::ForCurrentProcess()->HasSwitch( 126 base::CommandLine::ForCurrentProcess()->HasSwitch(
143 switches::kDisableInfobarForProtectedMediaIdentifier)) { 127 switches::kDisableInfobarForProtectedMediaIdentifier)) {
144 content_setting = CONTENT_SETTING_ALLOW; 128 content_setting = CONTENT_SETTING_ALLOW;
145 } 129 }
146 #endif 130 #endif
147 131
148 return content_setting; 132 return content_setting;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 DVLOG(1) << "Protected media identifier disabled by the user or by device " 198 DVLOG(1) << "Protected media identifier disabled by the user or by device "
215 "policy."; 199 "policy.";
216 return false; 200 return false;
217 } 201 }
218 #endif 202 #endif
219 203
220 return true; 204 return true;
221 } 205 }
222 206
223 #if defined(OS_CHROMEOS) 207 #if defined(OS_CHROMEOS)
224 static void RecordRAConsentGranted(content::WebContents* web_contents) {
225 PrefService* pref_service =
226 user_prefs::UserPrefs::Get(web_contents->GetBrowserContext());
227 if (!pref_service) {
228 LOG(ERROR) << "Failed to get user prefs.";
229 return;
230 }
231 pref_service->SetBoolean(prefs::kRAConsentGranted, true);
232 }
233
234 void ProtectedMediaIdentifierPermissionContext:: 208 void ProtectedMediaIdentifierPermissionContext::
235 OnPlatformVerificationConsentResponse( 209 OnPlatformVerificationConsentResponse(
236 content::WebContents* web_contents, 210 content::WebContents* web_contents,
237 const PermissionRequestID& id, 211 const PermissionRequestID& id,
238 const GURL& requesting_origin, 212 const GURL& requesting_origin,
239 const GURL& embedding_origin, 213 const GURL& embedding_origin,
240 const BrowserPermissionCallback& callback, 214 const BrowserPermissionCallback& callback,
241 PlatformVerificationDialog::ConsentResponse response) { 215 PlatformVerificationDialog::ConsentResponse response) {
242 // The request may have been canceled. Drop the callback in that case. 216 // The request may have been canceled. Drop the callback in that case.
243 PendingRequestMap::iterator request = pending_requests_.find(web_contents); 217 PendingRequestMap::iterator request = pending_requests_.find(web_contents);
244 if (request == pending_requests_.end()) 218 if (request == pending_requests_.end())
245 return; 219 return;
246 220
247 DCHECK(request->second.second.Equals(id)); 221 DCHECK(request->second.second.Equals(id));
248 pending_requests_.erase(request); 222 pending_requests_.erase(request);
249 223
250 ContentSetting content_setting = CONTENT_SETTING_ASK; 224 ContentSetting content_setting = CONTENT_SETTING_ASK;
251 bool persist = false; // Whether the ContentSetting should be saved. 225 bool persist = false; // Whether the ContentSetting should be saved.
252 switch (response) { 226 switch (response) {
253 case PlatformVerificationDialog::CONSENT_RESPONSE_NONE: 227 case PlatformVerificationDialog::CONSENT_RESPONSE_NONE:
254 content_setting = CONTENT_SETTING_ASK; 228 content_setting = CONTENT_SETTING_ASK;
255 persist = false; 229 persist = false;
256 break; 230 break;
257 case PlatformVerificationDialog::CONSENT_RESPONSE_ALLOW: 231 case PlatformVerificationDialog::CONSENT_RESPONSE_ALLOW:
258 VLOG(1) << "Platform verification accepted by user."; 232 VLOG(1) << "Platform verification accepted by user.";
259 content::RecordAction( 233 content::RecordAction(
260 base::UserMetricsAction("PlatformVerificationAccepted")); 234 base::UserMetricsAction("PlatformVerificationAccepted"));
261 RecordRAConsentGranted(web_contents);
262 content_setting = CONTENT_SETTING_ALLOW; 235 content_setting = CONTENT_SETTING_ALLOW;
263 persist = true; 236 persist = true;
264 break; 237 break;
265 case PlatformVerificationDialog::CONSENT_RESPONSE_DENY: 238 case PlatformVerificationDialog::CONSENT_RESPONSE_DENY:
266 VLOG(1) << "Platform verification denied by user."; 239 VLOG(1) << "Platform verification denied by user.";
267 content::RecordAction( 240 content::RecordAction(
268 base::UserMetricsAction("PlatformVerificationRejected")); 241 base::UserMetricsAction("PlatformVerificationRejected"));
269 content_setting = CONTENT_SETTING_BLOCK; 242 content_setting = CONTENT_SETTING_BLOCK;
270 persist = true; 243 persist = true;
271 break; 244 break;
272 } 245 }
273 246
274 NotifyPermissionSet( 247 NotifyPermissionSet(
275 id, requesting_origin, embedding_origin, callback, 248 id, requesting_origin, embedding_origin, callback,
276 persist, content_setting); 249 persist, content_setting);
277 } 250 }
278 #endif 251 #endif
OLDNEW
« no previous file with comments | « chrome/browser/media/protected_media_identifier_permission_context.h ('k') | chrome/browser/prefs/browser_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698