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

Unified 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, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/media/protected_media_identifier_permission_context.cc
diff --git a/chrome/browser/media/protected_media_identifier_permission_context.cc b/chrome/browser/media/protected_media_identifier_permission_context.cc
index 4ca5630d14e2ac9984f8e04265c2931109ceab8e..990be4c913e70ad32e41955653b9c0b37cf8ebbb 100644
--- a/chrome/browser/media/protected_media_identifier_permission_context.cc
+++ b/chrome/browser/media/protected_media_identifier_permission_context.cc
@@ -12,6 +12,11 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
+#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/settings/cros_settings.h"
+#include "chromeos/settings/cros_settings_names.h"
+#endif
+
ProtectedMediaIdentifierPermissionContext::
ProtectedMediaIdentifierPermissionContext(Profile* profile)
: PermissionContextBase(profile,
@@ -30,17 +35,13 @@ void ProtectedMediaIdentifierPermissionContext::RequestPermission(
const BrowserPermissionCallback& callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
-#if defined(OS_ANDROID)
- // Check if the protected media identifier master switch is disabled.
- if (!profile()->GetPrefs()->GetBoolean(
- prefs::kProtectedMediaIdentifierEnabled)) {
+ if (!IsProtectedMediaIdentifierEnabled()) {
NotifyPermissionSet(id,
requesting_frame_origin,
web_contents->GetLastCommittedURL().GetOrigin(),
callback, false, false);
return;
}
-#endif
PermissionContextBase::RequestPermission(web_contents, id,
requesting_frame_origin,
@@ -48,6 +49,16 @@ void ProtectedMediaIdentifierPermissionContext::RequestPermission(
callback);
}
+ContentSetting ProtectedMediaIdentifierPermissionContext::GetPermissionStatus(
+ const GURL& requesting_origin,
+ const GURL& embedding_origin) const {
+ if (!IsProtectedMediaIdentifierEnabled())
+ return CONTENT_SETTING_BLOCK;
+
+ return PermissionContextBase::GetPermissionStatus(requesting_origin,
+ embedding_origin);
+}
+
void ProtectedMediaIdentifierPermissionContext::UpdateTabContext(
const PermissionRequestID& id,
const GURL& requesting_frame,
@@ -64,3 +75,29 @@ void ProtectedMediaIdentifierPermissionContext::UpdateTabContext(
}
}
+
+// TODO(xhwang): We should consolidate the "protected content" related pref
+// across platforms.
+bool ProtectedMediaIdentifierPermissionContext::
+ IsProtectedMediaIdentifierEnabled() const {
+ bool enabled = false;
+
+#if defined(OS_ANDROID)
+ enabled = profile()->GetPrefs()->GetBoolean(
+ prefs::kProtectedMediaIdentifierEnabled);
+#endif
+
+#if defined(OS_CHROMEOS)
+ // This could be disabled by the device policy.
+ bool enabled_for_device = false;
+ enabled = chromeos::CrosSettings::Get()->GetBoolean(
+ chromeos::kAttestationForContentProtectionEnabled,
+ &enabled_for_device) &&
+ enabled_for_device &&
+ profile()->GetPrefs()->GetBoolean(prefs::kEnableDRM);
+#endif
+
+ DVLOG_IF(1, !enabled)
+ << "Protected media identifier disabled by the user or by device policy.";
+ return enabled;
+}

Powered by Google App Engine
This is Rietveld 408576698