diff options
25 files changed, 68 insertions, 45 deletions
diff --git a/content/browser/media/android/browser_media_player_manager.cc b/content/browser/media/android/browser_media_player_manager.cc index 914bb9f..ceace36 100644 --- a/content/browser/media/android/browser_media_player_manager.cc +++ b/content/browser/media/android/browser_media_player_manager.cc @@ -365,16 +365,16 @@ void BrowserMediaPlayerManager::OnSessionMessage( int cdm_id, uint32 session_id, const std::vector<uint8>& message, - const std::string& destination_url) { - GURL destination_gurl(destination_url); - if (!destination_gurl.is_valid() && !destination_gurl.is_empty()) { + const GURL& destination_url) { + GURL verified_gurl = destination_url; + if (!verified_gurl.is_valid() && !verified_gurl.is_empty()) { DLOG(WARNING) << "SessionMessage destination_url is invalid : " - << destination_gurl.possibly_invalid_spec(); - destination_gurl = GURL::EmptyGURL(); // Replace invalid destination_url. + << destination_url.possibly_invalid_spec(); + verified_gurl = GURL::EmptyGURL(); // Replace invalid destination_url. } Send(new CdmMsg_SessionMessage( - RoutingID(), cdm_id, session_id, message, destination_gurl)); + RoutingID(), cdm_id, session_id, message, verified_gurl)); } void BrowserMediaPlayerManager::OnSessionReady(int cdm_id, uint32 session_id) { diff --git a/content/browser/media/android/browser_media_player_manager.h b/content/browser/media/android/browser_media_player_manager.h index fbc2487..8e69623 100644 --- a/content/browser/media/android/browser_media_player_manager.h +++ b/content/browser/media/android/browser_media_player_manager.h @@ -100,7 +100,7 @@ class CONTENT_EXPORT BrowserMediaPlayerManager virtual void OnSessionMessage(int cdm_id, uint32 session_id, const std::vector<uint8>& message, - const std::string& destination_url) OVERRIDE; + const GURL& destination_url) OVERRIDE; virtual void OnSessionReady(int cdm_id, uint32 session_id) OVERRIDE; virtual void OnSessionClosed(int cdm_id, uint32 session_id) OVERRIDE; virtual void OnSessionError(int cdm_id, diff --git a/content/renderer/media/android/proxy_media_keys.cc b/content/renderer/media/android/proxy_media_keys.cc index 68175c8..cf2642f 100644 --- a/content/renderer/media/android/proxy_media_keys.cc +++ b/content/renderer/media/android/proxy_media_keys.cc @@ -94,7 +94,7 @@ void ProxyMediaKeys::OnSessionCreated(uint32 session_id, void ProxyMediaKeys::OnSessionMessage(uint32 session_id, const std::vector<uint8>& message, - const std::string& destination_url) { + const GURL& destination_url) { session_message_cb_.Run(session_id, message, destination_url); } diff --git a/content/renderer/media/android/proxy_media_keys.h b/content/renderer/media/android/proxy_media_keys.h index afe1719..d515726 100644 --- a/content/renderer/media/android/proxy_media_keys.h +++ b/content/renderer/media/android/proxy_media_keys.h @@ -48,7 +48,7 @@ class ProxyMediaKeys : public media::MediaKeys { void OnSessionCreated(uint32 session_id, const std::string& web_session_id); void OnSessionMessage(uint32 session_id, const std::vector<uint8>& message, - const std::string& destination_url); + const GURL& destination_url); void OnSessionReady(uint32 session_id); void OnSessionClosed(uint32 session_id); void OnSessionError(uint32 session_id, diff --git a/content/renderer/media/android/renderer_media_player_manager.cc b/content/renderer/media/android/renderer_media_player_manager.cc index ea9fea4..3ca3ccc 100644 --- a/content/renderer/media/android/renderer_media_player_manager.cc +++ b/content/renderer/media/android/renderer_media_player_manager.cc @@ -322,7 +322,7 @@ void RendererMediaPlayerManager::OnSessionMessage( ProxyMediaKeys* media_keys = GetMediaKeys(cdm_id); if (media_keys) - media_keys->OnSessionMessage(session_id, message, destination_url.spec()); + media_keys->OnSessionMessage(session_id, message, destination_url); } void RendererMediaPlayerManager::OnSessionReady(int cdm_id, uint32 session_id) { diff --git a/content/renderer/media/cdm_session_adapter.cc b/content/renderer/media/cdm_session_adapter.cc index c369514..8e82cda 100644 --- a/content/renderer/media/cdm_session_adapter.cc +++ b/content/renderer/media/cdm_session_adapter.cc @@ -112,7 +112,7 @@ void CdmSessionAdapter::OnSessionCreated(uint32 session_id, void CdmSessionAdapter::OnSessionMessage(uint32 session_id, const std::vector<uint8>& message, - const std::string& destination_url) { + const GURL& destination_url) { WebContentDecryptionModuleSessionImpl* session = GetSession(session_id); DLOG_IF(WARNING, !session) << __FUNCTION__ << " for unknown session " << session_id; diff --git a/content/renderer/media/cdm_session_adapter.h b/content/renderer/media/cdm_session_adapter.h index 1756054..332f2fc 100644 --- a/content/renderer/media/cdm_session_adapter.h +++ b/content/renderer/media/cdm_session_adapter.h @@ -84,7 +84,7 @@ class CdmSessionAdapter : public base::RefCounted<CdmSessionAdapter> { void OnSessionCreated(uint32 session_id, const std::string& web_session_id); void OnSessionMessage(uint32 session_id, const std::vector<uint8>& message, - const std::string& destination_url); + const GURL& destination_url); void OnSessionReady(uint32 session_id); void OnSessionClosed(uint32 session_id); void OnSessionError(uint32 session_id, diff --git a/content/renderer/media/crypto/ppapi_decryptor.cc b/content/renderer/media/crypto/ppapi_decryptor.cc index 76d0203..7ab6cf9 100644 --- a/content/renderer/media/crypto/ppapi_decryptor.cc +++ b/content/renderer/media/crypto/ppapi_decryptor.cc @@ -361,7 +361,7 @@ void PpapiDecryptor::OnSessionCreated(uint32 session_id, void PpapiDecryptor::OnSessionMessage(uint32 session_id, const std::vector<uint8>& message, - const std::string& destination_url) { + const GURL& destination_url) { DCHECK(render_loop_proxy_->BelongsToCurrentThread()); session_message_cb_.Run(session_id, message, destination_url); } diff --git a/content/renderer/media/crypto/ppapi_decryptor.h b/content/renderer/media/crypto/ppapi_decryptor.h index 430c361..54caebb 100644 --- a/content/renderer/media/crypto/ppapi_decryptor.h +++ b/content/renderer/media/crypto/ppapi_decryptor.h @@ -93,7 +93,7 @@ class PpapiDecryptor : public media::MediaKeys, public media::Decryptor { void OnSessionCreated(uint32 session_id, const std::string& web_session_id); void OnSessionMessage(uint32 session_id, const std::vector<uint8>& message, - const std::string& destination_url); + const GURL& destination_url); void OnSessionReady(uint32 session_id); void OnSessionClosed(uint32 session_id); void OnSessionError(uint32 session_id, diff --git a/content/renderer/media/crypto/proxy_decryptor.cc b/content/renderer/media/crypto/proxy_decryptor.cc index 95fe49f..079304e 100644 --- a/content/renderer/media/crypto/proxy_decryptor.cc +++ b/content/renderer/media/crypto/proxy_decryptor.cc @@ -223,9 +223,10 @@ void ProxyDecryptor::OnSessionCreated(uint32 session_id, void ProxyDecryptor::OnSessionMessage(uint32 session_id, const std::vector<uint8>& message, - const std::string& destination_url) { + const GURL& destination_url) { // Assumes that OnSessionCreated() has been called before this. - key_message_cb_.Run(LookupWebSessionId(session_id), message, destination_url); + key_message_cb_.Run( + LookupWebSessionId(session_id), message, destination_url.spec()); } void ProxyDecryptor::OnSessionReady(uint32 session_id) { diff --git a/content/renderer/media/crypto/proxy_decryptor.h b/content/renderer/media/crypto/proxy_decryptor.h index 2919ef7..951b7c3 100644 --- a/content/renderer/media/crypto/proxy_decryptor.h +++ b/content/renderer/media/crypto/proxy_decryptor.h @@ -100,7 +100,7 @@ class ProxyDecryptor { void OnSessionCreated(uint32 session_id, const std::string& web_session_id); void OnSessionMessage(uint32 session_id, const std::vector<uint8>& message, - const std::string& default_url); + const GURL& default_url); void OnSessionReady(uint32 session_id); void OnSessionClosed(uint32 session_id); void OnSessionError(uint32 session_id, diff --git a/content/renderer/media/webcontentdecryptionmodulesession_impl.cc b/content/renderer/media/webcontentdecryptionmodulesession_impl.cc index 76935ae..343397f 100644 --- a/content/renderer/media/webcontentdecryptionmodulesession_impl.cc +++ b/content/renderer/media/webcontentdecryptionmodulesession_impl.cc @@ -71,10 +71,9 @@ void WebContentDecryptionModuleSessionImpl::OnSessionCreated( void WebContentDecryptionModuleSessionImpl::OnSessionMessage( const std::vector<uint8>& message, - const std::string& destination_url) { - client_->message(message.empty() ? NULL : &message[0], - message.size(), - GURL(destination_url)); + const GURL& destination_url) { + client_->message( + message.empty() ? NULL : &message[0], message.size(), destination_url); } void WebContentDecryptionModuleSessionImpl::OnSessionReady() { diff --git a/content/renderer/media/webcontentdecryptionmodulesession_impl.h b/content/renderer/media/webcontentdecryptionmodulesession_impl.h index add26ca..f61a713 100644 --- a/content/renderer/media/webcontentdecryptionmodulesession_impl.h +++ b/content/renderer/media/webcontentdecryptionmodulesession_impl.h @@ -42,7 +42,7 @@ class WebContentDecryptionModuleSessionImpl // Callbacks. void OnSessionCreated(const std::string& web_session_id); void OnSessionMessage(const std::vector<uint8>& message, - const std::string& destination_url); + const GURL& destination_url); void OnSessionReady(); void OnSessionClosed(); void OnSessionError(media::MediaKeys::KeyError error_code, diff --git a/content/renderer/pepper/content_decryptor_delegate.cc b/content/renderer/pepper/content_decryptor_delegate.cc index a36cf6f..38c0293 100644 --- a/content/renderer/pepper/content_decryptor_delegate.cc +++ b/content/renderer/pepper/content_decryptor_delegate.cc @@ -591,6 +591,7 @@ void ContentDecryptorDelegate::OnSessionCreated(uint32 session_id, void ContentDecryptorDelegate::OnSessionMessage(uint32 session_id, PP_Var message_var, PP_Var default_url_var) { + // TODO(amogh.bihani): Replace all the default_url with destination_url. if (session_message_cb_.is_null()) return; @@ -609,7 +610,14 @@ void ContentDecryptorDelegate::OnSessionMessage(uint32 session_id, return; } - session_message_cb_.Run(session_id, message, default_url_string->value()); + GURL verified_gurl = GURL(default_url_string->value()); + if (!verified_gurl.is_valid() && !verified_gurl.is_empty()) { + DLOG(WARNING) << "SessionMessage default_url is invalid : " + << verified_gurl.possibly_invalid_spec(); + verified_gurl = GURL::EmptyGURL(); // Replace invalid default_url. + } + + session_message_cb_.Run(session_id, message, verified_gurl); } void ContentDecryptorDelegate::OnSessionReady(uint32 session_id) { diff --git a/media/base/android/media_drm_bridge.cc b/media/base/android/media_drm_bridge.cc index 6b022df..e1f14dc 100644 --- a/media/base/android/media_drm_bridge.cc +++ b/media/base/android/media_drm_bridge.cc @@ -473,8 +473,13 @@ void MediaDrmBridge::OnSessionMessage(JNIEnv* env, uint32 session_id = j_session_id; std::vector<uint8> message; JavaByteArrayToByteVector(env, j_message, &message); - std::string destination_url = ConvertJavaStringToUTF8(env, j_destination_url); - session_message_cb_.Run(session_id, message, destination_url); + GURL destination_gurl = GURL(ConvertJavaStringToUTF8(env, j_destination_url)); + if (!destination_gurl.is_valid() && !destination_gurl.is_empty()) { + DLOG(WARNING) << "SessionMessage destination_url is invalid : " + << destination_gurl.possibly_invalid_spec(); + destination_gurl = GURL::EmptyGURL(); // Replace invalid destination_url. + } + session_message_cb_.Run(session_id, message, destination_gurl); } void MediaDrmBridge::OnSessionReady(JNIEnv* env, diff --git a/media/base/android/media_player_manager.h b/media/base/android/media_player_manager.h index 4666fb5..c7c996a 100644 --- a/media/base/android/media_player_manager.h +++ b/media/base/android/media_player_manager.h @@ -13,6 +13,9 @@ #include "media/base/android/demuxer_stream_player_params.h" #include "media/base/media_export.h" #include "media/base/media_keys.h" +#include "url/gurl.h" + +class GURL; namespace media { @@ -91,7 +94,7 @@ class MEDIA_EXPORT MediaPlayerManager { virtual void OnSessionMessage(int cdm_id, uint32 session_id, const std::vector<uint8>& message, - const std::string& destination_url) = 0; + const GURL& destination_url) = 0; // Called when CDM wants to send a Ready event. virtual void OnSessionReady(int cdm_id, uint32 session_id) = 0; diff --git a/media/base/android/media_source_player_unittest.cc b/media/base/android/media_source_player_unittest.cc index 546ffc0..db09b54 100644 --- a/media/base/android/media_source_player_unittest.cc +++ b/media/base/android/media_source_player_unittest.cc @@ -80,7 +80,7 @@ class MockMediaPlayerManager : public MediaPlayerManager { virtual void OnSessionMessage(int cdm_id, uint32 session_id, const std::vector<uint8>& message, - const std::string& destination_url) OVERRIDE {} + const GURL& destination_url) OVERRIDE {} virtual void OnSessionReady(int cdm_id, uint32 session_id) OVERRIDE {} virtual void OnSessionClosed(int cdm_id, uint32 session_id) OVERRIDE {} virtual void OnSessionError(int cdm_id, diff --git a/media/base/media_keys.h b/media/base/media_keys.h index 4af3581..3166063 100644 --- a/media/base/media_keys.h +++ b/media/base/media_keys.h @@ -12,6 +12,7 @@ #include "base/callback.h" #include "base/memory/scoped_ptr.h" #include "media/base/media_export.h" +#include "url/gurl.h" namespace media { @@ -82,11 +83,9 @@ typedef base::Callback< void(uint32 session_id, const std::string& web_session_id)> SessionCreatedCB; -// TODO(xhwang): Use GURL for |destination_url|. See http://crbug.com/372877 typedef base::Callback<void(uint32 session_id, const std::vector<uint8>& message, - const std::string& destination_url)> - SessionMessageCB; + const GURL& destination_url)> SessionMessageCB; typedef base::Callback<void(uint32 session_id)> SessionReadyCB; diff --git a/media/cdm/aes_decryptor.cc b/media/cdm/aes_decryptor.cc index 82c899d..51661fd 100644 --- a/media/cdm/aes_decryptor.cc +++ b/media/cdm/aes_decryptor.cc @@ -247,7 +247,7 @@ bool AesDecryptor::CreateSession(uint32 session_id, message.assign(init_data, init_data + init_data_length); session_created_cb_.Run(session_id, web_session_id_string); - session_message_cb_.Run(session_id, message, std::string()); + session_message_cb_.Run(session_id, message, GURL()); return true; } diff --git a/media/cdm/aes_decryptor_unittest.cc b/media/cdm/aes_decryptor_unittest.cc index 39a5036..3339fc5 100644 --- a/media/cdm/aes_decryptor_unittest.cc +++ b/media/cdm/aes_decryptor_unittest.cc @@ -23,6 +23,8 @@ using ::testing::StrNe; MATCHER(IsEmpty, "") { return arg.empty(); } +class GURL; + namespace media { const uint8 kOriginalData[] = "Original subsample data."; @@ -226,7 +228,7 @@ class AesDecryptorTest : public testing::Test { DCHECK(!key_id.empty()); uint32 session_id = next_session_id_++; EXPECT_CALL(*this, OnSessionCreated(session_id, StrNe(std::string()))); - EXPECT_CALL(*this, OnSessionMessage(session_id, key_id, "")); + EXPECT_CALL(*this, OnSessionMessage(session_id, key_id, GURL::EmptyGURL())); EXPECT_TRUE(decryptor_.CreateSession( session_id, std::string(), &key_id[0], key_id.size())); return session_id; @@ -328,7 +330,7 @@ class AesDecryptorTest : public testing::Test { MOCK_METHOD3(OnSessionMessage, void(uint32 session_id, const std::vector<uint8>& message, - const std::string& default_url)); + const GURL& default_url)); MOCK_METHOD1(OnSessionReady, void(uint32 session_id)); MOCK_METHOD1(OnSessionClosed, void(uint32 session_id)); MOCK_METHOD3(OnSessionError, @@ -354,24 +356,28 @@ class AesDecryptorTest : public testing::Test { TEST_F(AesDecryptorTest, CreateSessionWithNullInitData) { uint32 session_id = 8; - EXPECT_CALL(*this, OnSessionMessage(session_id, IsEmpty(), "")); + EXPECT_CALL(*this, + OnSessionMessage(session_id, IsEmpty(), GURL::EmptyGURL())); EXPECT_CALL(*this, OnSessionCreated(session_id, StrNe(std::string()))); EXPECT_TRUE(decryptor_.CreateSession(session_id, std::string(), NULL, 0)); } TEST_F(AesDecryptorTest, MultipleCreateSession) { uint32 session_id1 = 10; - EXPECT_CALL(*this, OnSessionMessage(session_id1, IsEmpty(), "")); + EXPECT_CALL(*this, + OnSessionMessage(session_id1, IsEmpty(), GURL::EmptyGURL())); EXPECT_CALL(*this, OnSessionCreated(session_id1, StrNe(std::string()))); EXPECT_TRUE(decryptor_.CreateSession(session_id1, std::string(), NULL, 0)); uint32 session_id2 = 11; - EXPECT_CALL(*this, OnSessionMessage(session_id2, IsEmpty(), "")); + EXPECT_CALL(*this, + OnSessionMessage(session_id2, IsEmpty(), GURL::EmptyGURL())); EXPECT_CALL(*this, OnSessionCreated(session_id2, StrNe(std::string()))); EXPECT_TRUE(decryptor_.CreateSession(session_id2, std::string(), NULL, 0)); uint32 session_id3 = 23; - EXPECT_CALL(*this, OnSessionMessage(session_id3, IsEmpty(), "")); + EXPECT_CALL(*this, + OnSessionMessage(session_id3, IsEmpty(), GURL::EmptyGURL())); EXPECT_CALL(*this, OnSessionCreated(session_id3, StrNe(std::string()))); EXPECT_TRUE(decryptor_.CreateSession(session_id3, std::string(), NULL, 0)); } 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 e98db7c..82e3b63 100644 --- a/media/cdm/ppapi/external_clear_key/clear_key_cdm.cc +++ b/media/cdm/ppapi/external_clear_key/clear_key_cdm.cc @@ -562,7 +562,7 @@ void ClearKeyCdm::OnSessionCreated(uint32 session_id, void ClearKeyCdm::OnSessionMessage(uint32 session_id, const std::vector<uint8>& message, - const std::string& destination_url) { + const GURL& destination_url) { DVLOG(1) << "OnSessionMessage: " << message.size(); // Ignore the message when we are waiting to update the loadable session. @@ -572,8 +572,8 @@ void ClearKeyCdm::OnSessionMessage(uint32 session_id, host_->OnSessionMessage(session_id, reinterpret_cast<const char*>(message.data()), message.size(), - destination_url.data(), - destination_url.size()); + destination_url.spec().data(), + destination_url.spec().size()); } void ClearKeyCdm::OnSessionReady(uint32 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 cef59db..d0ef3c7 100644 --- a/media/cdm/ppapi/external_clear_key/clear_key_cdm.h +++ b/media/cdm/ppapi/external_clear_key/clear_key_cdm.h @@ -76,7 +76,7 @@ class ClearKeyCdm : public ClearKeyCdmInterface { void OnSessionCreated(uint32 session_id, const std::string& web_session_id); void OnSessionMessage(uint32 session_id, const std::vector<uint8>& message, - const std::string& destination_url); + const GURL& destination_url); void OnSessionReady(uint32 session_id); void OnSessionClosed(uint32 session_id); void OnSessionError(uint32 session_id, diff --git a/media/filters/pipeline_integration_test.cc b/media/filters/pipeline_integration_test.cc index d3caa1e..8e42b8c 100644 --- a/media/filters/pipeline_integration_test.cc +++ b/media/filters/pipeline_integration_test.cc @@ -119,7 +119,7 @@ class FakeEncryptedMedia { virtual void OnSessionMessage(uint32 session_id, const std::vector<uint8>& message, - const std::string& destination_url) = 0; + const GURL& destination_url) = 0; virtual void OnSessionReady(uint32 session_id) = 0; @@ -161,7 +161,7 @@ class FakeEncryptedMedia { void OnSessionMessage(uint32 session_id, const std::vector<uint8>& message, - const std::string& destination_url) { + const GURL& destination_url) { app_->OnSessionMessage(session_id, message, destination_url); } @@ -202,7 +202,7 @@ class KeyProvidingApp : public FakeEncryptedMedia::AppBase { virtual void OnSessionMessage(uint32 session_id, const std::vector<uint8>& message, - const std::string& default_url) OVERRIDE { + const GURL& default_url) OVERRIDE { EXPECT_GT(session_id, 0u); EXPECT_FALSE(message.empty()); @@ -329,7 +329,7 @@ class NoResponseApp : public FakeEncryptedMedia::AppBase { virtual void OnSessionMessage(uint32 session_id, const std::vector<uint8>& message, - const std::string& default_url) OVERRIDE { + const GURL& default_url) OVERRIDE { EXPECT_GT(session_id, 0u); EXPECT_FALSE(message.empty()); FAIL() << "Unexpected KeyMessage"; diff --git a/media/media.gyp b/media/media.gyp index 4f6068b..38c871c 100644 --- a/media/media.gyp +++ b/media/media.gyp @@ -955,6 +955,7 @@ '../ui/base/ui_base.gyp:ui_base', '../ui/gfx/gfx.gyp:gfx', '../ui/gfx/gfx.gyp:gfx_geometry', + '../url/url.gyp:url_lib', ], 'sources': [ 'audio/android/audio_android_unittest.cc', diff --git a/media/media_cdm.gypi b/media/media_cdm.gypi index a4f968f..6f84ed5 100644 --- a/media/media_cdm.gypi +++ b/media/media_cdm.gypi @@ -76,6 +76,7 @@ 'defines': ['CDM_IMPLEMENTATION'], 'dependencies': [ 'media', + '../url/url.gyp:url_lib', # Include the following for media::AudioBus. 'shared_memory_support', '<(DEPTH)/base/base.gyp:base', |