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