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/ppb_instance_proxy.h" | 5 #include "ppapi/proxy/ppb_instance_proxy.h" |
6 | 6 |
7 #include "ppapi/c/pp_errors.h" | 7 #include "ppapi/c/pp_errors.h" |
8 #include "ppapi/c/pp_time.h" | 8 #include "ppapi/c/pp_time.h" |
9 #include "ppapi/c/pp_var.h" | 9 #include "ppapi/c/pp_var.h" |
10 #include "ppapi/c/ppb_audio_config.h" | 10 #include "ppapi/c/ppb_audio_config.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetCursor, | 129 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetCursor, |
130 OnHostMsgSetCursor) | 130 OnHostMsgSetCursor) |
131 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetTextInputType, | 131 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetTextInputType, |
132 OnHostMsgSetTextInputType) | 132 OnHostMsgSetTextInputType) |
133 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UpdateCaretPosition, | 133 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UpdateCaretPosition, |
134 OnHostMsgUpdateCaretPosition) | 134 OnHostMsgUpdateCaretPosition) |
135 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_CancelCompositionText, | 135 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_CancelCompositionText, |
136 OnHostMsgCancelCompositionText) | 136 OnHostMsgCancelCompositionText) |
137 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UpdateSurroundingText, | 137 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UpdateSurroundingText, |
138 OnHostMsgUpdateSurroundingText) | 138 OnHostMsgUpdateSurroundingText) |
| 139 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_NeedKey, |
| 140 OnHostMsgNeedKey) |
| 141 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_KeyAdded, |
| 142 OnHostMsgKeyAdded) |
| 143 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_KeyMessage, |
| 144 OnHostMsgKeyMessage) |
| 145 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_KeyError, |
| 146 OnHostMsgKeyError) |
| 147 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DeliverBlock, |
| 148 OnHostMsgDeliverBlock) |
| 149 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DeliverFrame, |
| 150 OnHostMsgDeliverFrame) |
| 151 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DeliverSamples, |
| 152 OnHostMsgDeliverSamples) |
| 153 |
139 #if !defined(OS_NACL) | 154 #if !defined(OS_NACL) |
140 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ResolveRelativeToDocument, | 155 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ResolveRelativeToDocument, |
141 OnHostMsgResolveRelativeToDocument) | 156 OnHostMsgResolveRelativeToDocument) |
142 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DocumentCanRequest, | 157 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DocumentCanRequest, |
143 OnHostMsgDocumentCanRequest) | 158 OnHostMsgDocumentCanRequest) |
144 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DocumentCanAccessDocument, | 159 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DocumentCanAccessDocument, |
145 OnHostMsgDocumentCanAccessDocument) | 160 OnHostMsgDocumentCanAccessDocument) |
146 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetDocumentURL, | 161 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetDocumentURL, |
147 OnHostMsgGetDocumentURL) | 162 OnHostMsgGetDocumentURL) |
148 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetPluginInstanceURL, | 163 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetPluginInstanceURL, |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 void PPB_Instance_Proxy::OnHostMsgGetOwnerElementObject( | 538 void PPB_Instance_Proxy::OnHostMsgGetOwnerElementObject( |
524 PP_Instance instance, | 539 PP_Instance instance, |
525 SerializedVarReturnValue result) { | 540 SerializedVarReturnValue result) { |
526 EnterInstanceNoLock enter(instance); | 541 EnterInstanceNoLock enter(instance); |
527 if (enter.succeeded()) { | 542 if (enter.succeeded()) { |
528 result.Return(dispatcher(), | 543 result.Return(dispatcher(), |
529 enter.functions()->GetOwnerElementObject(instance)); | 544 enter.functions()->GetOwnerElementObject(instance)); |
530 } | 545 } |
531 } | 546 } |
532 | 547 |
| 548 void PPB_Instance_Proxy::NeedKey(PP_Instance instance, |
| 549 PP_Var key_system, |
| 550 PP_Var session_id, |
| 551 PP_Var init_data) { |
| 552 dispatcher()->Send( |
| 553 new PpapiHostMsg_PPBInstance_NeedKey( |
| 554 API_ID_PPB_INSTANCE, |
| 555 instance, |
| 556 SerializedVarSendInput(dispatcher(), key_system), |
| 557 SerializedVarSendInput(dispatcher(), session_id), |
| 558 SerializedVarSendInput(dispatcher(), init_data))); |
| 559 } |
| 560 |
| 561 void PPB_Instance_Proxy::KeyAdded(PP_Instance instance, |
| 562 PP_Var key_system, |
| 563 PP_Var session_id) { |
| 564 dispatcher()->Send( |
| 565 new PpapiHostMsg_PPBInstance_KeyAdded( |
| 566 API_ID_PPB_INSTANCE, |
| 567 instance, |
| 568 SerializedVarSendInput(dispatcher(), key_system), |
| 569 SerializedVarSendInput(dispatcher(), session_id))); |
| 570 } |
| 571 |
| 572 void PPB_Instance_Proxy::KeyMessage(PP_Instance instance, |
| 573 PP_Var key_system, |
| 574 PP_Var session_id, |
| 575 PP_Resource message, |
| 576 PP_Var default_url) { |
| 577 Resource* object = |
| 578 PpapiGlobals::Get()->GetResourceTracker()->GetResource(message); |
| 579 if (!object || object->pp_instance() != instance) |
| 580 return; |
| 581 dispatcher()->Send( |
| 582 new PpapiHostMsg_PPBInstance_KeyMessage( |
| 583 API_ID_PPB_INSTANCE, |
| 584 instance, |
| 585 SerializedVarSendInput(dispatcher(), key_system), |
| 586 SerializedVarSendInput(dispatcher(), session_id), |
| 587 object->host_resource().host_resource(), |
| 588 SerializedVarSendInput(dispatcher(), default_url))); |
| 589 } |
| 590 |
| 591 void PPB_Instance_Proxy::KeyError(PP_Instance instance, |
| 592 PP_Var key_system, |
| 593 PP_Var session_id, |
| 594 int32_t media_error, |
| 595 int32_t system_code) { |
| 596 dispatcher()->Send( |
| 597 new PpapiHostMsg_PPBInstance_KeyError( |
| 598 API_ID_PPB_INSTANCE, |
| 599 instance, |
| 600 SerializedVarSendInput(dispatcher(), key_system), |
| 601 SerializedVarSendInput(dispatcher(), session_id), |
| 602 media_error, |
| 603 system_code)); |
| 604 } |
| 605 |
| 606 void PPB_Instance_Proxy::DeliverBlock(PP_Instance instance, |
| 607 PP_Resource decrypted_block, |
| 608 int32_t request_id) { |
| 609 Resource* object = |
| 610 PpapiGlobals::Get()->GetResourceTracker()->GetResource(decrypted_block); |
| 611 if (!object || object->pp_instance() != instance) |
| 612 return; |
| 613 dispatcher()->Send( |
| 614 new PpapiHostMsg_PPBInstance_DeliverBlock(API_ID_PPB_INSTANCE, |
| 615 instance, |
| 616 object->host_resource().host_resource(), |
| 617 request_id)); |
| 618 } |
| 619 |
| 620 void PPB_Instance_Proxy::DeliverFrame(PP_Instance instance, |
| 621 PP_Resource decrypted_frame, |
| 622 int32_t request_id) { |
| 623 Resource* object = |
| 624 PpapiGlobals::Get()->GetResourceTracker()->GetResource(decrypted_frame); |
| 625 if (!object || object->pp_instance() != instance) |
| 626 return; |
| 627 dispatcher()->Send(new PpapiHostMsg_PPBInstance_DeliverFrame( |
| 628 API_ID_PPB_INSTANCE, |
| 629 instance, |
| 630 object->host_resource().host_resource(), |
| 631 request_id)); |
| 632 } |
| 633 |
| 634 void PPB_Instance_Proxy::DeliverSamples(PP_Instance instance, |
| 635 PP_Resource decrypted_samples, |
| 636 int32_t request_id) { |
| 637 Resource* object = |
| 638 PpapiGlobals::Get()->GetResourceTracker()->GetResource(decrypted_samples); |
| 639 if (!object || object->pp_instance() != instance) |
| 640 return; |
| 641 dispatcher()->Send( |
| 642 new PpapiHostMsg_PPBInstance_DeliverSamples( |
| 643 API_ID_PPB_INSTANCE, |
| 644 instance, |
| 645 object->host_resource().host_resource(), |
| 646 request_id)); |
| 647 } |
| 648 |
| 649 |
533 void PPB_Instance_Proxy::OnHostMsgBindGraphics(PP_Instance instance, | 650 void PPB_Instance_Proxy::OnHostMsgBindGraphics(PP_Instance instance, |
534 const HostResource& device, | 651 const HostResource& device, |
535 PP_Bool* result) { | 652 PP_Bool* result) { |
536 EnterInstanceNoLock enter(instance); | 653 EnterInstanceNoLock enter(instance); |
537 if (enter.succeeded()) { | 654 if (enter.succeeded()) { |
538 *result = enter.functions()->BindGraphics(instance, | 655 *result = enter.functions()->BindGraphics(instance, |
539 device.host_resource()); | 656 device.host_resource()); |
540 } | 657 } |
541 } | 658 } |
542 | 659 |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
772 const std::string& text, | 889 const std::string& text, |
773 uint32_t caret, | 890 uint32_t caret, |
774 uint32_t anchor) { | 891 uint32_t anchor) { |
775 EnterInstanceNoLock enter(instance); | 892 EnterInstanceNoLock enter(instance); |
776 if (enter.succeeded()) { | 893 if (enter.succeeded()) { |
777 enter.functions()->UpdateSurroundingText(instance, text.c_str(), caret, | 894 enter.functions()->UpdateSurroundingText(instance, text.c_str(), caret, |
778 anchor); | 895 anchor); |
779 } | 896 } |
780 } | 897 } |
781 | 898 |
| 899 void PPB_Instance_Proxy::OnHostMsgNeedKey(PP_Instance instance, |
| 900 SerializedVarReceiveInput key_system, |
| 901 SerializedVarReceiveInput session_id, |
| 902 SerializedVarReceiveInput init_data) { |
| 903 EnterInstanceNoLock enter(instance); |
| 904 if (enter.succeeded()) { |
| 905 enter.functions()->NeedKey(instance, |
| 906 key_system.Get(dispatcher()), |
| 907 session_id.Get(dispatcher()), |
| 908 init_data.Get(dispatcher())); |
| 909 } |
| 910 } |
| 911 |
| 912 void PPB_Instance_Proxy::OnHostMsgKeyAdded( |
| 913 PP_Instance instance, |
| 914 SerializedVarReceiveInput key_system, |
| 915 SerializedVarReceiveInput session_id) { |
| 916 EnterInstanceNoLock enter(instance); |
| 917 if (enter.succeeded()) { |
| 918 enter.functions()->KeyAdded(instance, |
| 919 key_system.Get(dispatcher()), |
| 920 session_id.Get(dispatcher())); |
| 921 } |
| 922 } |
| 923 |
| 924 void PPB_Instance_Proxy::OnHostMsgKeyMessage( |
| 925 PP_Instance instance, |
| 926 SerializedVarReceiveInput key_system, |
| 927 SerializedVarReceiveInput session_id, |
| 928 PP_Resource message, |
| 929 SerializedVarReceiveInput default_url) { |
| 930 EnterInstanceNoLock enter(instance); |
| 931 if (enter.succeeded()) { |
| 932 enter.functions()->KeyMessage(instance, |
| 933 key_system.Get(dispatcher()), |
| 934 session_id.Get(dispatcher()), |
| 935 message, |
| 936 default_url.Get(dispatcher())); |
| 937 } |
| 938 } |
| 939 |
| 940 void PPB_Instance_Proxy::OnHostMsgKeyError( |
| 941 PP_Instance instance, |
| 942 SerializedVarReceiveInput key_system, |
| 943 SerializedVarReceiveInput session_id, |
| 944 int32_t media_error, |
| 945 int32_t system_error) { |
| 946 EnterInstanceNoLock enter(instance); |
| 947 if (enter.succeeded()) { |
| 948 enter.functions()->KeyError(instance, |
| 949 key_system.Get(dispatcher()), |
| 950 session_id.Get(dispatcher()), |
| 951 media_error, |
| 952 system_error); |
| 953 } |
| 954 } |
| 955 |
| 956 void PPB_Instance_Proxy::OnHostMsgDeliverBlock(PP_Instance instance, |
| 957 PP_Resource decrypted_block, |
| 958 int32_t request_id) { |
| 959 EnterInstanceNoLock enter(instance); |
| 960 if (enter.succeeded()) |
| 961 enter.functions()->DeliverBlock(instance, decrypted_block, request_id); |
| 962 } |
| 963 |
| 964 void PPB_Instance_Proxy::OnHostMsgDeliverFrame(PP_Instance instance, |
| 965 PP_Resource decrypted_frame, |
| 966 int32_t request_id) { |
| 967 EnterInstanceNoLock enter(instance); |
| 968 if (enter.succeeded()) |
| 969 enter.functions()->DeliverFrame(instance, decrypted_frame, request_id); |
| 970 } |
| 971 |
| 972 void PPB_Instance_Proxy::OnHostMsgDeliverSamples(PP_Instance instance, |
| 973 PP_Resource decrypted_samples, |
| 974 int32_t request_id) { |
| 975 EnterInstanceNoLock enter(instance); |
| 976 if (enter.succeeded()) |
| 977 enter.functions()->DeliverSamples(instance, decrypted_samples, request_id); |
| 978 } |
| 979 |
782 void PPB_Instance_Proxy::OnPluginMsgMouseLockComplete(PP_Instance instance, | 980 void PPB_Instance_Proxy::OnPluginMsgMouseLockComplete(PP_Instance instance, |
783 int32_t result) { | 981 int32_t result) { |
784 // Save the mouse callback on the instance data. | 982 // Save the mouse callback on the instance data. |
785 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> | 983 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> |
786 GetInstanceData(instance); | 984 GetInstanceData(instance); |
787 if (!data) | 985 if (!data) |
788 return; // Instance was probably deleted. | 986 return; // Instance was probably deleted. |
789 if (!TrackedCallback::IsPending(data->mouse_lock_callback)) { | 987 if (!TrackedCallback::IsPending(data->mouse_lock_callback)) { |
790 NOTREACHED(); | 988 NOTREACHED(); |
791 return; | 989 return; |
792 } | 990 } |
793 TrackedCallback::ClearAndRun(&(data->mouse_lock_callback), result); | 991 TrackedCallback::ClearAndRun(&(data->mouse_lock_callback), result); |
794 } | 992 } |
795 | 993 |
796 void PPB_Instance_Proxy::MouseLockCompleteInHost(int32_t result, | 994 void PPB_Instance_Proxy::MouseLockCompleteInHost(int32_t result, |
797 PP_Instance instance) { | 995 PP_Instance instance) { |
798 dispatcher()->Send(new PpapiMsg_PPBInstance_MouseLockComplete( | 996 dispatcher()->Send(new PpapiMsg_PPBInstance_MouseLockComplete( |
799 API_ID_PPB_INSTANCE, instance, result)); | 997 API_ID_PPB_INSTANCE, instance, result)); |
800 } | 998 } |
801 | 999 |
802 } // namespace proxy | 1000 } // namespace proxy |
803 } // namespace ppapi | 1001 } // namespace ppapi |
OLD | NEW |