diff options
author | John Rummell <jrummell@chromium.org> | 2015-01-16 10:34:01 -0800 |
---|---|---|
committer | John Rummell <jrummell@chromium.org> | 2015-01-16 18:36:55 +0000 |
commit | e9359a9c0dea092dba0c2617142609491ef52cea (patch) | |
tree | 160977f304bd5fc73f59c922337248f853d22b72 | |
parent | baaaf5f4958ee3b337f79601a55c64f3ce6154b0 (diff) | |
download | chromium_src-e9359a9c0dea092dba0c2617142609491ef52cea.zip chromium_src-e9359a9c0dea092dba0c2617142609491ef52cea.tar.gz chromium_src-e9359a9c0dea092dba0c2617142609491ef52cea.tar.bz2 |
Merge: 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}
(cherry picked from commit c842f110b2b69639b4764e85d48dd404f6de8ee4)
TBR=dmichael@chromium.org, xhwang@chromium.org, dcheng@chromium.org
Review URL: https://codereview.chromium.org/836263004
Cr-Commit-Position: refs/branch-heads/2272@{#34}
Cr-Branched-From: 827a380cfdb31aa54c8d56e63ce2c3fd8c3ba4d4-refs/heads/master@{#310958}
36 files changed, 215 insertions, 110 deletions
@@ -285,7 +285,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 7e3d777..75928db 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<uint8>& message) { + const std::vector<uint8>& 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 05df585..7c1e2ea 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<uint8>& message); + const std::vector<uint8>& 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 e3867f1..94fe5aa 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<uint8>& 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 52eceee..05f1cb5 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<uint8>& 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 b085c8a..48a843d 100644 --- a/content/renderer/pepper/content_decryptor_delegate.cc +++ b/content/renderer/pepper/content_decryptor_delegate.cc @@ -767,7 +767,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; @@ -781,9 +782,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 0b2900b..235bde1 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 d949daf..f288373 100644 --- a/content/renderer/pepper/pepper_plugin_instance_impl.cc +++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc @@ -2429,9 +2429,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 ffc8ebb..3bfac15 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 78bf051..733880e 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<void(const std::string& web_session_id, MediaKeys::MessageType message_type, - const std::vector<uint8>& message)> + const std::vector<uint8>& message, + const GURL& legacy_destination_url)> SessionMessageCB; typedef base::Callback<void(const std::string& web_session_id)> SessionClosedCB; diff --git a/media/blink/cdm_session_adapter.cc b/media/blink/cdm_session_adapter.cc index 29fc8bb..fba560e 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<uint8>& message) { +void CdmSessionAdapter::OnSessionMessage( + const std::string& web_session_id, + MediaKeys::MessageType message_type, + const std::vector<uint8>& 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 1f5a3c8..768f1c4 100644 --- a/media/blink/cdm_session_adapter.h +++ b/media/blink/cdm_session_adapter.h @@ -103,7 +103,8 @@ class CdmSessionAdapter : public base::RefCounted<CdmSessionAdapter> { // Callbacks for firing session events. void OnSessionMessage(const std::string& web_session_id, MediaKeys::MessageType message_type, - const std::vector<uint8>& message); + const std::vector<uint8>& 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 f4993be..d510b98 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 cfa97b1..a630b02 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<uint8>& 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<uint8>& message)); + const std::vector<uint8>& 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 1d36db9..00a2fe3 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<uint8_t>(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<uint8_t>(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<uint8_t>& 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 ef7bc20..1fd5513 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<uint8_t> message; + std::string legacy_destination_url; + }; + bool CreateCdmInstance(const std::string& key_system); // <code>PPB_ContentDecryptor_Private</code> 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<uint8_t>& 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 48b0bb0..c06c76a 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<uint8>& message) { + const std::vector<uint8>& 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<const char*>(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 045cfde..ebe847a 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<uint8>& message); + const std::vector<uint8>& 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 15d4388..434988b 100644 --- a/media/cdm/proxy_decryptor.cc +++ b/media/cdm/proxy_decryptor.cc @@ -211,24 +211,21 @@ scoped_ptr<MediaKeys> ProxyDecryptor::CreateMediaKeys( void ProxyDecryptor::OnSessionMessage(const std::string& web_session_id, MediaKeys::MessageType message_type, - const std::vector<uint8>& message) { + const std::vector<uint8>& 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<uint8> 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 6b77ec0..cad5700 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<uint8>& message); + const std::vector<uint8>& 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 aa3414df8..aeee15b 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<uint8> message); + OnSessionMessage(string session_id, CdmMessageType message_type, + array<uint8> 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 efe7bac..69d2046 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<uint8_t> message) { + mojo::Array<uint8_t> 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<MediaKeys::MessageType>(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 4fda2ac..4083728 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<uint8_t> message) final; + mojo::Array<uint8_t> 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 e53d43e0..17c3919 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<uint8_t>& message) { + const std::vector<uint8_t>& message, + const GURL& legacy_destination_url) { client()->OnSessionMessage(session_id, static_cast<mojo::CdmMessageType>(message_type), - mojo::Array<uint8_t>::From(message)); + mojo::Array<uint8_t>::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 bccd8e1..da8f372 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<uint8_t>& message); + const std::vector<uint8_t>& 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 f6ef961..1f616a5 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<uint8>& message) = 0; + const std::vector<uint8>& 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<uint8>& message) { - app_->OnSessionMessage(web_session_id, message_type, message); + const std::vector<uint8>& 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<uint8>& message) override { + const std::vector<uint8>& 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<uint8>& message) override { + const std::vector<uint8>& 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 49cc0b3..10f998a 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 <code>PP_Var</code> of type * <code>PP_VARTYPE_ARRAY_BUFFER</code> that contains the message. + * + * @param[in] legacy_destination_url A <code>PP_Var</code> of type + * <code>PP_VARTYPE_STRING</code> 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 3b7d309..da33117 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 <code>PP_Var</code> of type * <code>PP_VARTYPE_ARRAY_BUFFER</code> that contains the message. + * + * @param[in] legacy_destination_url A <code>PP_Var</code> of type + * <code>PP_VARTYPE_STRING</code> 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 d64d502..68fc61e 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<PPB_ContentDecryptor_Private>()) { pp::Var web_session_id_var(web_session_id); + pp::Var legacy_destination_url_var(legacy_destination_url); get_interface<PPB_ContentDecryptor_Private>()->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 0117c72..589c3a7 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<PP_KeyInformation>& 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 6212a7b..2fc23c3 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 c899527..2b881ce 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 32ee8b2..31cdb04 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 d6ed5c4..6a0a3b2 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 6f359f3..fd2adde 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 5f84de5..b0fccbd 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, |