Commit 992d832b authored by Xiaohan Wang's avatar Xiaohan Wang Committed by Commit Bot

media: Unify NotSupported message in key system config selection

This CL drops the error message parameter in the |not_supported_cb|
passed to KeySystemConfigSelector::SelectConfig() so that the error
message for not supported key system or config is always the same, as
specified in WebEncryptedMediaClientImpl::OnRequestNotSupported().

BUG=760720

Change-Id: I3dd6de9a112efe4dd753be1e38b510740523dc6a
Reviewed-on: https://chromium-review.googlesource.com/772968
Commit-Queue: Xiaohan Wang <xhwang@chromium.org>
Reviewed-by: default avatarDavid Dorwin <ddorwin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#516994}
parent cea1ee3e
......@@ -33,13 +33,6 @@ using EmeFeatureRequirement =
namespace {
// The rejection message when the key system is not supported or when none of
// the requested configurations is supported should always be the same to help
// avoid leaking internal information unnecessarily.
// See https://crbug.com/760720
const char kUnsupportedKeySystemOrConfigMessage[] =
"Unsupported keySystem or supportedConfigurations.";
static EmeConfigRule GetSessionTypeConfigRule(EmeSessionTypeSupport support) {
switch (support) {
case EmeSessionTypeSupport::INVALID:
......@@ -165,7 +158,7 @@ struct KeySystemConfigSelector::SelectionRequest {
blink::WebSecurityOrigin security_origin;
base::Callback<void(const blink::WebMediaKeySystemConfiguration&,
const CdmConfig&)> succeeded_cb;
base::Callback<void(const blink::WebString&)> not_supported_cb;
base::Closure not_supported_cb;
bool was_permission_requested = false;
bool is_permission_granted = false;
};
......@@ -860,7 +853,7 @@ void KeySystemConfigSelector::SelectConfig(
const blink::WebSecurityOrigin& security_origin,
base::Callback<void(const blink::WebMediaKeySystemConfiguration&,
const CdmConfig&)> succeeded_cb,
base::Callback<void(const blink::WebString&)> not_supported_cb) {
base::Closure not_supported_cb) {
// Continued from requestMediaKeySystemAccess(), step 6, from
// https://w3c.github.io/encrypted-media/#requestmediakeysystemaccess
//
......@@ -868,13 +861,13 @@ void KeySystemConfigSelector::SelectConfig(
// agent, reject promise with a NotSupportedError. String comparison
// is case-sensitive.
if (!key_system.ContainsOnlyASCII()) {
not_supported_cb.Run(kUnsupportedKeySystemOrConfigMessage);
not_supported_cb.Run();
return;
}
std::string key_system_ascii = key_system.Ascii();
if (!key_systems_->IsSupportedKeySystem(key_system_ascii)) {
not_supported_cb.Run(kUnsupportedKeySystemOrConfigMessage);
not_supported_cb.Run();
return;
}
......@@ -896,7 +889,7 @@ void KeySystemConfigSelector::SelectConfig(
// Therefore, always support Clear Key key system and only check settings for
// other key systems.
if (!is_encrypted_media_enabled && !IsClearKey(key_system_ascii)) {
not_supported_cb.Run(kUnsupportedKeySystemOrConfigMessage);
not_supported_cb.Run();
return;
}
......@@ -970,7 +963,7 @@ void KeySystemConfigSelector::SelectConfigInternal(
}
// 6.4. Reject promise with a NotSupportedError.
request->not_supported_cb.Run(kUnsupportedKeySystemOrConfigMessage);
request->not_supported_cb.Run();
}
void KeySystemConfigSelector::OnPermissionResult(
......
......@@ -46,7 +46,7 @@ class MEDIA_BLINK_EXPORT KeySystemConfigSelector {
const blink::WebSecurityOrigin& security_origin,
base::Callback<void(const blink::WebMediaKeySystemConfiguration&,
const CdmConfig&)> succeeded_cb,
base::Callback<void(const blink::WebString&)> not_supported_cb);
base::Closure not_supported_cb);
private:
struct SelectionRequest;
......
......@@ -276,7 +276,7 @@ class KeySystemConfigSelectorTest : public testing::Test {
config_ = result;
}
void OnNotSupported(const blink::WebString&) { not_supported_count_++; }
void OnNotSupported() { not_supported_count_++; }
std::unique_ptr<FakeKeySystems> key_systems_;
std::unique_ptr<FakeMediaPermission> media_permission_;
......
......@@ -152,9 +152,14 @@ void WebEncryptedMediaClientImpl::OnRequestSucceeded(
}
void WebEncryptedMediaClientImpl::OnRequestNotSupported(
blink::WebEncryptedMediaRequest request,
const blink::WebString& error_message) {
request.RequestNotSupported(error_message);
blink::WebEncryptedMediaRequest request) {
// The rejection message when the key system is not supported or when none of
// the requested configurations is supported should always be the same to help
// avoid leaking information unnecessarily. See https://crbug.com/760720
const char kUnsupportedKeySystemOrConfigMessage[] =
"Unsupported keySystem or supportedConfigurations.";
request.RequestNotSupported(kUnsupportedKeySystemOrConfigMessage);
}
WebEncryptedMediaClientImpl::Reporter* WebEncryptedMediaClientImpl::GetReporter(
......
......@@ -65,9 +65,8 @@ class MEDIA_BLINK_EXPORT WebEncryptedMediaClientImpl
const blink::WebMediaKeySystemConfiguration& accumulated_configuration,
const CdmConfig& cdm_config);
// Complete a requestMediaKeySystemAccess() request with an error message.
void OnRequestNotSupported(blink::WebEncryptedMediaRequest request,
const blink::WebString& error_message);
// Complete a requestMediaKeySystemAccess() request with a NotSupportedError.
void OnRequestNotSupported(blink::WebEncryptedMediaRequest request);
// Gets the Reporter for |key_system|. If it doesn't already exist,
// create one.
......
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