| 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/platform_file.h" | 7 #include "base/platform_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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 resource, | 102 resource, |
| 103 &handle) == PP_FALSE) | 103 &handle) == PP_FALSE) |
| 104 return false; | 104 return false; |
| 105 | 105 |
| 106 buffer->resource = host_resource; | 106 buffer->resource = host_resource; |
| 107 buffer->handle = handle; | 107 buffer->handle = handle; |
| 108 buffer->size = size; | 108 buffer->size = size; |
| 109 return true; | 109 return true; |
| 110 } | 110 } |
| 111 | 111 |
| 112 void Initialize(PP_Instance instance, PP_Var key_system) { |
| 113 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); |
| 114 if (!dispatcher) { |
| 115 NOTREACHED(); |
| 116 return; |
| 117 } |
| 118 |
| 119 dispatcher->Send( |
| 120 new PpapiMsg_PPPContentDecryptor_Initialize( |
| 121 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, |
| 122 instance, |
| 123 SerializedVarSendInput(dispatcher, key_system))); |
| 124 } |
| 125 |
| 112 void GenerateKeyRequest(PP_Instance instance, | 126 void GenerateKeyRequest(PP_Instance instance, |
| 113 PP_Var key_system, | |
| 114 PP_Var type, | 127 PP_Var type, |
| 115 PP_Var init_data) { | 128 PP_Var init_data) { |
| 116 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); | 129 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); |
| 117 if (!dispatcher) { | 130 if (!dispatcher) { |
| 118 NOTREACHED(); | 131 NOTREACHED(); |
| 119 return; | 132 return; |
| 120 } | 133 } |
| 121 | 134 |
| 122 dispatcher->Send( | 135 dispatcher->Send( |
| 123 new PpapiMsg_PPPContentDecryptor_GenerateKeyRequest( | 136 new PpapiMsg_PPPContentDecryptor_GenerateKeyRequest( |
| 124 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, | 137 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, |
| 125 instance, | 138 instance, |
| 126 SerializedVarSendInput(dispatcher, key_system), | |
| 127 SerializedVarSendInput(dispatcher, type), | 139 SerializedVarSendInput(dispatcher, type), |
| 128 SerializedVarSendInput(dispatcher, init_data))); | 140 SerializedVarSendInput(dispatcher, init_data))); |
| 129 } | 141 } |
| 130 | 142 |
| 131 void AddKey(PP_Instance instance, | 143 void AddKey(PP_Instance instance, |
| 132 PP_Var session_id, | 144 PP_Var session_id, |
| 133 PP_Var key, | 145 PP_Var key, |
| 134 PP_Var init_data) { | 146 PP_Var init_data) { |
| 135 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); | 147 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); |
| 136 if (!dispatcher) { | 148 if (!dispatcher) { |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 dispatcher->Send( | 354 dispatcher->Send( |
| 343 new PpapiMsg_PPPContentDecryptor_DecryptAndDecode( | 355 new PpapiMsg_PPPContentDecryptor_DecryptAndDecode( |
| 344 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, | 356 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, |
| 345 instance, | 357 instance, |
| 346 decoder_type, | 358 decoder_type, |
| 347 buffer, | 359 buffer, |
| 348 serialized_block_info)); | 360 serialized_block_info)); |
| 349 } | 361 } |
| 350 | 362 |
| 351 static const PPP_ContentDecryptor_Private content_decryptor_interface = { | 363 static const PPP_ContentDecryptor_Private content_decryptor_interface = { |
| 364 &Initialize, |
| 352 &GenerateKeyRequest, | 365 &GenerateKeyRequest, |
| 353 &AddKey, | 366 &AddKey, |
| 354 &CancelKeyRequest, | 367 &CancelKeyRequest, |
| 355 &Decrypt, | 368 &Decrypt, |
| 356 &InitializeAudioDecoder, | 369 &InitializeAudioDecoder, |
| 357 &InitializeVideoDecoder, | 370 &InitializeVideoDecoder, |
| 358 &DeinitializeDecoder, | 371 &DeinitializeDecoder, |
| 359 &ResetDecoder, | 372 &ResetDecoder, |
| 360 &DecryptAndDecode | 373 &DecryptAndDecode |
| 361 }; | 374 }; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 383 } | 396 } |
| 384 | 397 |
| 385 bool PPP_ContentDecryptor_Private_Proxy::OnMessageReceived( | 398 bool PPP_ContentDecryptor_Private_Proxy::OnMessageReceived( |
| 386 const IPC::Message& msg) { | 399 const IPC::Message& msg) { |
| 387 if (!dispatcher()->IsPlugin()) | 400 if (!dispatcher()->IsPlugin()) |
| 388 return false; // These are only valid from host->plugin. | 401 return false; // These are only valid from host->plugin. |
| 389 // Don't allow the plugin to send these to the host. | 402 // Don't allow the plugin to send these to the host. |
| 390 | 403 |
| 391 bool handled = true; | 404 bool handled = true; |
| 392 IPC_BEGIN_MESSAGE_MAP(PPP_ContentDecryptor_Private_Proxy, msg) | 405 IPC_BEGIN_MESSAGE_MAP(PPP_ContentDecryptor_Private_Proxy, msg) |
| 406 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Initialize, |
| 407 OnMsgInitialize) |
| 393 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_GenerateKeyRequest, | 408 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_GenerateKeyRequest, |
| 394 OnMsgGenerateKeyRequest) | 409 OnMsgGenerateKeyRequest) |
| 395 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_AddKey, | 410 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_AddKey, |
| 396 OnMsgAddKey) | 411 OnMsgAddKey) |
| 397 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_CancelKeyRequest, | 412 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_CancelKeyRequest, |
| 398 OnMsgCancelKeyRequest) | 413 OnMsgCancelKeyRequest) |
| 399 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Decrypt, | 414 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Decrypt, |
| 400 OnMsgDecrypt) | 415 OnMsgDecrypt) |
| 401 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_InitializeAudioDecoder, | 416 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_InitializeAudioDecoder, |
| 402 OnMsgInitializeAudioDecoder) | 417 OnMsgInitializeAudioDecoder) |
| 403 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_InitializeVideoDecoder, | 418 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_InitializeVideoDecoder, |
| 404 OnMsgInitializeVideoDecoder) | 419 OnMsgInitializeVideoDecoder) |
| 405 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DeinitializeDecoder, | 420 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DeinitializeDecoder, |
| 406 OnMsgDeinitializeDecoder) | 421 OnMsgDeinitializeDecoder) |
| 407 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_ResetDecoder, | 422 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_ResetDecoder, |
| 408 OnMsgResetDecoder) | 423 OnMsgResetDecoder) |
| 409 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DecryptAndDecode, | 424 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DecryptAndDecode, |
| 410 OnMsgDecryptAndDecode) | 425 OnMsgDecryptAndDecode) |
| 411 IPC_MESSAGE_UNHANDLED(handled = false) | 426 IPC_MESSAGE_UNHANDLED(handled = false) |
| 412 IPC_END_MESSAGE_MAP() | 427 IPC_END_MESSAGE_MAP() |
| 413 DCHECK(handled); | 428 DCHECK(handled); |
| 414 return handled; | 429 return handled; |
| 415 } | 430 } |
| 416 | 431 |
| 432 void PPP_ContentDecryptor_Private_Proxy::OnMsgInitialize( |
| 433 PP_Instance instance, |
| 434 SerializedVarReceiveInput key_system) { |
| 435 if (ppp_decryptor_impl_) { |
| 436 CallWhileUnlocked(ppp_decryptor_impl_->Initialize, |
| 437 instance, |
| 438 ExtractReceivedVarAndAddRef(dispatcher(), &key_system)); |
| 439 } |
| 440 } |
| 441 |
| 417 void PPP_ContentDecryptor_Private_Proxy::OnMsgGenerateKeyRequest( | 442 void PPP_ContentDecryptor_Private_Proxy::OnMsgGenerateKeyRequest( |
| 418 PP_Instance instance, | 443 PP_Instance instance, |
| 419 SerializedVarReceiveInput key_system, | |
| 420 SerializedVarReceiveInput type, | 444 SerializedVarReceiveInput type, |
| 421 SerializedVarReceiveInput init_data) { | 445 SerializedVarReceiveInput init_data) { |
| 422 if (ppp_decryptor_impl_) { | 446 if (ppp_decryptor_impl_) { |
| 423 CallWhileUnlocked(ppp_decryptor_impl_->GenerateKeyRequest, | 447 CallWhileUnlocked(ppp_decryptor_impl_->GenerateKeyRequest, |
| 424 instance, | 448 instance, |
| 425 ExtractReceivedVarAndAddRef(dispatcher(), &key_system), | |
| 426 ExtractReceivedVarAndAddRef(dispatcher(), &type), | 449 ExtractReceivedVarAndAddRef(dispatcher(), &type), |
| 427 ExtractReceivedVarAndAddRef(dispatcher(), &init_data)); | 450 ExtractReceivedVarAndAddRef(dispatcher(), &init_data)); |
| 428 } | 451 } |
| 429 } | 452 } |
| 430 | 453 |
| 431 void PPP_ContentDecryptor_Private_Proxy::OnMsgAddKey( | 454 void PPP_ContentDecryptor_Private_Proxy::OnMsgAddKey( |
| 432 PP_Instance instance, | 455 PP_Instance instance, |
| 433 SerializedVarReceiveInput session_id, | 456 SerializedVarReceiveInput session_id, |
| 434 SerializedVarReceiveInput key, | 457 SerializedVarReceiveInput key, |
| 435 SerializedVarReceiveInput init_data) { | 458 SerializedVarReceiveInput init_data) { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 ppp_decryptor_impl_->DecryptAndDecode, | 595 ppp_decryptor_impl_->DecryptAndDecode, |
| 573 instance, | 596 instance, |
| 574 decoder_type, | 597 decoder_type, |
| 575 plugin_resource.get(), | 598 plugin_resource.get(), |
| 576 const_cast<const PP_EncryptedBlockInfo*>(&block_info)); | 599 const_cast<const PP_EncryptedBlockInfo*>(&block_info)); |
| 577 } | 600 } |
| 578 } | 601 } |
| 579 | 602 |
| 580 } // namespace proxy | 603 } // namespace proxy |
| 581 } // namespace ppapi | 604 } // namespace ppapi |
| OLD | NEW |