Chromium Code Reviews| Index: content/renderer/pepper/content_decryptor_delegate.cc |
| diff --git a/content/renderer/pepper/content_decryptor_delegate.cc b/content/renderer/pepper/content_decryptor_delegate.cc |
| index e1b0b1ba3e5d1100275908abf15dd578ec1b86a9..26127fdbf9d8d12f676488791e3e4a8191ff9631 100644 |
| --- a/content/renderer/pepper/content_decryptor_delegate.cc |
| +++ b/content/renderer/pepper/content_decryptor_delegate.cc |
| @@ -20,6 +20,7 @@ |
| #include "media/base/video_decoder_config.h" |
| #include "media/base/video_frame.h" |
| #include "media/base/video_util.h" |
| +#include "ppapi/shared_impl/array_var.h" |
| #include "ppapi/shared_impl/scoped_pp_resource.h" |
| #include "ppapi/shared_impl/var.h" |
| #include "ppapi/shared_impl/var_tracker.h" |
| @@ -29,10 +30,12 @@ |
| using media::CdmPromise; |
| using media::Decryptor; |
| +using media::KeyIdsPromise; |
| using media::MediaKeys; |
| using media::NewSessionCdmPromise; |
| using media::SimpleCdmPromise; |
| using ppapi::ArrayBufferVar; |
| +using ppapi::ArrayVar; |
| using ppapi::PpapiGlobals; |
| using ppapi::ScopedPPResource; |
| using ppapi::StringVar; |
| @@ -330,6 +333,18 @@ void ContentDecryptorDelegate::InstanceCrashed() { |
| SatisfyAllPendingCallbacksOnError(); |
| } |
| +void ContentDecryptorDelegate::SetServerCertificate( |
| + const uint8* certificate, |
| + int certificate_length, |
| + scoped_ptr<media::SimpleCdmPromise> promise) { |
| + uint32_t promise_id = SavePromise(promise.PassAs<CdmPromise>()); |
| + PP_Var certificate_array = |
| + PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( |
| + certificate_length, certificate); |
| + plugin_decryption_interface_->SetServerCertificate( |
| + pp_instance_, promise_id, certificate_array); |
| +} |
| + |
| void ContentDecryptorDelegate::CreateSession( |
| const std::string& init_data_type, |
| const uint8* init_data, |
| @@ -372,11 +387,27 @@ void ContentDecryptorDelegate::UpdateSession( |
| response_array); |
| } |
| -void ContentDecryptorDelegate::ReleaseSession( |
| +void ContentDecryptorDelegate::GetUsableKeyIds( |
| + const std::string& web_session_id, |
| + scoped_ptr<media::KeyIdsPromise> promise) { |
| + uint32_t promise_id = SavePromise(promise.PassAs<CdmPromise>()); |
| + plugin_decryption_interface_->GetUsableKeyIds( |
| + pp_instance_, promise_id, StringVar::StringToPPVar(web_session_id)); |
| +} |
| + |
| +void ContentDecryptorDelegate::CloseSession( |
| + const std::string& web_session_id, |
| + scoped_ptr<SimpleCdmPromise> promise) { |
| + uint32_t promise_id = SavePromise(promise.PassAs<CdmPromise>()); |
| + plugin_decryption_interface_->CloseSession( |
| + pp_instance_, promise_id, StringVar::StringToPPVar(web_session_id)); |
| +} |
| + |
| +void ContentDecryptorDelegate::RemoveSession( |
| const std::string& web_session_id, |
| scoped_ptr<SimpleCdmPromise> promise) { |
| uint32_t promise_id = SavePromise(promise.PassAs<CdmPromise>()); |
| - plugin_decryption_interface_->ReleaseSession( |
| + plugin_decryption_interface_->RemoveSession( |
| pp_instance_, promise_id, StringVar::StringToPPVar(web_session_id)); |
| } |
| @@ -647,6 +678,31 @@ void ContentDecryptorDelegate::OnPromiseResolvedWithSession( |
| } |
| } |
| +void ContentDecryptorDelegate::OnPromiseResolvedWithKeyIds(uint32 promise_id, |
| + PP_Var key_ids) { |
|
ddorwin
2014/08/22 20:49:20
..._array?
jrummell
2014/08/25 21:54:36
Done.
|
| + scoped_ptr<CdmPromise> promise = TakePromise(promise_id); |
| + |
| + ArrayVar* key_ids_array = ArrayVar::FromPPVar(key_ids); |
| + media::KeyIdsVector key_ids_vector; |
| + if (key_ids_array) { |
|
ddorwin
2014/08/22 20:49:20
DCHECK? Or can this be null if the array is empty?
jrummell
2014/08/25 21:54:36
Done.
|
| + for (size_t i = 0; i < key_ids_array->GetLength(); ++i) { |
| + ArrayBufferVar* array_buffer = |
| + ArrayBufferVar::FromPPVar(key_ids_array->Get(i)); |
| + if (array_buffer) { |
|
ddorwin
2014/08/22 20:49:20
DCHECK?
jrummell
2014/08/25 21:54:36
Done.
|
| + std::vector<uint8> item; |
|
ddorwin
2014/08/22 20:49:20
How about key_id?
jrummell
2014/08/25 21:54:36
Done.
|
| + const uint8* data = static_cast<const uint8*>(array_buffer->Map()); |
| + item.assign(data, data + array_buffer->ByteLength()); |
| + key_ids_vector.push_back(item); |
| + } |
| + } |
| + } |
| + |
| + if (promise) { |
|
ddorwin
2014/08/22 20:49:20
DCHECK?
I wonder why existing code does not have t
jrummell
2014/08/25 21:54:36
The other OnPromise...() do check that promise is
|
| + KeyIdsPromise* key_ids_promise(static_cast<KeyIdsPromise*>(promise.get())); |
|
ddorwin
2014/08/22 20:49:20
This promise ID is coming from a plugin process, w
jrummell
2014/08/25 21:54:36
Added type on CdmPromise so it can be verified.
|
| + key_ids_promise->resolve(key_ids_vector); |
| + } |
| +} |
| + |
| void ContentDecryptorDelegate::OnPromiseRejected( |
| uint32 promise_id, |
| PP_CdmExceptionCode exception_code, |
| @@ -693,6 +749,18 @@ void ContentDecryptorDelegate::OnSessionMessage(PP_Var web_session_id, |
| web_session_id_string->value(), message_vector, verified_gurl); |
| } |
| +void ContentDecryptorDelegate::OnSessionKeysChange( |
| + PP_Var web_session_id, |
| + PP_Bool has_additional_usable_key) { |
| + // TODO(jrummell): Pass this event on. |
| +} |
| + |
| +void ContentDecryptorDelegate::OnSessionExpirationChange( |
| + PP_Var web_session_id, |
| + PP_Time new_expiry_time) { |
| + // TODO(jrummell): Pass this event on. |
| +} |
| + |
| void ContentDecryptorDelegate::OnSessionReady(PP_Var web_session_id) { |
| if (session_ready_cb_.is_null()) |
| return; |