Commit 5f80e74c authored by xhwang's avatar xhwang Committed by Commit bot

media: Check kDisableInfobarForProtectedMediaIdentifier in...

media: Check kDisableInfobarForProtectedMediaIdentifier in ProtectedMediaIdentifierPermissionContext.

Previously this flag was checked in BrowserCdmManager. When this flag is set,
we would NOT check any preference and content setting related to protected
media identifier. Permission was granted blindly by default.

This CL moves the check to ProtectedMediaIdentifierPermissionContext. Now the
impact of this flag is more restrictive: only when the permission status is
"ASK" will we replace it with "ALLOW". This applies to both permission request
and permission check. If the permission is "BLOCKED" for any reason (e.g.
invalid origin, disabled by master switch, blocked in content setting), the
permission request/check will be blocked.

BUG=456219
TEST=Manually tested with and without the switch.

Review URL: https://codereview.chromium.org/1007163003

Cr-Commit-Position: refs/heads/master@{#320997}
parent 831563d9
......@@ -22,8 +22,11 @@
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/user_prefs/user_prefs.h"
#include "ui/views/widget/widget.h"
using chromeos::attestation::PlatformVerificationDialog;
#elif defined(OS_ANDROID)
#include "base/command_line.h"
#include "media/base/media_switches.h"
#else
#error This file currently only supports Chrome OS and Android.
#endif
ProtectedMediaIdentifierPermissionContext::
......@@ -42,6 +45,8 @@ ProtectedMediaIdentifierPermissionContext::
}
#if defined(OS_CHROMEOS)
using chromeos::attestation::PlatformVerificationDialog;
// static
void ProtectedMediaIdentifierPermissionContext::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* prefs) {
......@@ -98,6 +103,8 @@ void ProtectedMediaIdentifierPermissionContext::RequestPermission(
pending_requests_.insert(
std::make_pair(web_contents, std::make_pair(widget, id)));
#else
DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableInfobarForProtectedMediaIdentifier));
PermissionContextBase::RequestPermission(web_contents, id, requesting_origin,
user_gesture, callback);
#endif
......@@ -121,14 +128,20 @@ ContentSetting ProtectedMediaIdentifierPermissionContext::GetPermissionStatus(
content_setting == CONTENT_SETTING_ASK);
#if defined(OS_CHROMEOS)
if (content_setting == CONTENT_SETTING_ALLOW) {
// Check kRAConsentGranted here because it's possible that user dismissed
// the dialog triggered by RequestPermission() and the content setting is
// set to "allow" by server sync. In this case, we should still "ask".
if (profile()->GetPrefs()->GetBoolean(prefs::kRAConsentGranted))
return CONTENT_SETTING_ALLOW;
else
return CONTENT_SETTING_ASK;
// Check kRAConsentGranted here because it's possible that user dismissed
// the dialog triggered by RequestPermission() and the content setting is
// set to "allow" by server sync. In this case, we should still "ask".
if (content_setting == CONTENT_SETTING_ALLOW &&
!profile()->GetPrefs()->GetBoolean(prefs::kRAConsentGranted)) {
content_setting = CONTENT_SETTING_ASK;
}
#elif defined(OS_ANDROID)
// When kDisableInfobarForProtectedMediaIdentifier is enabled, do not "ask"
// the user and always "allow".
if (content_setting == CONTENT_SETTING_ASK &&
base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableInfobarForProtectedMediaIdentifier)) {
content_setting = CONTENT_SETTING_ALLOW;
}
#endif
......@@ -224,8 +237,7 @@ void ProtectedMediaIdentifierPermissionContext::
const GURL& requesting_origin,
const GURL& embedding_origin,
const BrowserPermissionCallback& callback,
chromeos::attestation::PlatformVerificationDialog::ConsentResponse
response) {
PlatformVerificationDialog::ConsentResponse response) {
// The request may have been canceled. Drop the callback in that case.
PendingRequestMap::iterator request = pending_requests_.find(web_contents);
if (request == pending_requests_.end())
......
......@@ -7,7 +7,6 @@
#include <string>
#include "base/bind.h"
#include "base/command_line.h"
#include "base/lazy_instance.h"
#include "base/memory/scoped_ptr.h"
#include "base/task_runner.h"
......@@ -18,12 +17,10 @@
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_switches.h"
#include "media/base/browser_cdm.h"
#include "media/base/browser_cdm_factory.h"
#include "media/base/cdm_promise.h"
#include "media/base/limits.h"
#include "media/base/media_switches.h"
namespace content {
......@@ -366,16 +363,6 @@ void BrowserCdmManager::OnCreateSessionAndGenerateRequest(
return;
}
#if defined(OS_ANDROID)
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableInfobarForProtectedMediaIdentifier)) {
CreateSessionAndGenerateRequestIfPermitted(
render_frame_id, cdm_id, eme_init_data_type, init_data, promise.Pass(),
true /* allowed */);
return;
}
#endif
BrowserCdm* cdm = GetCdm(render_frame_id, cdm_id);
if (!cdm) {
DLOG(WARNING) << "No CDM found for: " << render_frame_id << ", " << cdm_id;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment