From c842f110b2b69639b4764e85d48dd404f6de8ee4 Mon Sep 17 00:00:00 2001 From: jrummell Date: Tue, 13 Jan 2015 16:34:32 -0800 Subject: [PATCH] Add |legacy_destination_url| back to SessionMessage for EME Recent changes to CDM_7 removed |destination_url| as it is no longer used in the EME spec. However legacy applications using the prefixed EME API depend on it, so adding it back in so that it is available to those applications. BUG=448242 TEST=existing EME tests pass + Play movies play Review URL: https://codereview.chromium.org/813683005 Cr-Commit-Position: refs/heads/master@{#311371} --- DEPS | 2 +- .../renderer/media/crypto/ppapi_decryptor.cc | 6 +- .../renderer/media/crypto/ppapi_decryptor.h | 3 +- .../renderer/media/crypto/proxy_media_keys.cc | 10 ++-- .../renderer/media/crypto/proxy_media_keys.h | 2 +- .../pepper/content_decryptor_delegate.cc | 19 +++++- .../pepper/content_decryptor_delegate.h | 3 +- .../pepper/pepper_plugin_instance_impl.cc | 7 ++- .../pepper/pepper_plugin_instance_impl.h | 3 +- media/base/media_keys.h | 3 +- media/blink/cdm_session_adapter.cc | 8 ++- media/blink/cdm_session_adapter.h | 3 +- media/cdm/aes_decryptor.cc | 4 +- media/cdm/aes_decryptor_unittest.cc | 20 ++++--- media/cdm/ppapi/cdm_adapter.cc | 59 +++++++++++++------ media/cdm/ppapi/cdm_adapter.h | 22 +++++-- .../ppapi/external_clear_key/clear_key_cdm.cc | 13 ++-- .../ppapi/external_clear_key/clear_key_cdm.h | 3 +- media/cdm/proxy_decryptor.cc | 11 ++-- media/cdm/proxy_decryptor.h | 3 +- .../content_decryption_module.mojom | 3 +- media/mojo/services/mojo_cdm.cc | 12 +++- media/mojo/services/mojo_cdm.h | 3 +- media/mojo/services/mojo_cdm_service.cc | 6 +- media/mojo/services/mojo_cdm_service.h | 3 +- media/test/pipeline_integration_test.cc | 15 +++-- .../private/ppb_content_decryptor_private.idl | 7 ++- .../c/private/ppb_content_decryptor_private.h | 9 ++- .../cpp/private/content_decryptor_private.cc | 11 ++-- ppapi/cpp/private/content_decryptor_private.h | 3 +- .../src/untrusted/pnacl_irt_shim/pnacl_shim.c | 6 +- ppapi/proxy/ppapi_messages.h | 5 +- ppapi/proxy/ppb_instance_proxy.cc | 15 +++-- ppapi/proxy/ppb_instance_proxy.h | 13 ++-- .../ppb_content_decryptor_private_thunk.cc | 7 ++- ppapi/thunk/ppb_instance_api.h | 3 +- 36 files changed, 215 insertions(+), 110 deletions(-) diff --git a/DEPS b/DEPS index bb20bde066ce0..0bc6ce499cc80 100644 --- a/DEPS +++ b/DEPS @@ -277,7 +277,7 @@ deps = { Var('chromium_git') + '/chromium/deps/opus.git' + '@' + 'cae696156f1e60006e39821e79a1811ae1933c69', 'src/media/cdm/ppapi/api': - Var('chromium_git') + '/chromium/cdm.git' + '@' + '4aca5940e0a4f25c8ab3a91ffed3a59b0f7f6800', # from svn revision 293568 + Var('chromium_git') + '/chromium/cdm.git' + '@' + '7b7c6cc620e13c8057b4b6bff19e5955feb2c8fa', # from svn revision 293617 'src/third_party/mesa/src': Var('chromium_git') + '/chromium/deps/mesa.git' + '@' + '071d25db04c23821a12a8b260ab9d96a097402f0', diff --git a/content/renderer/media/crypto/ppapi_decryptor.cc b/content/renderer/media/crypto/ppapi_decryptor.cc index 7e3d7776df6e5..75928dbecd7cd 100644 --- a/content/renderer/media/crypto/ppapi_decryptor.cc +++ b/content/renderer/media/crypto/ppapi_decryptor.cc @@ -388,9 +388,11 @@ void PpapiDecryptor::OnDecoderInitialized(StreamType stream_type, void PpapiDecryptor::OnSessionMessage(const std::string& web_session_id, MessageType message_type, - const std::vector& message) { + const std::vector& message, + const GURL& legacy_destination_url) { DCHECK(render_loop_proxy_->BelongsToCurrentThread()); - session_message_cb_.Run(web_session_id, message_type, message); + session_message_cb_.Run(web_session_id, message_type, message, + legacy_destination_url); } void PpapiDecryptor::OnSessionKeysChange(const std::string& web_session_id, diff --git a/content/renderer/media/crypto/ppapi_decryptor.h b/content/renderer/media/crypto/ppapi_decryptor.h index 05df5852bd98a..7c1e2ea765b4f 100644 --- a/content/renderer/media/crypto/ppapi_decryptor.h +++ b/content/renderer/media/crypto/ppapi_decryptor.h @@ -108,7 +108,8 @@ class PpapiDecryptor : public media::MediaKeys, // Callbacks for |plugin_cdm_delegate_| to fire session events. void OnSessionMessage(const std::string& web_session_id, MediaKeys::MessageType message_type, - const std::vector& message); + const std::vector& message, + const GURL& legacy_destination_url); void OnSessionKeysChange(const std::string& web_session_id, bool has_additional_usable_key, media::CdmKeysInfo keys_info); diff --git a/content/renderer/media/crypto/proxy_media_keys.cc b/content/renderer/media/crypto/proxy_media_keys.cc index e3867f1ddb25f..94fe5aa8e624e 100644 --- a/content/renderer/media/crypto/proxy_media_keys.cc +++ b/content/renderer/media/crypto/proxy_media_keys.cc @@ -161,14 +161,14 @@ void ProxyMediaKeys::OnSessionCreated(uint32 session_id, void ProxyMediaKeys::OnSessionMessage(uint32 session_id, const std::vector& message, - const GURL& destination_url) { + const GURL& legacy_destination_url) { // TODO(jrummell): Once |message_type| is passed, use it rather than // guessing from the URL. media::MediaKeys::MessageType message_type = - destination_url.is_empty() ? media::MediaKeys::LICENSE_REQUEST - : media::MediaKeys::LICENSE_RENEWAL; - session_message_cb_.Run(LookupWebSessionId(session_id), message_type, - message); + legacy_destination_url.is_empty() ? media::MediaKeys::LICENSE_REQUEST + : media::MediaKeys::LICENSE_RENEWAL; + session_message_cb_.Run(LookupWebSessionId(session_id), message_type, message, + legacy_destination_url); } void ProxyMediaKeys::OnSessionReady(uint32 session_id) { diff --git a/content/renderer/media/crypto/proxy_media_keys.h b/content/renderer/media/crypto/proxy_media_keys.h index 52eceeeef67f2..05f1cb59f416b 100644 --- a/content/renderer/media/crypto/proxy_media_keys.h +++ b/content/renderer/media/crypto/proxy_media_keys.h @@ -68,7 +68,7 @@ class ProxyMediaKeys : public media::MediaKeys, public media::CdmContext { void OnSessionCreated(uint32 session_id, const std::string& web_session_id); void OnSessionMessage(uint32 session_id, const std::vector& message, - const GURL& destination_url); + const GURL& legacy_destination_url); void OnSessionReady(uint32 session_id); void OnSessionClosed(uint32 session_id); void OnSessionError(uint32 session_id, diff --git a/content/renderer/pepper/content_decryptor_delegate.cc b/content/renderer/pepper/content_decryptor_delegate.cc index 239779983587c..cf0c3b230d4fa 100644 --- a/content/renderer/pepper/content_decryptor_delegate.cc +++ b/content/renderer/pepper/content_decryptor_delegate.cc @@ -742,7 +742,8 @@ void ContentDecryptorDelegate::OnPromiseRejected( void ContentDecryptorDelegate::OnSessionMessage(PP_Var web_session_id, PP_CdmMessageType message_type, - PP_Var message) { + PP_Var message, + PP_Var legacy_destination_url) { if (session_message_cb_.is_null()) return; @@ -756,9 +757,23 @@ void ContentDecryptorDelegate::OnSessionMessage(PP_Var web_session_id, message_vector.assign(data, data + message_array_buffer->ByteLength()); } + StringVar* destination_url_string = + StringVar::FromPPVar(legacy_destination_url); + if (!destination_url_string) { + NOTREACHED(); + return; + } + + GURL verified_gurl = GURL(destination_url_string->value()); + if (!verified_gurl.is_valid()) { + DLOG(WARNING) << "SessionMessage legacy_destination_url is invalid : " + << verified_gurl.possibly_invalid_spec(); + verified_gurl = GURL::EmptyGURL(); // Replace invalid destination_url. + } + session_message_cb_.Run(web_session_id_string->value(), PpCdmMessageTypeToMediaMessageType(message_type), - message_vector); + message_vector, verified_gurl); } void ContentDecryptorDelegate::OnSessionKeysChange( diff --git a/content/renderer/pepper/content_decryptor_delegate.h b/content/renderer/pepper/content_decryptor_delegate.h index 0b2900b93f47f..235bde1da400b 100644 --- a/content/renderer/pepper/content_decryptor_delegate.h +++ b/content/renderer/pepper/content_decryptor_delegate.h @@ -109,7 +109,8 @@ class ContentDecryptorDelegate { PP_Var error_description); void OnSessionMessage(PP_Var web_session_id, PP_CdmMessageType message_type, - PP_Var message); + PP_Var message, + PP_Var legacy_destination_url); void OnSessionKeysChange(PP_Var web_session_id, PP_Bool has_additional_usable_key, uint32_t key_count, diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.cc b/content/renderer/pepper/pepper_plugin_instance_impl.cc index edb356c453c11..586240cef25cd 100644 --- a/content/renderer/pepper/pepper_plugin_instance_impl.cc +++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc @@ -2427,9 +2427,10 @@ void PepperPluginInstanceImpl::PromiseRejected( void PepperPluginInstanceImpl::SessionMessage(PP_Instance instance, PP_Var web_session_id_var, PP_CdmMessageType message_type, - PP_Var message_var) { - content_decryptor_delegate_->OnSessionMessage(web_session_id_var, - message_type, message_var); + PP_Var message_var, + PP_Var legacy_destination_url) { + content_decryptor_delegate_->OnSessionMessage( + web_session_id_var, message_type, message_var, legacy_destination_url); } void PepperPluginInstanceImpl::SessionKeysChange( diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.h b/content/renderer/pepper/pepper_plugin_instance_impl.h index ffc8ebb69c5b4..3bfac15a930e4 100644 --- a/content/renderer/pepper/pepper_plugin_instance_impl.h +++ b/content/renderer/pepper/pepper_plugin_instance_impl.h @@ -479,7 +479,8 @@ class CONTENT_EXPORT PepperPluginInstanceImpl void SessionMessage(PP_Instance instance, PP_Var web_session_id_var, PP_CdmMessageType message_type, - PP_Var message_var) override; + PP_Var message_var, + PP_Var legacy_destination_url) override; void SessionKeysChange( PP_Instance instance, PP_Var web_session_id_var, diff --git a/media/base/media_keys.h b/media/base/media_keys.h index 78bf0513fb93f..733880ed91181 100644 --- a/media/base/media_keys.h +++ b/media/base/media_keys.h @@ -139,7 +139,8 @@ class MEDIA_EXPORT MediaKeys{ // https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/encrypted-media.html#event-summary typedef base::Callback& message)> + const std::vector& message, + const GURL& legacy_destination_url)> SessionMessageCB; typedef base::Callback SessionClosedCB; diff --git a/media/blink/cdm_session_adapter.cc b/media/blink/cdm_session_adapter.cc index 29fc8bb797de5..fba560e184133 100644 --- a/media/blink/cdm_session_adapter.cc +++ b/media/blink/cdm_session_adapter.cc @@ -117,9 +117,11 @@ const std::string& CdmSessionAdapter::GetKeySystemUMAPrefix() const { return key_system_uma_prefix_; } -void CdmSessionAdapter::OnSessionMessage(const std::string& web_session_id, - MediaKeys::MessageType message_type, - const std::vector& message) { +void CdmSessionAdapter::OnSessionMessage( + const std::string& web_session_id, + MediaKeys::MessageType message_type, + const std::vector& message, + const GURL& /* legacy_destination_url */) { WebContentDecryptionModuleSessionImpl* session = GetSession(web_session_id); DLOG_IF(WARNING, !session) << __FUNCTION__ << " for unknown session " << web_session_id; diff --git a/media/blink/cdm_session_adapter.h b/media/blink/cdm_session_adapter.h index 1f5a3c8c53570..768f1c419fe18 100644 --- a/media/blink/cdm_session_adapter.h +++ b/media/blink/cdm_session_adapter.h @@ -103,7 +103,8 @@ class CdmSessionAdapter : public base::RefCounted { // Callbacks for firing session events. void OnSessionMessage(const std::string& web_session_id, MediaKeys::MessageType message_type, - const std::vector& message); + const std::vector& message, + const GURL& legacy_destination_url); void OnSessionKeysChange(const std::string& web_session_id, bool has_additional_usable_key, CdmKeysInfo keys_info); diff --git a/media/cdm/aes_decryptor.cc b/media/cdm/aes_decryptor.cc index c531175cea723..7b94bd1001914 100644 --- a/media/cdm/aes_decryptor.cc +++ b/media/cdm/aes_decryptor.cc @@ -265,7 +265,9 @@ void AesDecryptor::CreateSessionAndGenerateRequest( promise->resolve(web_session_id); - session_message_cb_.Run(web_session_id, LICENSE_REQUEST, message); + // No URL needed for license requests. + session_message_cb_.Run(web_session_id, LICENSE_REQUEST, message, + GURL::EmptyGURL()); } void AesDecryptor::LoadSession(SessionType session_type, diff --git a/media/cdm/aes_decryptor_unittest.cc b/media/cdm/aes_decryptor_unittest.cc index cfa97b1b847fb..a630b02d13194 100644 --- a/media/cdm/aes_decryptor_unittest.cc +++ b/media/cdm/aes_decryptor_unittest.cc @@ -282,7 +282,8 @@ class AesDecryptorTest : public testing::Test { // Creates a new session using |key_id|. Returns the session ID. std::string CreateSession(const std::vector& key_id) { DCHECK(!key_id.empty()); - EXPECT_CALL(*this, OnSessionMessage(IsNotEmpty(), _, IsJSONDictionary())); + EXPECT_CALL(*this, OnSessionMessage(IsNotEmpty(), _, IsJSONDictionary(), + GURL::EmptyGURL())); decryptor_.CreateSessionAndGenerateRequest( MediaKeys::TEMPORARY_SESSION, std::string(), &key_id[0], key_id.size(), CreateSessionPromise(RESOLVED)); @@ -403,10 +404,11 @@ class AesDecryptorTest : public testing::Test { } } - MOCK_METHOD3(OnSessionMessage, + MOCK_METHOD4(OnSessionMessage, void(const std::string& web_session_id, MediaKeys::MessageType message_type, - const std::vector& message)); + const std::vector& message, + const GURL& legacy_destination_url)); MOCK_METHOD1(OnSessionClosed, void(const std::string& web_session_id)); AesDecryptor decryptor_; @@ -425,24 +427,28 @@ class AesDecryptorTest : public testing::Test { }; TEST_F(AesDecryptorTest, CreateSessionWithNullInitData) { - EXPECT_CALL(*this, OnSessionMessage(IsNotEmpty(), _, IsEmpty())); + EXPECT_CALL(*this, + OnSessionMessage(IsNotEmpty(), _, IsEmpty(), GURL::EmptyGURL())); decryptor_.CreateSessionAndGenerateRequest(MediaKeys::TEMPORARY_SESSION, std::string(), NULL, 0, CreateSessionPromise(RESOLVED)); } TEST_F(AesDecryptorTest, MultipleCreateSession) { - EXPECT_CALL(*this, OnSessionMessage(IsNotEmpty(), _, IsEmpty())); + EXPECT_CALL(*this, + OnSessionMessage(IsNotEmpty(), _, IsEmpty(), GURL::EmptyGURL())); decryptor_.CreateSessionAndGenerateRequest(MediaKeys::TEMPORARY_SESSION, std::string(), NULL, 0, CreateSessionPromise(RESOLVED)); - EXPECT_CALL(*this, OnSessionMessage(IsNotEmpty(), _, IsEmpty())); + EXPECT_CALL(*this, + OnSessionMessage(IsNotEmpty(), _, IsEmpty(), GURL::EmptyGURL())); decryptor_.CreateSessionAndGenerateRequest(MediaKeys::TEMPORARY_SESSION, std::string(), NULL, 0, CreateSessionPromise(RESOLVED)); - EXPECT_CALL(*this, OnSessionMessage(IsNotEmpty(), _, IsEmpty())); + EXPECT_CALL(*this, + OnSessionMessage(IsNotEmpty(), _, IsEmpty(), GURL::EmptyGURL())); decryptor_.CreateSessionAndGenerateRequest(MediaKeys::TEMPORARY_SESSION, std::string(), NULL, 0, CreateSessionPromise(RESOLVED)); diff --git a/media/cdm/ppapi/cdm_adapter.cc b/media/cdm/ppapi/cdm_adapter.cc index 1d36db9595365..00a2fe3958a02 100644 --- a/media/cdm/ppapi/cdm_adapter.cc +++ b/media/cdm/ppapi/cdm_adapter.cc @@ -715,11 +715,21 @@ void CdmAdapter::OnSessionMessage(const char* session_id, uint32_t session_id_size, cdm::MessageType message_type, const char* message, - uint32_t message_size) { + uint32_t message_size, + const char* legacy_destination_url, + uint32_t legacy_destination_url_size) { + // Only license renewals should specify |legacy_destination_url|. + // |legacy_destination_url| is not passed to unprefixed EME applications, + // so it can be removed when the prefixed API is removed. + PP_DCHECK(legacy_destination_url_size == 0 || + message_type == cdm::MessageType::kLicenseRenewal); + PostOnMain(callback_factory_.NewCallback( &CdmAdapter::SendSessionMessageInternal, - std::string(session_id, session_id_size), message_type, - std::vector(message, message + message_size))); + SessionMessage( + std::string(session_id, session_id_size), message_type, message, + message_size, + std::string(legacy_destination_url, legacy_destination_url_size)))); } // cdm::Host_6 only. @@ -729,16 +739,17 @@ void CdmAdapter::OnSessionMessage(const char* session_id, uint32_t message_size, const char* destination_url, uint32_t destination_url_size) { - // |destination_url| is no longer passed to EME applications, so it is - // dropped. All messages will appear as license renewals if |destination_url| - // is provided, license request if not. + // |destination_url| is no longer passed to unprefixed EME applications, + // so it will be dropped. All messages will appear as license renewals + // if |destination_url| is provided, license request if not. cdm::MessageType message_type = (destination_url_size > 0) ? cdm::MessageType::kLicenseRenewal : cdm::MessageType::kLicenseRequest; PostOnMain(callback_factory_.NewCallback( &CdmAdapter::SendSessionMessageInternal, - std::string(session_id, session_id_size), message_type, - std::vector(message, message + message_size))); + SessionMessage(std::string(session_id, session_id_size), message_type, + message, message_size, + std::string(destination_url, destination_url_size)))); } // cdm::Host_7 only. @@ -851,21 +862,19 @@ void CdmAdapter::SendPromiseRejectedInternal(int32_t result, error.error_description); } -void CdmAdapter::SendSessionMessageInternal( - int32_t result, - const std::string& session_id, - cdm::MessageType message_type, - const std::vector& message) { +void CdmAdapter::SendSessionMessageInternal(int32_t result, + const SessionMessage& message) { PP_DCHECK(result == PP_OK); - pp::VarArrayBuffer message_array_buffer(message.size()); - if (message.size() > 0) { - memcpy(message_array_buffer.Map(), message.data(), message.size()); + pp::VarArrayBuffer message_array_buffer(message.message.size()); + if (message.message.size() > 0) { + memcpy(message_array_buffer.Map(), message.message.data(), + message.message.size()); } pp::ContentDecryptor_Private::SessionMessage( - session_id, CdmMessageTypeToPpMessageType(message_type), - message_array_buffer); + message.session_id, CdmMessageTypeToPpMessageType(message.message_type), + message_array_buffer, message.legacy_destination_url); } void CdmAdapter::SendSessionClosedInternal(int32_t result, @@ -1300,12 +1309,24 @@ void CdmAdapter::QueryOutputProtectionStatusDone(int32_t result) { CdmAdapter::SessionError::SessionError(cdm::Error error, uint32_t system_code, - std::string error_description) + const std::string& error_description) : error(error), system_code(system_code), error_description(error_description) { } +CdmAdapter::SessionMessage::SessionMessage( + const std::string& session_id, + cdm::MessageType message_type, + const char* message, + uint32_t message_size, + const std::string& legacy_destination_url) + : session_id(session_id), + message_type(message_type), + message(message, message + message_size), + legacy_destination_url(legacy_destination_url) { +} + void* GetCdmHost(int host_interface_version, void* user_data) { if (!host_interface_version || !user_data) return NULL; diff --git a/media/cdm/ppapi/cdm_adapter.h b/media/cdm/ppapi/cdm_adapter.h index ef7bc20b9acf9..1fd5513509ca4 100644 --- a/media/cdm/ppapi/cdm_adapter.h +++ b/media/cdm/ppapi/cdm_adapter.h @@ -115,7 +115,9 @@ class CdmAdapter : public pp::Instance, uint32_t session_id_size, cdm::MessageType message_type, const char* message, - uint32_t message_size) override; + uint32_t message_size, + const char* legacy_destination_url, + uint32_t legacy_destination_url_size) override; void OnSessionKeysChange(const char* session_id, uint32_t session_id_size, bool has_additional_usable_key, @@ -164,12 +166,24 @@ class CdmAdapter : public pp::Instance, struct SessionError { SessionError(cdm::Error error, uint32_t system_code, - std::string error_description); + const std::string& error_description); cdm::Error error; uint32_t system_code; std::string error_description; }; + struct SessionMessage { + SessionMessage(const std::string& session_id, + cdm::MessageType message_type, + const char* message, + uint32_t message_size, + const std::string& legacy_destination_url); + std::string session_id; + cdm::MessageType message_type; + std::vector message; + std::string legacy_destination_url; + }; + bool CreateCdmInstance(const std::string& key_system); // PPB_ContentDecryptor_Private dispatchers. These are passed to @@ -183,9 +197,7 @@ class CdmAdapter : public pp::Instance, uint32_t promise_id, const SessionError& error); void SendSessionMessageInternal(int32_t result, - const std::string& session_id, - cdm::MessageType message_type, - const std::vector& message); + const SessionMessage& message); void SendSessionClosedInternal(int32_t result, const std::string& session_id); void SendSessionErrorInternal(int32_t result, const std::string& session_id, diff --git a/media/cdm/ppapi/external_clear_key/clear_key_cdm.cc b/media/cdm/ppapi/external_clear_key/clear_key_cdm.cc index 48b0bb063c0b7..c06c76ad3098a 100644 --- a/media/cdm/ppapi/external_clear_key/clear_key_cdm.cc +++ b/media/cdm/ppapi/external_clear_key/clear_key_cdm.cc @@ -671,7 +671,8 @@ void ClearKeyCdm::LoadLoadableSession() { void ClearKeyCdm::OnSessionMessage(const std::string& web_session_id, MediaKeys::MessageType message_type, - const std::vector& message) { + const std::vector& message, + const GURL& legacy_destination_url) { DVLOG(1) << "OnSessionMessage: " << message.size(); // Ignore the message when we are waiting to update the loadable session. @@ -682,13 +683,11 @@ void ClearKeyCdm::OnSessionMessage(const std::string& web_session_id, // involved (OnSessionCreated() called to resolve the CreateSession() // promise). // TODO(jrummell): Pass |message_type| on when this class is updated - // to Host_7. For now, pass NULL as the |destination_url| since we have - // no idea what it should be. - host_->OnSessionMessage(web_session_id.data(), - web_session_id.length(), + // to Host_7. + host_->OnSessionMessage(web_session_id.data(), web_session_id.length(), reinterpret_cast(message.data()), - message.size(), - nullptr, 0); + message.size(), legacy_destination_url.spec().data(), + legacy_destination_url.spec().size()); } void ClearKeyCdm::OnSessionKeysChange(const std::string& web_session_id, diff --git a/media/cdm/ppapi/external_clear_key/clear_key_cdm.h b/media/cdm/ppapi/external_clear_key/clear_key_cdm.h index 045cfdedbf3de..ebe847a06ea07 100644 --- a/media/cdm/ppapi/external_clear_key/clear_key_cdm.h +++ b/media/cdm/ppapi/external_clear_key/clear_key_cdm.h @@ -91,7 +91,8 @@ class ClearKeyCdm : public ClearKeyCdmInterface { // ContentDecryptionModule callbacks. void OnSessionMessage(const std::string& web_session_id, MediaKeys::MessageType message_type, - const std::vector& message); + const std::vector& message, + const GURL& legacy_destination_url); void OnSessionKeysChange(const std::string& web_session_id, bool has_additional_usable_key, CdmKeysInfo keys_info); diff --git a/media/cdm/proxy_decryptor.cc b/media/cdm/proxy_decryptor.cc index 15d438864ee1d..434988b78da2e 100644 --- a/media/cdm/proxy_decryptor.cc +++ b/media/cdm/proxy_decryptor.cc @@ -211,24 +211,21 @@ scoped_ptr ProxyDecryptor::CreateMediaKeys( void ProxyDecryptor::OnSessionMessage(const std::string& web_session_id, MediaKeys::MessageType message_type, - const std::vector& message) { + const std::vector& message, + const GURL& legacy_destination_url) { // Assumes that OnSessionCreated() has been called before this. - // EME v0.1b gets passed |destination_url| rather than |message_type|. - // Since we have no idea what the URL should be, return an empty one in all - // cases. - // For ClearKey, convert the message from JSON into just passing the key // as the message. If unable to extract the key, return the message unchanged. if (is_clear_key_) { std::vector key; if (ExtractFirstKeyIdFromLicenseRequest(message, &key)) { - key_message_cb_.Run(web_session_id, key, GURL()); + key_message_cb_.Run(web_session_id, key, legacy_destination_url); return; } } - key_message_cb_.Run(web_session_id, message, GURL()); + key_message_cb_.Run(web_session_id, message, legacy_destination_url); } void ProxyDecryptor::OnSessionKeysChange(const std::string& web_session_id, diff --git a/media/cdm/proxy_decryptor.h b/media/cdm/proxy_decryptor.h index 6b77ec0a1f4aa..cad57001e0f21 100644 --- a/media/cdm/proxy_decryptor.h +++ b/media/cdm/proxy_decryptor.h @@ -73,7 +73,8 @@ class MEDIA_EXPORT ProxyDecryptor { // Callbacks for firing session events. void OnSessionMessage(const std::string& web_session_id, MediaKeys::MessageType message_type, - const std::vector& message); + const std::vector& message, + const GURL& legacy_destination_url); void OnSessionKeysChange(const std::string& web_session_id, bool has_additional_usable_key, CdmKeysInfo keys_info); diff --git a/media/mojo/interfaces/content_decryption_module.mojom b/media/mojo/interfaces/content_decryption_module.mojom index aa3414df84080..aeee15bdf5d08 100644 --- a/media/mojo/interfaces/content_decryption_module.mojom +++ b/media/mojo/interfaces/content_decryption_module.mojom @@ -117,7 +117,8 @@ interface ContentDecryptionModule { // Session callbacks. See media/base/media_keys.h for details. interface ContentDecryptionModuleClient { - OnSessionMessage(string session_id, CdmMessageType message_type, array message); + OnSessionMessage(string session_id, CdmMessageType message_type, + array message, string legacy_destination_url); OnSessionClosed(string session_id); diff --git a/media/mojo/services/mojo_cdm.cc b/media/mojo/services/mojo_cdm.cc index efe7bacffc4fe..69d2046e2a27e 100644 --- a/media/mojo/services/mojo_cdm.cc +++ b/media/mojo/services/mojo_cdm.cc @@ -122,10 +122,18 @@ CdmContext* MojoCdm::GetCdmContext() { void MojoCdm::OnSessionMessage(const mojo::String& session_id, mojo::CdmMessageType message_type, - mojo::Array message) { + mojo::Array message, + const mojo::String& legacy_destination_url) { + GURL verified_gurl = GURL(legacy_destination_url); + if (!verified_gurl.is_valid() && !verified_gurl.is_empty()) { + DLOG(WARNING) << "SessionMessage destination_url is invalid : " + << verified_gurl.possibly_invalid_spec(); + verified_gurl = GURL::EmptyGURL(); // Replace invalid destination_url. + } + session_message_cb_.Run(session_id, static_cast(message_type), - message.storage()); + message.storage(), verified_gurl); } void MojoCdm::OnSessionClosed(const mojo::String& session_id) { diff --git a/media/mojo/services/mojo_cdm.h b/media/mojo/services/mojo_cdm.h index 4fda2ac74ea1d..4083728221025 100644 --- a/media/mojo/services/mojo_cdm.h +++ b/media/mojo/services/mojo_cdm.h @@ -59,7 +59,8 @@ class MojoCdm : public MediaKeys, public mojo::ContentDecryptionModuleClient { // mojo::ContentDecryptionModuleClient implementation. void OnSessionMessage(const mojo::String& session_id, mojo::CdmMessageType message_type, - mojo::Array message) final; + mojo::Array message, + const mojo::String& legacy_destination_url) final; void OnSessionClosed(const mojo::String& session_id) final; void OnSessionError(const mojo::String& session_id, mojo::CdmException exception, diff --git a/media/mojo/services/mojo_cdm_service.cc b/media/mojo/services/mojo_cdm_service.cc index e53d43e010394..17c3919e681c8 100644 --- a/media/mojo/services/mojo_cdm_service.cc +++ b/media/mojo/services/mojo_cdm_service.cc @@ -108,10 +108,12 @@ void MojoCdmService::GetCdmContext( void MojoCdmService::OnSessionMessage(const std::string& session_id, MediaKeys::MessageType message_type, - const std::vector& message) { + const std::vector& message, + const GURL& legacy_destination_url) { client()->OnSessionMessage(session_id, static_cast(message_type), - mojo::Array::From(message)); + mojo::Array::From(message), + mojo::String::From(legacy_destination_url)); } void MojoCdmService::OnSessionKeysChange(const std::string& session_id, diff --git a/media/mojo/services/mojo_cdm_service.h b/media/mojo/services/mojo_cdm_service.h index bccd8e19358a9..da8f372df80b0 100644 --- a/media/mojo/services/mojo_cdm_service.h +++ b/media/mojo/services/mojo_cdm_service.h @@ -53,7 +53,8 @@ class MojoCdmService // Callbacks for firing session events. void OnSessionMessage(const std::string& session_id, MediaKeys::MessageType message_type, - const std::vector& message); + const std::vector& message, + const GURL& legacy_destination_url); void OnSessionKeysChange(const std::string& session_id, bool has_additional_usable_key, CdmKeysInfo keys_info); diff --git a/media/test/pipeline_integration_test.cc b/media/test/pipeline_integration_test.cc index f6ef9619a0bee..1f616a5c5b890 100644 --- a/media/test/pipeline_integration_test.cc +++ b/media/test/pipeline_integration_test.cc @@ -148,7 +148,8 @@ class FakeEncryptedMedia { virtual void OnSessionMessage(const std::string& web_session_id, MediaKeys::MessageType message_type, - const std::vector& message) = 0; + const std::vector& message, + const GURL& legacy_destination_url) = 0; virtual void OnSessionClosed(const std::string& web_session_id) = 0; @@ -184,8 +185,10 @@ class FakeEncryptedMedia { // Callbacks for firing session events. Delegate to |app_|. void OnSessionMessage(const std::string& web_session_id, MediaKeys::MessageType message_type, - const std::vector& message) { - app_->OnSessionMessage(web_session_id, message_type, message); + const std::vector& message, + const GURL& legacy_destination_url) { + app_->OnSessionMessage(web_session_id, message_type, message, + legacy_destination_url); } void OnSessionClosed(const std::string& web_session_id) { @@ -280,7 +283,8 @@ class KeyProvidingApp : public FakeEncryptedMedia::AppBase { void OnSessionMessage(const std::string& web_session_id, MediaKeys::MessageType message_type, - const std::vector& message) override { + const std::vector& message, + const GURL& legacy_destination_url) override { EXPECT_FALSE(web_session_id.empty()); EXPECT_FALSE(message.empty()); EXPECT_EQ(current_session_id_, web_session_id); @@ -406,7 +410,8 @@ class NoResponseApp : public FakeEncryptedMedia::AppBase { public: void OnSessionMessage(const std::string& web_session_id, MediaKeys::MessageType message_type, - const std::vector& message) override { + const std::vector& message, + const GURL& legacy_destination_url) override { EXPECT_FALSE(web_session_id.empty()); EXPECT_FALSE(message.empty()); FAIL() << "Unexpected Message"; diff --git a/ppapi/api/private/ppb_content_decryptor_private.idl b/ppapi/api/private/ppb_content_decryptor_private.idl index 49cc0b37042dd..10f998aa41ba7 100644 --- a/ppapi/api/private/ppb_content_decryptor_private.idl +++ b/ppapi/api/private/ppb_content_decryptor_private.idl @@ -89,12 +89,17 @@ interface PPB_ContentDecryptor_Private { * * @param[in] message A PP_Var of type * PP_VARTYPE_ARRAY_BUFFER that contains the message. + * + * @param[in] legacy_destination_url A PP_Var of type + * PP_VARTYPE_STRING containing the destination URL for the + * message. */ void SessionMessage( [in] PP_Instance instance, [in] PP_Var web_session_id, [in] PP_CdmMessageType message_type, - [in] PP_Var message); + [in] PP_Var message, + [in] PP_Var legacy_destination_url); /** * The keys for a session have changed. diff --git a/ppapi/c/private/ppb_content_decryptor_private.h b/ppapi/c/private/ppb_content_decryptor_private.h index 3b7d309955fbe..da331176efaff 100644 --- a/ppapi/c/private/ppb_content_decryptor_private.h +++ b/ppapi/c/private/ppb_content_decryptor_private.h @@ -4,7 +4,7 @@ */ /* From private/ppb_content_decryptor_private.idl, - * modified Wed Jan 7 16:48:10 2015. + * modified Mon Jan 12 17:33:29 2015. */ #ifndef PPAPI_C_PRIVATE_PPB_CONTENT_DECRYPTOR_PRIVATE_H_ @@ -102,11 +102,16 @@ struct PPB_ContentDecryptor_Private_0_13 { * * @param[in] message A PP_Var of type * PP_VARTYPE_ARRAY_BUFFER that contains the message. + * + * @param[in] legacy_destination_url A PP_Var of type + * PP_VARTYPE_STRING containing the destination URL for the + * message. */ void (*SessionMessage)(PP_Instance instance, struct PP_Var web_session_id, PP_CdmMessageType message_type, - struct PP_Var message); + struct PP_Var message, + struct PP_Var legacy_destination_url); /** * The keys for a session have changed. * diff --git a/ppapi/cpp/private/content_decryptor_private.cc b/ppapi/cpp/private/content_decryptor_private.cc index d64d502e1468a..68fc61ec06cc1 100644 --- a/ppapi/cpp/private/content_decryptor_private.cc +++ b/ppapi/cpp/private/content_decryptor_private.cc @@ -308,14 +308,17 @@ void ContentDecryptor_Private::PromiseRejected( } } -void ContentDecryptor_Private::SessionMessage(const std::string& web_session_id, - PP_CdmMessageType message_type, - pp::VarArrayBuffer message) { +void ContentDecryptor_Private::SessionMessage( + const std::string& web_session_id, + PP_CdmMessageType message_type, + pp::VarArrayBuffer message, + const std::string& legacy_destination_url) { if (has_interface()) { pp::Var web_session_id_var(web_session_id); + pp::Var legacy_destination_url_var(legacy_destination_url); get_interface()->SessionMessage( associated_instance_.pp_instance(), web_session_id_var.pp_var(), - message_type, message.pp_var()); + message_type, message.pp_var(), legacy_destination_url_var.pp_var()); } } diff --git a/ppapi/cpp/private/content_decryptor_private.h b/ppapi/cpp/private/content_decryptor_private.h index 0117c72dfa333..589c3a7b3e568 100644 --- a/ppapi/cpp/private/content_decryptor_private.h +++ b/ppapi/cpp/private/content_decryptor_private.h @@ -81,7 +81,8 @@ class ContentDecryptor_Private { const std::string& error_description); void SessionMessage(const std::string& web_session_id, PP_CdmMessageType message_type, - pp::VarArrayBuffer message); + pp::VarArrayBuffer message, + const std::string& legacy_destination_url); void SessionKeysChange(const std::string& web_session_id, bool has_additional_usable_key, const std::vector& key_information); diff --git a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c index 6212a7b2e79f7..2fc23c331261f 100644 --- a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c +++ b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c @@ -2899,9 +2899,9 @@ static void Pnacl_M41_PPB_ContentDecryptor_Private_PromiseRejected(PP_Instance i iface->PromiseRejected(instance, promise_id, exception_code, system_code, *error_description); } -static void Pnacl_M41_PPB_ContentDecryptor_Private_SessionMessage(PP_Instance instance, struct PP_Var* web_session_id, PP_CdmMessageType message_type, struct PP_Var* message) { +static void Pnacl_M41_PPB_ContentDecryptor_Private_SessionMessage(PP_Instance instance, struct PP_Var* web_session_id, PP_CdmMessageType message_type, struct PP_Var* message, struct PP_Var* legacy_destination_url) { const struct PPB_ContentDecryptor_Private_0_13 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_13.real_iface; - iface->SessionMessage(instance, *web_session_id, message_type, *message); + iface->SessionMessage(instance, *web_session_id, message_type, *message, *legacy_destination_url); } static void Pnacl_M41_PPB_ContentDecryptor_Private_SessionKeysChange(PP_Instance instance, struct PP_Var* web_session_id, PP_Bool has_additional_usable_key, uint32_t key_count, const struct PP_KeyInformation key_information[]) { @@ -5440,7 +5440,7 @@ static const struct PPB_ContentDecryptor_Private_0_13 Pnacl_Wrappers_PPB_Content .PromiseResolved = (void (*)(PP_Instance instance, uint32_t promise_id))&Pnacl_M41_PPB_ContentDecryptor_Private_PromiseResolved, .PromiseResolvedWithSession = (void (*)(PP_Instance instance, uint32_t promise_id, struct PP_Var web_session_id))&Pnacl_M41_PPB_ContentDecryptor_Private_PromiseResolvedWithSession, .PromiseRejected = (void (*)(PP_Instance instance, uint32_t promise_id, PP_CdmExceptionCode exception_code, uint32_t system_code, struct PP_Var error_description))&Pnacl_M41_PPB_ContentDecryptor_Private_PromiseRejected, - .SessionMessage = (void (*)(PP_Instance instance, struct PP_Var web_session_id, PP_CdmMessageType message_type, struct PP_Var message))&Pnacl_M41_PPB_ContentDecryptor_Private_SessionMessage, + .SessionMessage = (void (*)(PP_Instance instance, struct PP_Var web_session_id, PP_CdmMessageType message_type, struct PP_Var message, struct PP_Var legacy_destination_url))&Pnacl_M41_PPB_ContentDecryptor_Private_SessionMessage, .SessionKeysChange = (void (*)(PP_Instance instance, struct PP_Var web_session_id, PP_Bool has_additional_usable_key, uint32_t key_count, const struct PP_KeyInformation key_information[]))&Pnacl_M41_PPB_ContentDecryptor_Private_SessionKeysChange, .SessionExpirationChange = (void (*)(PP_Instance instance, struct PP_Var web_session_id, PP_Time new_expiry_time))&Pnacl_M41_PPB_ContentDecryptor_Private_SessionExpirationChange, .SessionClosed = (void (*)(PP_Instance instance, struct PP_Var web_session_id))&Pnacl_M41_PPB_ContentDecryptor_Private_SessionClosed, diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index c8995275d4b66..2b881ce6aae3a 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -1134,11 +1134,12 @@ IPC_MESSAGE_ROUTED5(PpapiHostMsg_PPBInstance_PromiseRejected, PP_CdmExceptionCode /* exception_code */, int32_t /* system_code */, ppapi::proxy::SerializedVar /* error_description, String */) -IPC_MESSAGE_ROUTED4(PpapiHostMsg_PPBInstance_SessionMessage, +IPC_MESSAGE_ROUTED5(PpapiHostMsg_PPBInstance_SessionMessage, PP_Instance /* instance */, ppapi::proxy::SerializedVar /* web_session_id, String */, PP_CdmMessageType /* message_type */, - ppapi::proxy::SerializedVar /* message, ArrayBuffer */) + ppapi::proxy::SerializedVar /* message, ArrayBuffer */, + ppapi::proxy::SerializedVar /* destination_url, String */) IPC_MESSAGE_ROUTED4(PpapiHostMsg_PPBInstance_SessionKeysChange, PP_Instance /* instance */, std::string /* web_session_id */, diff --git a/ppapi/proxy/ppb_instance_proxy.cc b/ppapi/proxy/ppb_instance_proxy.cc index 32ee8b2dea7ce..31cdb04d762dc 100644 --- a/ppapi/proxy/ppb_instance_proxy.cc +++ b/ppapi/proxy/ppb_instance_proxy.cc @@ -600,11 +600,13 @@ void PPB_Instance_Proxy::PromiseRejected(PP_Instance instance, void PPB_Instance_Proxy::SessionMessage(PP_Instance instance, PP_Var web_session_id_var, PP_CdmMessageType message_type, - PP_Var message_var) { + PP_Var message_var, + PP_Var legacy_destination_url_var) { dispatcher()->Send(new PpapiHostMsg_PPBInstance_SessionMessage( API_ID_PPB_INSTANCE, instance, SerializedVarSendInput(dispatcher(), web_session_id_var), message_type, - SerializedVarSendInput(dispatcher(), message_var))); + SerializedVarSendInput(dispatcher(), message_var), + SerializedVarSendInput(dispatcher(), legacy_destination_url_var))); } void PPB_Instance_Proxy::SessionKeysChange( @@ -1274,14 +1276,15 @@ void PPB_Instance_Proxy::OnHostMsgSessionMessage( PP_Instance instance, SerializedVarReceiveInput web_session_id, PP_CdmMessageType message_type, - SerializedVarReceiveInput message) { + SerializedVarReceiveInput message, + SerializedVarReceiveInput legacy_destination_url) { if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE)) return; EnterInstanceNoLock enter(instance); if (enter.succeeded()) { - enter.functions()->SessionMessage(instance, - web_session_id.Get(dispatcher()), - message_type, message.Get(dispatcher())); + enter.functions()->SessionMessage( + instance, web_session_id.Get(dispatcher()), message_type, + message.Get(dispatcher()), legacy_destination_url.Get(dispatcher())); } } diff --git a/ppapi/proxy/ppb_instance_proxy.h b/ppapi/proxy/ppb_instance_proxy.h index d6ed5c4e50429..6a0a3b25b588b 100644 --- a/ppapi/proxy/ppb_instance_proxy.h +++ b/ppapi/proxy/ppb_instance_proxy.h @@ -144,7 +144,8 @@ class PPB_Instance_Proxy : public InterfaceProxy, virtual void SessionMessage(PP_Instance instance, PP_Var web_session_id_var, PP_CdmMessageType message_type, - PP_Var message_var) override; + PP_Var message_var, + PP_Var legacy_destination_url_var) override; virtual void SessionKeysChange( PP_Instance instance, PP_Var web_session_id_var, @@ -273,10 +274,12 @@ class PPB_Instance_Proxy : public InterfaceProxy, PP_CdmExceptionCode exception_code, uint32_t system_code, SerializedVarReceiveInput error_description); - virtual void OnHostMsgSessionMessage(PP_Instance instance, - SerializedVarReceiveInput web_session_id, - PP_CdmMessageType message_type, - SerializedVarReceiveInput message); + virtual void OnHostMsgSessionMessage( + PP_Instance instance, + SerializedVarReceiveInput web_session_id, + PP_CdmMessageType message_type, + SerializedVarReceiveInput message, + SerializedVarReceiveInput legacy_destination_url); virtual void OnHostMsgSessionKeysChange( PP_Instance instance, const std::string& web_session_id, diff --git a/ppapi/thunk/ppb_content_decryptor_private_thunk.cc b/ppapi/thunk/ppb_content_decryptor_private_thunk.cc index 6f359f3acc8ee..fd2adde5422f5 100644 --- a/ppapi/thunk/ppb_content_decryptor_private_thunk.cc +++ b/ppapi/thunk/ppb_content_decryptor_private_thunk.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// From private/ppb_content_decryptor_private.idl modified Wed Jan 7 16:48:10 +// From private/ppb_content_decryptor_private.idl modified Mon Jan 12 17:33:29 // 2015. #include "ppapi/c/pp_errors.h" @@ -51,13 +51,14 @@ void PromiseRejected(PP_Instance instance, void SessionMessage(PP_Instance instance, struct PP_Var web_session_id, PP_CdmMessageType message_type, - struct PP_Var message) { + struct PP_Var message, + struct PP_Var legacy_destination_url) { VLOG(4) << "PPB_ContentDecryptor_Private::SessionMessage()"; EnterInstance enter(instance); if (enter.failed()) return; enter.functions()->SessionMessage(instance, web_session_id, message_type, - message); + message, legacy_destination_url); } void SessionKeysChange(PP_Instance instance, diff --git a/ppapi/thunk/ppb_instance_api.h b/ppapi/thunk/ppb_instance_api.h index 5f84de5cc0add..b0fccbd0c3264 100644 --- a/ppapi/thunk/ppb_instance_api.h +++ b/ppapi/thunk/ppb_instance_api.h @@ -174,7 +174,8 @@ class PPB_Instance_API { virtual void SessionMessage(PP_Instance instance, PP_Var web_session_id_var, PP_CdmMessageType message_type, - PP_Var message_var) = 0; + PP_Var message_var, + PP_Var legacy_destination_url_var) = 0; virtual void SessionKeysChange( PP_Instance instance, PP_Var web_session_id_var,