| 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 "ppapi/proxy/ppp_content_decryptor_private_proxy.h" | 5 #include "ppapi/proxy/ppp_content_decryptor_private_proxy.h" |
| 6 | 6 |
| 7 #include "base/files/file.h" | 7 #include "base/files/file.h" |
| 8 #include "media/base/limits.h" | 8 #include "media/base/limits.h" |
| 9 #include "ppapi/c/pp_bool.h" | 9 #include "ppapi/c/pp_bool.h" |
| 10 #include "ppapi/c/ppb_core.h" | 10 #include "ppapi/c/ppb_core.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 std::vector<uint8_t> server_certificate_vector( | 153 std::vector<uint8_t> server_certificate_vector( |
| 154 server_certificate_ptr, server_certificate_ptr + server_certificate_size); | 154 server_certificate_ptr, server_certificate_ptr + server_certificate_size); |
| 155 | 155 |
| 156 dispatcher->Send(new PpapiMsg_PPPContentDecryptor_SetServerCertificate( | 156 dispatcher->Send(new PpapiMsg_PPPContentDecryptor_SetServerCertificate( |
| 157 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, | 157 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, |
| 158 instance, | 158 instance, |
| 159 promise_id, | 159 promise_id, |
| 160 server_certificate_vector)); | 160 server_certificate_vector)); |
| 161 } | 161 } |
| 162 | 162 |
| 163 void CreateSession(PP_Instance instance, | 163 void CreateSessionAndGenerateRequest(PP_Instance instance, |
| 164 uint32_t promise_id, | 164 uint32_t promise_id, |
| 165 PP_Var init_data_type, | 165 PP_SessionType session_type, |
| 166 PP_Var init_data, | 166 PP_Var init_data_type, |
| 167 PP_SessionType session_type) { | 167 PP_Var init_data) { |
| 168 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); | 168 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); |
| 169 if (!dispatcher) { | 169 if (!dispatcher) { |
| 170 NOTREACHED(); | 170 NOTREACHED(); |
| 171 return; | 171 return; |
| 172 } | 172 } |
| 173 | 173 |
| 174 dispatcher->Send(new PpapiMsg_PPPContentDecryptor_CreateSession( | 174 dispatcher->Send( |
| 175 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, | 175 new PpapiMsg_PPPContentDecryptor_CreateSessionAndGenerateRequest( |
| 176 instance, | 176 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, instance, promise_id, |
| 177 promise_id, | 177 session_type, SerializedVarSendInput(dispatcher, init_data_type), |
| 178 SerializedVarSendInput(dispatcher, init_data_type), | 178 SerializedVarSendInput(dispatcher, init_data))); |
| 179 SerializedVarSendInput(dispatcher, init_data), | |
| 180 session_type)); | |
| 181 } | 179 } |
| 182 | 180 |
| 183 void LoadSession(PP_Instance instance, | 181 void LoadSession(PP_Instance instance, |
| 184 uint32_t promise_id, | 182 uint32_t promise_id, |
| 183 PP_SessionType session_type, |
| 185 PP_Var web_session_id) { | 184 PP_Var web_session_id) { |
| 186 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); | 185 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); |
| 187 if (!dispatcher) { | 186 if (!dispatcher) { |
| 188 NOTREACHED(); | 187 NOTREACHED(); |
| 189 return; | 188 return; |
| 190 } | 189 } |
| 191 | 190 |
| 192 dispatcher->Send(new PpapiMsg_PPPContentDecryptor_LoadSession( | 191 dispatcher->Send(new PpapiMsg_PPPContentDecryptor_LoadSession( |
| 193 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, | 192 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, instance, promise_id, session_type, |
| 194 instance, | |
| 195 promise_id, | |
| 196 SerializedVarSendInput(dispatcher, web_session_id))); | 193 SerializedVarSendInput(dispatcher, web_session_id))); |
| 197 } | 194 } |
| 198 | 195 |
| 199 void UpdateSession(PP_Instance instance, | 196 void UpdateSession(PP_Instance instance, |
| 200 uint32_t promise_id, | 197 uint32_t promise_id, |
| 201 PP_Var web_session_id, | 198 PP_Var web_session_id, |
| 202 PP_Var response) { | 199 PP_Var response) { |
| 203 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); | 200 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); |
| 204 if (!dispatcher) { | 201 if (!dispatcher) { |
| 205 NOTREACHED(); | 202 NOTREACHED(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 return; | 250 return; |
| 254 } | 251 } |
| 255 | 252 |
| 256 dispatcher->Send(new PpapiMsg_PPPContentDecryptor_RemoveSession( | 253 dispatcher->Send(new PpapiMsg_PPPContentDecryptor_RemoveSession( |
| 257 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, | 254 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, |
| 258 instance, | 255 instance, |
| 259 promise_id, | 256 promise_id, |
| 260 session_id->value())); | 257 session_id->value())); |
| 261 } | 258 } |
| 262 | 259 |
| 263 void GetUsableKeyIds(PP_Instance instance, | |
| 264 uint32_t promise_id, | |
| 265 PP_Var web_session_id) { | |
| 266 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); | |
| 267 if (!dispatcher) { | |
| 268 NOTREACHED(); | |
| 269 return; | |
| 270 } | |
| 271 | |
| 272 StringVar* session_id = StringVar::FromPPVar(web_session_id); | |
| 273 if (!session_id || | |
| 274 session_id->value().length() > media::limits::kMaxWebSessionIdLength) { | |
| 275 NOTREACHED(); | |
| 276 return; | |
| 277 } | |
| 278 | |
| 279 dispatcher->Send(new PpapiMsg_PPPContentDecryptor_GetUsableKeyIds( | |
| 280 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, | |
| 281 instance, | |
| 282 promise_id, | |
| 283 session_id->value())); | |
| 284 } | |
| 285 | |
| 286 void Decrypt(PP_Instance instance, | 260 void Decrypt(PP_Instance instance, |
| 287 PP_Resource encrypted_block, | 261 PP_Resource encrypted_block, |
| 288 const PP_EncryptedBlockInfo* encrypted_block_info) { | 262 const PP_EncryptedBlockInfo* encrypted_block_info) { |
| 289 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); | 263 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); |
| 290 if (!dispatcher) { | 264 if (!dispatcher) { |
| 291 NOTREACHED(); | 265 NOTREACHED(); |
| 292 return; | 266 return; |
| 293 } | 267 } |
| 294 | 268 |
| 295 PPPDecryptor_Buffer buffer; | 269 PPPDecryptor_Buffer buffer; |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, | 440 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, |
| 467 instance, | 441 instance, |
| 468 decoder_type, | 442 decoder_type, |
| 469 buffer, | 443 buffer, |
| 470 serialized_block_info)); | 444 serialized_block_info)); |
| 471 } | 445 } |
| 472 | 446 |
| 473 static const PPP_ContentDecryptor_Private content_decryptor_interface = { | 447 static const PPP_ContentDecryptor_Private content_decryptor_interface = { |
| 474 &Initialize, | 448 &Initialize, |
| 475 &SetServerCertificate, | 449 &SetServerCertificate, |
| 476 &CreateSession, | 450 &CreateSessionAndGenerateRequest, |
| 477 &LoadSession, | 451 &LoadSession, |
| 478 &UpdateSession, | 452 &UpdateSession, |
| 479 &CloseSession, | 453 &CloseSession, |
| 480 &RemoveSession, | 454 &RemoveSession, |
| 481 &GetUsableKeyIds, | |
| 482 &Decrypt, | 455 &Decrypt, |
| 483 &InitializeAudioDecoder, | 456 &InitializeAudioDecoder, |
| 484 &InitializeVideoDecoder, | 457 &InitializeVideoDecoder, |
| 485 &DeinitializeDecoder, | 458 &DeinitializeDecoder, |
| 486 &ResetDecoder, | 459 &ResetDecoder, |
| 487 &DecryptAndDecode}; | 460 &DecryptAndDecode}; |
| 488 | 461 |
| 489 } // namespace | 462 } // namespace |
| 490 | 463 |
| 491 PPP_ContentDecryptor_Private_Proxy::PPP_ContentDecryptor_Private_Proxy( | 464 PPP_ContentDecryptor_Private_Proxy::PPP_ContentDecryptor_Private_Proxy( |
| (...skipping 21 matching lines...) Expand all Loading... |
| 513 if (!dispatcher()->IsPlugin()) | 486 if (!dispatcher()->IsPlugin()) |
| 514 return false; // These are only valid from host->plugin. | 487 return false; // These are only valid from host->plugin. |
| 515 // Don't allow the plugin to send these to the host. | 488 // Don't allow the plugin to send these to the host. |
| 516 | 489 |
| 517 bool handled = true; | 490 bool handled = true; |
| 518 IPC_BEGIN_MESSAGE_MAP(PPP_ContentDecryptor_Private_Proxy, msg) | 491 IPC_BEGIN_MESSAGE_MAP(PPP_ContentDecryptor_Private_Proxy, msg) |
| 519 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Initialize, | 492 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Initialize, |
| 520 OnMsgInitialize) | 493 OnMsgInitialize) |
| 521 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_SetServerCertificate, | 494 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_SetServerCertificate, |
| 522 OnMsgSetServerCertificate) | 495 OnMsgSetServerCertificate) |
| 523 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_CreateSession, | 496 IPC_MESSAGE_HANDLER( |
| 524 OnMsgCreateSession) | 497 PpapiMsg_PPPContentDecryptor_CreateSessionAndGenerateRequest, |
| 498 OnMsgCreateSessionAndGenerateRequest) |
| 525 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_LoadSession, | 499 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_LoadSession, |
| 526 OnMsgLoadSession) | 500 OnMsgLoadSession) |
| 527 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_UpdateSession, | 501 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_UpdateSession, |
| 528 OnMsgUpdateSession) | 502 OnMsgUpdateSession) |
| 529 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_CloseSession, | 503 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_CloseSession, |
| 530 OnMsgCloseSession) | 504 OnMsgCloseSession) |
| 531 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_RemoveSession, | 505 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_RemoveSession, |
| 532 OnMsgRemoveSession) | 506 OnMsgRemoveSession) |
| 533 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_GetUsableKeyIds, | |
| 534 OnMsgGetUsableKeyIds) | |
| 535 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Decrypt, | 507 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Decrypt, |
| 536 OnMsgDecrypt) | 508 OnMsgDecrypt) |
| 537 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_InitializeAudioDecoder, | 509 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_InitializeAudioDecoder, |
| 538 OnMsgInitializeAudioDecoder) | 510 OnMsgInitializeAudioDecoder) |
| 539 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_InitializeVideoDecoder, | 511 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_InitializeVideoDecoder, |
| 540 OnMsgInitializeVideoDecoder) | 512 OnMsgInitializeVideoDecoder) |
| 541 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DeinitializeDecoder, | 513 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DeinitializeDecoder, |
| 542 OnMsgDeinitializeDecoder) | 514 OnMsgDeinitializeDecoder) |
| 543 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_ResetDecoder, | 515 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_ResetDecoder, |
| 544 OnMsgResetDecoder) | 516 OnMsgResetDecoder) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 ->GetVarTracker() | 550 ->GetVarTracker() |
| 579 ->MakeArrayBufferPPVar(server_certificate.size(), | 551 ->MakeArrayBufferPPVar(server_certificate.size(), |
| 580 &server_certificate[0])); | 552 &server_certificate[0])); |
| 581 CallWhileUnlocked(ppp_decryptor_impl_->SetServerCertificate, | 553 CallWhileUnlocked(ppp_decryptor_impl_->SetServerCertificate, |
| 582 instance, | 554 instance, |
| 583 promise_id, | 555 promise_id, |
| 584 server_certificate_var.get()); | 556 server_certificate_var.get()); |
| 585 } | 557 } |
| 586 } | 558 } |
| 587 | 559 |
| 588 void PPP_ContentDecryptor_Private_Proxy::OnMsgCreateSession( | 560 void PPP_ContentDecryptor_Private_Proxy::OnMsgCreateSessionAndGenerateRequest( |
| 589 PP_Instance instance, | 561 PP_Instance instance, |
| 590 uint32_t promise_id, | 562 uint32_t promise_id, |
| 563 PP_SessionType session_type, |
| 591 SerializedVarReceiveInput init_data_type, | 564 SerializedVarReceiveInput init_data_type, |
| 592 SerializedVarReceiveInput init_data, | 565 SerializedVarReceiveInput init_data) { |
| 593 PP_SessionType session_type) { | |
| 594 if (ppp_decryptor_impl_) { | 566 if (ppp_decryptor_impl_) { |
| 595 CallWhileUnlocked( | 567 CallWhileUnlocked( |
| 596 ppp_decryptor_impl_->CreateSession, | 568 ppp_decryptor_impl_->CreateSessionAndGenerateRequest, instance, |
| 597 instance, | 569 promise_id, session_type, |
| 598 promise_id, | |
| 599 ExtractReceivedVarAndAddRef(dispatcher(), &init_data_type), | 570 ExtractReceivedVarAndAddRef(dispatcher(), &init_data_type), |
| 600 ExtractReceivedVarAndAddRef(dispatcher(), &init_data), | 571 ExtractReceivedVarAndAddRef(dispatcher(), &init_data)); |
| 601 session_type); | |
| 602 } | 572 } |
| 603 } | 573 } |
| 604 | 574 |
| 605 void PPP_ContentDecryptor_Private_Proxy::OnMsgLoadSession( | 575 void PPP_ContentDecryptor_Private_Proxy::OnMsgLoadSession( |
| 606 PP_Instance instance, | 576 PP_Instance instance, |
| 607 uint32_t promise_id, | 577 uint32_t promise_id, |
| 578 PP_SessionType session_type, |
| 608 SerializedVarReceiveInput web_session_id) { | 579 SerializedVarReceiveInput web_session_id) { |
| 609 if (ppp_decryptor_impl_) { | 580 if (ppp_decryptor_impl_) { |
| 610 CallWhileUnlocked( | 581 CallWhileUnlocked( |
| 611 ppp_decryptor_impl_->LoadSession, | 582 ppp_decryptor_impl_->LoadSession, instance, promise_id, session_type, |
| 612 instance, | |
| 613 promise_id, | |
| 614 ExtractReceivedVarAndAddRef(dispatcher(), &web_session_id)); | 583 ExtractReceivedVarAndAddRef(dispatcher(), &web_session_id)); |
| 615 } | 584 } |
| 616 } | 585 } |
| 617 | 586 |
| 618 void PPP_ContentDecryptor_Private_Proxy::OnMsgUpdateSession( | 587 void PPP_ContentDecryptor_Private_Proxy::OnMsgUpdateSession( |
| 619 PP_Instance instance, | 588 PP_Instance instance, |
| 620 uint32_t promise_id, | 589 uint32_t promise_id, |
| 621 SerializedVarReceiveInput web_session_id, | 590 SerializedVarReceiveInput web_session_id, |
| 622 SerializedVarReceiveInput response) { | 591 SerializedVarReceiveInput response) { |
| 623 if (ppp_decryptor_impl_) { | 592 if (ppp_decryptor_impl_) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 651 if (ppp_decryptor_impl_) { | 620 if (ppp_decryptor_impl_) { |
| 652 ScopedPPVar web_session_id_var(ScopedPPVar::PassRef(), | 621 ScopedPPVar web_session_id_var(ScopedPPVar::PassRef(), |
| 653 StringVar::StringToPPVar(web_session_id)); | 622 StringVar::StringToPPVar(web_session_id)); |
| 654 CallWhileUnlocked(ppp_decryptor_impl_->RemoveSession, | 623 CallWhileUnlocked(ppp_decryptor_impl_->RemoveSession, |
| 655 instance, | 624 instance, |
| 656 promise_id, | 625 promise_id, |
| 657 web_session_id_var.get()); | 626 web_session_id_var.get()); |
| 658 } | 627 } |
| 659 } | 628 } |
| 660 | 629 |
| 661 void PPP_ContentDecryptor_Private_Proxy::OnMsgGetUsableKeyIds( | |
| 662 PP_Instance instance, | |
| 663 uint32_t promise_id, | |
| 664 const std::string& web_session_id) { | |
| 665 if (ppp_decryptor_impl_) { | |
| 666 ScopedPPVar web_session_id_var(ScopedPPVar::PassRef(), | |
| 667 StringVar::StringToPPVar(web_session_id)); | |
| 668 CallWhileUnlocked(ppp_decryptor_impl_->GetUsableKeyIds, | |
| 669 instance, | |
| 670 promise_id, | |
| 671 web_session_id_var.get()); | |
| 672 } | |
| 673 } | |
| 674 | |
| 675 void PPP_ContentDecryptor_Private_Proxy::OnMsgDecrypt( | 630 void PPP_ContentDecryptor_Private_Proxy::OnMsgDecrypt( |
| 676 PP_Instance instance, | 631 PP_Instance instance, |
| 677 const PPPDecryptor_Buffer& encrypted_buffer, | 632 const PPPDecryptor_Buffer& encrypted_buffer, |
| 678 const std::string& serialized_block_info) { | 633 const std::string& serialized_block_info) { |
| 679 ScopedPPResource plugin_resource( | 634 ScopedPPResource plugin_resource( |
| 680 ScopedPPResource::PassRef(), | 635 ScopedPPResource::PassRef(), |
| 681 PPB_Buffer_Proxy::AddProxyResource(encrypted_buffer.resource, | 636 PPB_Buffer_Proxy::AddProxyResource(encrypted_buffer.resource, |
| 682 encrypted_buffer.handle, | 637 encrypted_buffer.handle, |
| 683 encrypted_buffer.size)); | 638 encrypted_buffer.size)); |
| 684 if (ppp_decryptor_impl_) { | 639 if (ppp_decryptor_impl_) { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 792 ppp_decryptor_impl_->DecryptAndDecode, | 747 ppp_decryptor_impl_->DecryptAndDecode, |
| 793 instance, | 748 instance, |
| 794 decoder_type, | 749 decoder_type, |
| 795 plugin_resource.get(), | 750 plugin_resource.get(), |
| 796 &block_info); | 751 &block_info); |
| 797 } | 752 } |
| 798 } | 753 } |
| 799 | 754 |
| 800 } // namespace proxy | 755 } // namespace proxy |
| 801 } // namespace ppapi | 756 } // namespace ppapi |
| OLD | NEW |