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 "ppapi/c/pp_bool.h" | 8 #include "ppapi/c/pp_bool.h" |
9 #include "ppapi/c/ppb_core.h" | 9 #include "ppapi/c/ppb_core.h" |
10 #include "ppapi/proxy/content_decryptor_private_serializer.h" | 10 #include "ppapi/proxy/content_decryptor_private_serializer.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 return; | 117 return; |
118 } | 118 } |
119 | 119 |
120 dispatcher->Send( | 120 dispatcher->Send( |
121 new PpapiMsg_PPPContentDecryptor_Initialize( | 121 new PpapiMsg_PPPContentDecryptor_Initialize( |
122 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, | 122 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, |
123 instance, | 123 instance, |
124 SerializedVarSendInput(dispatcher, key_system))); | 124 SerializedVarSendInput(dispatcher, key_system))); |
125 } | 125 } |
126 | 126 |
127 void SetServerCertificate(PP_Instance instance, | |
128 uint32_t promise_id, | |
129 PP_Var server_certificate) { | |
130 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); | |
131 if (!dispatcher) { | |
132 NOTREACHED(); | |
133 return; | |
134 } | |
135 | |
136 dispatcher->Send(new PpapiMsg_PPPContentDecryptor_SetServerCertificate( | |
137 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, | |
138 instance, | |
139 promise_id, | |
140 SerializedVarSendInput(dispatcher, server_certificate))); | |
141 } | |
142 | |
127 void CreateSession(PP_Instance instance, | 143 void CreateSession(PP_Instance instance, |
128 uint32_t promise_id, | 144 uint32_t promise_id, |
129 PP_Var init_data_type, | 145 PP_Var init_data_type, |
130 PP_Var init_data, | 146 PP_Var init_data, |
131 PP_SessionType session_type) { | 147 PP_SessionType session_type) { |
132 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); | 148 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); |
133 if (!dispatcher) { | 149 if (!dispatcher) { |
134 NOTREACHED(); | 150 NOTREACHED(); |
135 return; | 151 return; |
136 } | 152 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 } | 187 } |
172 | 188 |
173 dispatcher->Send(new PpapiMsg_PPPContentDecryptor_UpdateSession( | 189 dispatcher->Send(new PpapiMsg_PPPContentDecryptor_UpdateSession( |
174 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, | 190 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, |
175 instance, | 191 instance, |
176 promise_id, | 192 promise_id, |
177 SerializedVarSendInput(dispatcher, web_session_id), | 193 SerializedVarSendInput(dispatcher, web_session_id), |
178 SerializedVarSendInput(dispatcher, response))); | 194 SerializedVarSendInput(dispatcher, response))); |
179 } | 195 } |
180 | 196 |
181 void ReleaseSession(PP_Instance instance, | 197 void GetUsableKeyIds(PP_Instance instance, |
182 uint32_t promise_id, | 198 uint32_t promise_id, |
183 PP_Var web_session_id) { | 199 PP_Var web_session_id) { |
184 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); | 200 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); |
185 if (!dispatcher) { | 201 if (!dispatcher) { |
186 NOTREACHED(); | 202 NOTREACHED(); |
187 return; | 203 return; |
188 } | 204 } |
189 | 205 |
190 dispatcher->Send(new PpapiMsg_PPPContentDecryptor_ReleaseSession( | 206 dispatcher->Send(new PpapiMsg_PPPContentDecryptor_GetUsableKeyIds( |
191 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, | 207 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, |
192 instance, | 208 instance, |
193 promise_id, | 209 promise_id, |
210 SerializedVarSendInput(dispatcher, web_session_id))); | |
211 } | |
212 | |
213 void CloseSession(PP_Instance instance, | |
214 uint32_t promise_id, | |
215 PP_Var web_session_id) { | |
216 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); | |
217 if (!dispatcher) { | |
218 NOTREACHED(); | |
219 return; | |
220 } | |
221 | |
222 dispatcher->Send(new PpapiMsg_PPPContentDecryptor_CloseSession( | |
223 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, | |
224 instance, | |
225 promise_id, | |
226 SerializedVarSendInput(dispatcher, web_session_id))); | |
227 } | |
228 | |
229 void RemoveSession(PP_Instance instance, | |
230 uint32_t promise_id, | |
231 PP_Var web_session_id) { | |
232 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); | |
233 if (!dispatcher) { | |
234 NOTREACHED(); | |
235 return; | |
236 } | |
237 | |
238 dispatcher->Send(new PpapiMsg_PPPContentDecryptor_RemoveSession( | |
239 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, | |
240 instance, | |
241 promise_id, | |
194 SerializedVarSendInput(dispatcher, web_session_id))); | 242 SerializedVarSendInput(dispatcher, web_session_id))); |
195 } | 243 } |
196 | 244 |
197 void Decrypt(PP_Instance instance, | 245 void Decrypt(PP_Instance instance, |
198 PP_Resource encrypted_block, | 246 PP_Resource encrypted_block, |
199 const PP_EncryptedBlockInfo* encrypted_block_info) { | 247 const PP_EncryptedBlockInfo* encrypted_block_info) { |
200 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); | 248 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); |
201 if (!dispatcher) { | 249 if (!dispatcher) { |
202 NOTREACHED(); | 250 NOTREACHED(); |
203 return; | 251 return; |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
375 dispatcher->Send( | 423 dispatcher->Send( |
376 new PpapiMsg_PPPContentDecryptor_DecryptAndDecode( | 424 new PpapiMsg_PPPContentDecryptor_DecryptAndDecode( |
377 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, | 425 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, |
378 instance, | 426 instance, |
379 decoder_type, | 427 decoder_type, |
380 buffer, | 428 buffer, |
381 serialized_block_info)); | 429 serialized_block_info)); |
382 } | 430 } |
383 | 431 |
384 static const PPP_ContentDecryptor_Private content_decryptor_interface = { | 432 static const PPP_ContentDecryptor_Private content_decryptor_interface = { |
385 &Initialize, | 433 &Initialize, |
386 &CreateSession, | 434 &SetServerCertificate, |
387 &LoadSession, | 435 &CreateSession, |
388 &UpdateSession, | 436 &LoadSession, |
389 &ReleaseSession, | 437 &UpdateSession, |
390 &Decrypt, | 438 &GetUsableKeyIds, |
ddorwin
2014/08/22 20:49:21
ditto
jrummell
2014/08/25 21:54:37
Done.
| |
391 &InitializeAudioDecoder, | 439 &CloseSession, |
392 &InitializeVideoDecoder, | 440 &RemoveSession, |
393 &DeinitializeDecoder, | 441 &Decrypt, |
394 &ResetDecoder, | 442 &InitializeAudioDecoder, |
395 &DecryptAndDecode | 443 &InitializeVideoDecoder, |
396 }; | 444 &DeinitializeDecoder, |
445 &ResetDecoder, | |
446 &DecryptAndDecode}; | |
397 | 447 |
398 } // namespace | 448 } // namespace |
399 | 449 |
400 PPP_ContentDecryptor_Private_Proxy::PPP_ContentDecryptor_Private_Proxy( | 450 PPP_ContentDecryptor_Private_Proxy::PPP_ContentDecryptor_Private_Proxy( |
401 Dispatcher* dispatcher) | 451 Dispatcher* dispatcher) |
402 : InterfaceProxy(dispatcher), | 452 : InterfaceProxy(dispatcher), |
403 ppp_decryptor_impl_(NULL) { | 453 ppp_decryptor_impl_(NULL) { |
404 if (dispatcher->IsPlugin()) { | 454 if (dispatcher->IsPlugin()) { |
405 ppp_decryptor_impl_ = static_cast<const PPP_ContentDecryptor_Private*>( | 455 ppp_decryptor_impl_ = static_cast<const PPP_ContentDecryptor_Private*>( |
406 dispatcher->local_get_interface()( | 456 dispatcher->local_get_interface()( |
(...skipping 13 matching lines...) Expand all Loading... | |
420 bool PPP_ContentDecryptor_Private_Proxy::OnMessageReceived( | 470 bool PPP_ContentDecryptor_Private_Proxy::OnMessageReceived( |
421 const IPC::Message& msg) { | 471 const IPC::Message& msg) { |
422 if (!dispatcher()->IsPlugin()) | 472 if (!dispatcher()->IsPlugin()) |
423 return false; // These are only valid from host->plugin. | 473 return false; // These are only valid from host->plugin. |
424 // Don't allow the plugin to send these to the host. | 474 // Don't allow the plugin to send these to the host. |
425 | 475 |
426 bool handled = true; | 476 bool handled = true; |
427 IPC_BEGIN_MESSAGE_MAP(PPP_ContentDecryptor_Private_Proxy, msg) | 477 IPC_BEGIN_MESSAGE_MAP(PPP_ContentDecryptor_Private_Proxy, msg) |
428 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Initialize, | 478 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Initialize, |
429 OnMsgInitialize) | 479 OnMsgInitialize) |
480 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_SetServerCertificate, | |
481 OnMsgSetServerCertificate) | |
430 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_CreateSession, | 482 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_CreateSession, |
431 OnMsgCreateSession) | 483 OnMsgCreateSession) |
432 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_LoadSession, | 484 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_LoadSession, |
433 OnMsgLoadSession) | 485 OnMsgLoadSession) |
434 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_UpdateSession, | 486 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_UpdateSession, |
435 OnMsgUpdateSession) | 487 OnMsgUpdateSession) |
436 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_ReleaseSession, | 488 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_GetUsableKeyIds, |
437 OnMsgReleaseSession) | 489 OnMsgGetUsableKeyIds) |
490 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_CloseSession, | |
491 OnMsgCloseSession) | |
492 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_RemoveSession, | |
493 OnMsgRemoveSession) | |
438 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Decrypt, | 494 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Decrypt, |
439 OnMsgDecrypt) | 495 OnMsgDecrypt) |
440 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_InitializeAudioDecoder, | 496 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_InitializeAudioDecoder, |
441 OnMsgInitializeAudioDecoder) | 497 OnMsgInitializeAudioDecoder) |
442 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_InitializeVideoDecoder, | 498 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_InitializeVideoDecoder, |
443 OnMsgInitializeVideoDecoder) | 499 OnMsgInitializeVideoDecoder) |
444 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DeinitializeDecoder, | 500 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DeinitializeDecoder, |
445 OnMsgDeinitializeDecoder) | 501 OnMsgDeinitializeDecoder) |
446 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_ResetDecoder, | 502 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_ResetDecoder, |
447 OnMsgResetDecoder) | 503 OnMsgResetDecoder) |
448 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DecryptAndDecode, | 504 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DecryptAndDecode, |
449 OnMsgDecryptAndDecode) | 505 OnMsgDecryptAndDecode) |
450 IPC_MESSAGE_UNHANDLED(handled = false) | 506 IPC_MESSAGE_UNHANDLED(handled = false) |
451 IPC_END_MESSAGE_MAP() | 507 IPC_END_MESSAGE_MAP() |
452 DCHECK(handled); | 508 DCHECK(handled); |
453 return handled; | 509 return handled; |
454 } | 510 } |
455 | 511 |
456 void PPP_ContentDecryptor_Private_Proxy::OnMsgInitialize( | 512 void PPP_ContentDecryptor_Private_Proxy::OnMsgInitialize( |
457 PP_Instance instance, | 513 PP_Instance instance, |
458 SerializedVarReceiveInput key_system) { | 514 SerializedVarReceiveInput key_system) { |
459 if (ppp_decryptor_impl_) { | 515 if (ppp_decryptor_impl_) { |
460 CallWhileUnlocked( | 516 CallWhileUnlocked( |
461 ppp_decryptor_impl_->Initialize, | 517 ppp_decryptor_impl_->Initialize, |
462 instance, | 518 instance, |
463 ExtractReceivedVarAndAddRef(dispatcher(), &key_system)); | 519 ExtractReceivedVarAndAddRef(dispatcher(), &key_system)); |
464 } | 520 } |
465 } | 521 } |
466 | 522 |
523 void PPP_ContentDecryptor_Private_Proxy::OnMsgSetServerCertificate( | |
524 PP_Instance instance, | |
525 uint32_t promise_id, | |
526 SerializedVarReceiveInput server_certificate) { | |
527 if (ppp_decryptor_impl_) { | |
528 CallWhileUnlocked( | |
529 ppp_decryptor_impl_->SetServerCertificate, | |
530 instance, | |
531 promise_id, | |
532 ExtractReceivedVarAndAddRef(dispatcher(), &server_certificate)); | |
533 } | |
534 } | |
535 | |
467 void PPP_ContentDecryptor_Private_Proxy::OnMsgCreateSession( | 536 void PPP_ContentDecryptor_Private_Proxy::OnMsgCreateSession( |
468 PP_Instance instance, | 537 PP_Instance instance, |
469 uint32_t promise_id, | 538 uint32_t promise_id, |
470 SerializedVarReceiveInput init_data_type, | 539 SerializedVarReceiveInput init_data_type, |
471 SerializedVarReceiveInput init_data, | 540 SerializedVarReceiveInput init_data, |
472 PP_SessionType session_type) { | 541 PP_SessionType session_type) { |
473 if (ppp_decryptor_impl_) { | 542 if (ppp_decryptor_impl_) { |
474 CallWhileUnlocked( | 543 CallWhileUnlocked( |
475 ppp_decryptor_impl_->CreateSession, | 544 ppp_decryptor_impl_->CreateSession, |
476 instance, | 545 instance, |
(...skipping 25 matching lines...) Expand all Loading... | |
502 if (ppp_decryptor_impl_) { | 571 if (ppp_decryptor_impl_) { |
503 CallWhileUnlocked( | 572 CallWhileUnlocked( |
504 ppp_decryptor_impl_->UpdateSession, | 573 ppp_decryptor_impl_->UpdateSession, |
505 instance, | 574 instance, |
506 promise_id, | 575 promise_id, |
507 ExtractReceivedVarAndAddRef(dispatcher(), &web_session_id), | 576 ExtractReceivedVarAndAddRef(dispatcher(), &web_session_id), |
508 ExtractReceivedVarAndAddRef(dispatcher(), &response)); | 577 ExtractReceivedVarAndAddRef(dispatcher(), &response)); |
509 } | 578 } |
510 } | 579 } |
511 | 580 |
512 void PPP_ContentDecryptor_Private_Proxy::OnMsgReleaseSession( | 581 void PPP_ContentDecryptor_Private_Proxy::OnMsgGetUsableKeyIds( |
513 PP_Instance instance, | 582 PP_Instance instance, |
514 uint32_t promise_id, | 583 uint32_t promise_id, |
515 SerializedVarReceiveInput web_session_id) { | 584 SerializedVarReceiveInput web_session_id) { |
516 if (ppp_decryptor_impl_) { | 585 if (ppp_decryptor_impl_) { |
517 CallWhileUnlocked( | 586 CallWhileUnlocked( |
518 ppp_decryptor_impl_->ReleaseSession, | 587 ppp_decryptor_impl_->GetUsableKeyIds, |
519 instance, | 588 instance, |
520 promise_id, | 589 promise_id, |
521 ExtractReceivedVarAndAddRef(dispatcher(), &web_session_id)); | 590 ExtractReceivedVarAndAddRef(dispatcher(), &web_session_id)); |
591 } | |
592 } | |
593 | |
594 void PPP_ContentDecryptor_Private_Proxy::OnMsgCloseSession( | |
595 PP_Instance instance, | |
596 uint32_t promise_id, | |
597 SerializedVarReceiveInput web_session_id) { | |
598 if (ppp_decryptor_impl_) { | |
599 CallWhileUnlocked( | |
600 ppp_decryptor_impl_->CloseSession, | |
601 instance, | |
602 promise_id, | |
603 ExtractReceivedVarAndAddRef(dispatcher(), &web_session_id)); | |
604 } | |
605 } | |
606 | |
607 void PPP_ContentDecryptor_Private_Proxy::OnMsgRemoveSession( | |
608 PP_Instance instance, | |
609 uint32_t promise_id, | |
610 SerializedVarReceiveInput web_session_id) { | |
611 if (ppp_decryptor_impl_) { | |
612 CallWhileUnlocked( | |
613 ppp_decryptor_impl_->RemoveSession, | |
614 instance, | |
615 promise_id, | |
616 ExtractReceivedVarAndAddRef(dispatcher(), &web_session_id)); | |
522 } | 617 } |
523 } | 618 } |
524 | 619 |
525 void PPP_ContentDecryptor_Private_Proxy::OnMsgDecrypt( | 620 void PPP_ContentDecryptor_Private_Proxy::OnMsgDecrypt( |
526 PP_Instance instance, | 621 PP_Instance instance, |
527 const PPPDecryptor_Buffer& encrypted_buffer, | 622 const PPPDecryptor_Buffer& encrypted_buffer, |
528 const std::string& serialized_block_info) { | 623 const std::string& serialized_block_info) { |
529 ScopedPPResource plugin_resource( | 624 ScopedPPResource plugin_resource( |
530 ScopedPPResource::PassRef(), | 625 ScopedPPResource::PassRef(), |
531 PPB_Buffer_Proxy::AddProxyResource(encrypted_buffer.resource, | 626 PPB_Buffer_Proxy::AddProxyResource(encrypted_buffer.resource, |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
642 ppp_decryptor_impl_->DecryptAndDecode, | 737 ppp_decryptor_impl_->DecryptAndDecode, |
643 instance, | 738 instance, |
644 decoder_type, | 739 decoder_type, |
645 plugin_resource.get(), | 740 plugin_resource.get(), |
646 const_cast<const PP_EncryptedBlockInfo*>(&block_info)); | 741 const_cast<const PP_EncryptedBlockInfo*>(&block_info)); |
647 } | 742 } |
648 } | 743 } |
649 | 744 |
650 } // namespace proxy | 745 } // namespace proxy |
651 } // namespace ppapi | 746 } // namespace ppapi |
OLD | NEW |