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

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

Issue 863263007: media: Enable ProtectedMediaIdentifierPermissionContext on ChromeOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase only Created 5 years, 10 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/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/web_contents.h" 13 #include "content/public/browser/web_contents.h"
14 14
15 #if defined(OS_CHROMEOS)
16 #include "chrome/browser/chromeos/settings/cros_settings.h"
17 #include "chromeos/settings/cros_settings_names.h"
18 #endif
19
15 ProtectedMediaIdentifierPermissionContext:: 20 ProtectedMediaIdentifierPermissionContext::
16 ProtectedMediaIdentifierPermissionContext(Profile* profile) 21 ProtectedMediaIdentifierPermissionContext(Profile* profile)
17 : PermissionContextBase(profile, 22 : PermissionContextBase(profile,
18 CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER) { 23 CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER) {
19 } 24 }
20 25
21 ProtectedMediaIdentifierPermissionContext:: 26 ProtectedMediaIdentifierPermissionContext::
22 ~ProtectedMediaIdentifierPermissionContext() { 27 ~ProtectedMediaIdentifierPermissionContext() {
23 } 28 }
24 29
25 void ProtectedMediaIdentifierPermissionContext::RequestPermission( 30 void ProtectedMediaIdentifierPermissionContext::RequestPermission(
26 content::WebContents* web_contents, 31 content::WebContents* web_contents,
27 const PermissionRequestID& id, 32 const PermissionRequestID& id,
28 const GURL& requesting_frame_origin, 33 const GURL& requesting_frame_origin,
29 bool user_gesture, 34 bool user_gesture,
30 const BrowserPermissionCallback& callback) { 35 const BrowserPermissionCallback& callback) {
31 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 36 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
32 37
33 #if defined(OS_ANDROID) 38 if (!IsProtectedMediaIdentifierEnabled()) {
34 // Check if the protected media identifier master switch is disabled.
35 if (!profile()->GetPrefs()->GetBoolean(
36 prefs::kProtectedMediaIdentifierEnabled)) {
37 NotifyPermissionSet(id, 39 NotifyPermissionSet(id,
38 requesting_frame_origin, 40 requesting_frame_origin,
39 web_contents->GetLastCommittedURL().GetOrigin(), 41 web_contents->GetLastCommittedURL().GetOrigin(),
40 callback, false, false); 42 callback, false, false);
41 return; 43 return;
42 } 44 }
43 #endif
44 45
45 PermissionContextBase::RequestPermission(web_contents, id, 46 PermissionContextBase::RequestPermission(web_contents, id,
46 requesting_frame_origin, 47 requesting_frame_origin,
47 user_gesture, 48 user_gesture,
48 callback); 49 callback);
49 } 50 }
50 51
52 ContentSetting ProtectedMediaIdentifierPermissionContext::GetPermissionStatus(
53 const GURL& requesting_origin,
54 const GURL& embedding_origin) const {
55 if (!IsProtectedMediaIdentifierEnabled())
56 return CONTENT_SETTING_BLOCK;
57
58 return PermissionContextBase::GetPermissionStatus(requesting_origin,
59 embedding_origin);
60 }
61
51 void ProtectedMediaIdentifierPermissionContext::UpdateTabContext( 62 void ProtectedMediaIdentifierPermissionContext::UpdateTabContext(
52 const PermissionRequestID& id, 63 const PermissionRequestID& id,
53 const GURL& requesting_frame, 64 const GURL& requesting_frame,
54 bool allowed) { 65 bool allowed) {
55 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 66 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
56 67
57 // WebContents may have gone away. 68 // WebContents may have gone away.
58 TabSpecificContentSettings* content_settings = 69 TabSpecificContentSettings* content_settings =
59 TabSpecificContentSettings::Get(id.render_process_id(), 70 TabSpecificContentSettings::Get(id.render_process_id(),
60 id.render_view_id()); 71 id.render_view_id());
61 if (content_settings) { 72 if (content_settings) {
62 content_settings->OnProtectedMediaIdentifierPermissionSet( 73 content_settings->OnProtectedMediaIdentifierPermissionSet(
63 requesting_frame.GetOrigin(), allowed); 74 requesting_frame.GetOrigin(), allowed);
64 } 75 }
65 76
66 } 77 }
78
79 // TODO(xhwang): We should consolidate the "protected content" related pref
80 // across platforms.
81 bool ProtectedMediaIdentifierPermissionContext::
82 IsProtectedMediaIdentifierEnabled() const {
83 bool enabled = false;
84
85 #if defined(OS_ANDROID)
86 enabled = profile()->GetPrefs()->GetBoolean(
87 prefs::kProtectedMediaIdentifierEnabled);
88 #endif
89
90 #if defined(OS_CHROMEOS)
91 // This could be disabled by the device policy.
92 bool enabled_for_device = false;
93 enabled = chromeos::CrosSettings::Get()->GetBoolean(
94 chromeos::kAttestationForContentProtectionEnabled,
95 &enabled_for_device) &&
96 enabled_for_device &&
97 profile()->GetPrefs()->GetBoolean(prefs::kEnableDRM);
98 #endif
99
100 DVLOG_IF(1, !enabled)
101 << "Protected media identifier disabled by the user or by device policy.";
102 return enabled;
103 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698