Index: webkit/media/crypto/proxy_decryptor.cc |
diff --git a/webkit/media/crypto/proxy_decryptor.cc b/webkit/media/crypto/proxy_decryptor.cc |
index 0c9646452325c69a2a93bbebbf586e4377f2ed70..876ccb3ade4aa89698b0e496914d3ddd2e4abc2d 100644 |
--- a/webkit/media/crypto/proxy_decryptor.cc |
+++ b/webkit/media/crypto/proxy_decryptor.cc |
@@ -9,11 +9,17 @@ |
#include "media/base/decryptor_client.h" |
#include "media/crypto/aes_decryptor.h" |
#include "webkit/media/crypto/key_systems.h" |
+#include "webkit/media/crypto/ppapi_decryptor.h" |
namespace webkit_media { |
-ProxyDecryptor::ProxyDecryptor(media::DecryptorClient* client) |
- : client_(client) { |
+ProxyDecryptor::ProxyDecryptor( |
+ media::DecryptorClient* decryptor_client, |
+ WebKit::WebMediaPlayerClient* web_media_player_client, |
+ WebKit::WebFrame* web_frame) |
+ : client_(decryptor_client), |
+ web_media_player_client_(web_media_player_client), |
+ web_frame_(web_frame) { |
} |
ProxyDecryptor::~ProxyDecryptor() { |
@@ -26,10 +32,18 @@ void ProxyDecryptor::GenerateKeyRequest(const std::string& key_system, |
// only creates a new decryptor when |decryptor_| is not initialized. |
if (!decryptor_.get()) { |
base::AutoLock auto_lock(lock_); |
- decryptor_ = CreateDecryptor(key_system, client_); |
+ decryptor_ = CreateDecryptor(key_system); |
+ } |
+ |
+ DCHECK(client_); |
+ if (!decryptor_.get()) { |
+ // TODO(ddorwin): Update the spec about generateKeyRequest to include an |
+ // error for handler loading failure. In our case, this can happen when the |
+ // plugin cannot be loaded. |
+ client_->KeyError(key_system, "", Decryptor::kUnknownError, 0); |
+ return; |
} |
- DCHECK(decryptor_.get()); |
decryptor_->GenerateKeyRequest(key_system, init_data, init_data_length); |
} |
@@ -67,4 +81,23 @@ void ProxyDecryptor::Decrypt( |
return decryptor->Decrypt(encrypted, decrypt_cb); |
} |
+scoped_ptr<media::Decryptor> ProxyDecryptor::CreateDecryptor( |
+ const std::string& key_system) { |
+ DCHECK(client_); |
+ DCHECK(web_media_player_client_); |
+ DCHECK(web_frame_); |
+ |
+ if (CanUseAesDecryptor(key_system)) |
+ return scoped_ptr<media::Decryptor>(new media::AesDecryptor(client_)); |
+ |
+ // For now, we only support AesDecryptor and PpapiDecryptor. So if we cannot |
ddorwin
2012/07/19 01:12:34
You can remove "For now, ".
xhwang
2012/07/19 15:54:34
Done.
|
+ // use the AesDecryptor, then we'll try to create a PpapiDecryptor for given |
+ // |key_system|. |
+ scoped_ptr<PpapiDecryptor> ppapi_decryptor(new PpapiDecryptor(client_)); |
+ if (ppapi_decryptor->Init(key_system, web_media_player_client_, web_frame_)) |
ddorwin
2012/07/19 01:12:34
Since we are creating and initializing a PpapiDecr
xhwang
2012/07/19 15:54:34
Done.
|
+ return scoped_ptr<media::Decryptor>(ppapi_decryptor.release()); |
+ |
+ return scoped_ptr<media::Decryptor>(); |
+} |
+ |
} // namespace webkit_media |