| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/pepper/content_decryptor_delegate.h" | 5 #include "content/renderer/pepper/content_decryptor_delegate.h" |
| 6 | 6 |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "base/message_loop/message_loop_proxy.h" | 8 #include "base/message_loop/message_loop_proxy.h" |
| 9 #include "base/metrics/sparse_histogram.h" | 9 #include "base/metrics/sparse_histogram.h" |
| 10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 PP_FromBool(allow_distinctive_identifier), | 398 PP_FromBool(allow_distinctive_identifier), |
| 399 PP_FromBool(allow_persistent_state)); | 399 PP_FromBool(allow_persistent_state)); |
| 400 } | 400 } |
| 401 | 401 |
| 402 void ContentDecryptorDelegate::InstanceCrashed() { | 402 void ContentDecryptorDelegate::InstanceCrashed() { |
| 403 fatal_plugin_error_cb_.Run(); | 403 fatal_plugin_error_cb_.Run(); |
| 404 SatisfyAllPendingCallbacksOnError(); | 404 SatisfyAllPendingCallbacksOnError(); |
| 405 } | 405 } |
| 406 | 406 |
| 407 void ContentDecryptorDelegate::SetServerCertificate( | 407 void ContentDecryptorDelegate::SetServerCertificate( |
| 408 const uint8_t* certificate, | 408 const std::vector<uint8>& certificate, |
| 409 uint32_t certificate_length, | |
| 410 scoped_ptr<media::SimpleCdmPromise> promise) { | 409 scoped_ptr<media::SimpleCdmPromise> promise) { |
| 411 if (!certificate || | 410 if (certificate.size() < media::limits::kMinCertificateLength || |
| 412 certificate_length < media::limits::kMinCertificateLength || | 411 certificate.size() > media::limits::kMaxCertificateLength) { |
| 413 certificate_length > media::limits::kMaxCertificateLength) { | |
| 414 promise->reject( | 412 promise->reject( |
| 415 media::MediaKeys::INVALID_ACCESS_ERROR, 0, "Incorrect certificate."); | 413 media::MediaKeys::INVALID_ACCESS_ERROR, 0, "Incorrect certificate."); |
| 416 return; | 414 return; |
| 417 } | 415 } |
| 418 | 416 |
| 419 uint32_t promise_id = cdm_promise_adapter_.SavePromise(promise.Pass()); | 417 uint32_t promise_id = cdm_promise_adapter_.SavePromise(promise.Pass()); |
| 420 PP_Var certificate_array = | 418 PP_Var certificate_array = |
| 421 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( | 419 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( |
| 422 certificate_length, certificate); | 420 certificate.size(), vector_as_array(&certificate)); |
| 423 plugin_decryption_interface_->SetServerCertificate( | 421 plugin_decryption_interface_->SetServerCertificate( |
| 424 pp_instance_, promise_id, certificate_array); | 422 pp_instance_, promise_id, certificate_array); |
| 425 } | 423 } |
| 426 | 424 |
| 427 void ContentDecryptorDelegate::CreateSessionAndGenerateRequest( | 425 void ContentDecryptorDelegate::CreateSessionAndGenerateRequest( |
| 428 MediaKeys::SessionType session_type, | 426 MediaKeys::SessionType session_type, |
| 429 media::EmeInitDataType init_data_type, | 427 media::EmeInitDataType init_data_type, |
| 430 const uint8* init_data, | 428 const std::vector<uint8>& init_data, |
| 431 int init_data_length, | |
| 432 scoped_ptr<NewSessionCdmPromise> promise) { | 429 scoped_ptr<NewSessionCdmPromise> promise) { |
| 433 uint32_t promise_id = cdm_promise_adapter_.SavePromise(promise.Pass()); | 430 uint32_t promise_id = cdm_promise_adapter_.SavePromise(promise.Pass()); |
| 434 PP_Var init_data_array = | 431 PP_Var init_data_array = |
| 435 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( | 432 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( |
| 436 init_data_length, init_data); | 433 init_data.size(), vector_as_array(&init_data)); |
| 437 plugin_decryption_interface_->CreateSessionAndGenerateRequest( | 434 plugin_decryption_interface_->CreateSessionAndGenerateRequest( |
| 438 pp_instance_, promise_id, MediaSessionTypeToPpSessionType(session_type), | 435 pp_instance_, promise_id, MediaSessionTypeToPpSessionType(session_type), |
| 439 MediaInitDataTypeToPpInitDataType(init_data_type), init_data_array); | 436 MediaInitDataTypeToPpInitDataType(init_data_type), init_data_array); |
| 440 } | 437 } |
| 441 | 438 |
| 442 void ContentDecryptorDelegate::LoadSession( | 439 void ContentDecryptorDelegate::LoadSession( |
| 443 media::MediaKeys::SessionType session_type, | 440 media::MediaKeys::SessionType session_type, |
| 444 const std::string& session_id, | 441 const std::string& session_id, |
| 445 scoped_ptr<NewSessionCdmPromise> promise) { | 442 scoped_ptr<NewSessionCdmPromise> promise) { |
| 446 uint32_t promise_id = cdm_promise_adapter_.SavePromise(promise.Pass()); | 443 uint32_t promise_id = cdm_promise_adapter_.SavePromise(promise.Pass()); |
| 447 plugin_decryption_interface_->LoadSession( | 444 plugin_decryption_interface_->LoadSession( |
| 448 pp_instance_, promise_id, MediaSessionTypeToPpSessionType(session_type), | 445 pp_instance_, promise_id, MediaSessionTypeToPpSessionType(session_type), |
| 449 StringVar::StringToPPVar(session_id)); | 446 StringVar::StringToPPVar(session_id)); |
| 450 } | 447 } |
| 451 | 448 |
| 452 void ContentDecryptorDelegate::UpdateSession( | 449 void ContentDecryptorDelegate::UpdateSession( |
| 453 const std::string& session_id, | 450 const std::string& session_id, |
| 454 const uint8* response, | 451 const std::vector<uint8>& response, |
| 455 int response_length, | |
| 456 scoped_ptr<SimpleCdmPromise> promise) { | 452 scoped_ptr<SimpleCdmPromise> promise) { |
| 457 uint32_t promise_id = cdm_promise_adapter_.SavePromise(promise.Pass()); | 453 uint32_t promise_id = cdm_promise_adapter_.SavePromise(promise.Pass()); |
| 458 PP_Var response_array = | 454 PP_Var response_array = |
| 459 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( | 455 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( |
| 460 response_length, response); | 456 response.size(), vector_as_array(&response)); |
| 461 plugin_decryption_interface_->UpdateSession( | 457 plugin_decryption_interface_->UpdateSession( |
| 462 pp_instance_, promise_id, StringVar::StringToPPVar(session_id), | 458 pp_instance_, promise_id, StringVar::StringToPPVar(session_id), |
| 463 response_array); | 459 response_array); |
| 464 } | 460 } |
| 465 | 461 |
| 466 void ContentDecryptorDelegate::CloseSession( | 462 void ContentDecryptorDelegate::CloseSession( |
| 467 const std::string& session_id, | 463 const std::string& session_id, |
| 468 scoped_ptr<SimpleCdmPromise> promise) { | 464 scoped_ptr<SimpleCdmPromise> promise) { |
| 469 if (session_id.length() > media::limits::kMaxSessionIdLength) { | 465 if (session_id.length() > media::limits::kMaxSessionIdLength) { |
| 470 promise->reject( | 466 promise->reject( |
| (...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1288 empty_frames); | 1284 empty_frames); |
| 1289 } | 1285 } |
| 1290 | 1286 |
| 1291 if (!video_decode_cb_.is_null()) | 1287 if (!video_decode_cb_.is_null()) |
| 1292 video_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError, NULL); | 1288 video_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError, NULL); |
| 1293 | 1289 |
| 1294 cdm_promise_adapter_.Clear(); | 1290 cdm_promise_adapter_.Clear(); |
| 1295 } | 1291 } |
| 1296 | 1292 |
| 1297 } // namespace content | 1293 } // namespace content |
| OLD | NEW |