diff options
author | xhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-04 23:39:00 +0000 |
---|---|---|
committer | xhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-04 23:39:00 +0000 |
commit | 6d613d6dc13bf948f84f7494c6ee316a06d7c4e4 (patch) | |
tree | 7d1efaf3afe03cd5e2fee7df357247ced3a767ac /media/crypto | |
parent | 2432c058351cb5b4da6b1c5a9c756d1758c9ee5d (diff) | |
download | chromium_src-6d613d6dc13bf948f84f7494c6ee316a06d7c4e4.zip chromium_src-6d613d6dc13bf948f84f7494c6ee316a06d7c4e4.tar.gz chromium_src-6d613d6dc13bf948f84f7494c6ee316a06d7c4e4.tar.bz2 |
Encrypted Media: Allows empty key message to be fired.
This CL also changes the expected behavior of GenerateKeyRequest() of CleryKey key system when init_data is null. Previously it returns MediaKeyException (from render side) or fires KeyError (from plugin side). Now it fires an empty KeyMessage regardless. In the future the spec should be clear about this.
BUG=163785
TEST=media Layout test; media_unittests; content_browsertests
Review URL: https://chromiumcodereview.appspot.com/11348365
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171081 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/crypto')
-rw-r--r-- | media/crypto/aes_decryptor.cc | 16 | ||||
-rw-r--r-- | media/crypto/aes_decryptor_unittest.cc | 4 |
2 files changed, 11 insertions, 9 deletions
diff --git a/media/crypto/aes_decryptor.cc b/media/crypto/aes_decryptor.cc index 88d194e..a1dd46a 100644 --- a/media/crypto/aes_decryptor.cc +++ b/media/crypto/aes_decryptor.cc @@ -139,16 +139,16 @@ bool AesDecryptor::GenerateKeyRequest(const std::string& key_system, int init_data_length) { std::string session_id_string(base::UintToString(next_session_id_++)); - if (!init_data || !init_data_length) { - DVLOG(1) << "init_data required to generate a key request."; - return false; - } - // For now, the AesDecryptor does not care about |key_system| and |type|; // just fire the event with the |init_data| as the request. - int message_length = init_data_length; - scoped_array<uint8> message(new uint8[message_length]); - memcpy(message.get(), init_data, message_length); + scoped_array<uint8> message; + int message_length = 0; + + if (init_data && init_data_length) { + message_length = init_data_length; + message.reset(new uint8[message_length]); + memcpy(message.get(), init_data, message_length); + } client_->KeyMessage(key_system, session_id_string, message.Pass(), message_length, ""); diff --git a/media/crypto/aes_decryptor_unittest.cc b/media/crypto/aes_decryptor_unittest.cc index b6c9805..8a35b06 100644 --- a/media/crypto/aes_decryptor_unittest.cc +++ b/media/crypto/aes_decryptor_unittest.cc @@ -316,7 +316,9 @@ class AesDecryptorTest : public testing::Test { }; TEST_F(AesDecryptorTest, GenerateKeyRequestWithNullInitData) { - EXPECT_FALSE(decryptor_.GenerateKeyRequest(kClearKeySystem, "", NULL, 0)); + EXPECT_CALL(client_, KeyMessageMock(kClearKeySystem, StrNe(""), + IsNull(), 0, "")); + EXPECT_TRUE(decryptor_.GenerateKeyRequest(kClearKeySystem, "", NULL, 0)); } TEST_F(AesDecryptorTest, NormalWebMDecryption) { |