| 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 "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
| 9 #include "ppapi/c/pp_time.h" | 9 #include "ppapi/c/pp_time.h" |
| 10 #include "ppapi/c/pp_var.h" | 10 #include "ppapi/c/pp_var.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 &CreateInstanceProxy, | 89 &CreateInstanceProxy, |
| 90 }; | 90 }; |
| 91 return &info; | 91 return &info; |
| 92 } | 92 } |
| 93 | 93 |
| 94 bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) { | 94 bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) { |
| 95 // Prevent the dispatcher from going away during a call to ExecuteScript. | 95 // Prevent the dispatcher from going away during a call to ExecuteScript. |
| 96 // This must happen OUTSIDE of ExecuteScript since the SerializedVars use | 96 // This must happen OUTSIDE of ExecuteScript since the SerializedVars use |
| 97 // the dispatcher upon return of the function (converting the | 97 // the dispatcher upon return of the function (converting the |
| 98 // SerializedVarReturnValue/OutParam to a SerializedVar in the destructor). | 98 // SerializedVarReturnValue/OutParam to a SerializedVar in the destructor). |
| 99 #if !defined(OS_NACL) |
| 99 ScopedModuleReference death_grip(dispatcher()); | 100 ScopedModuleReference death_grip(dispatcher()); |
| 101 #endif |
| 100 | 102 |
| 101 bool handled = true; | 103 bool handled = true; |
| 102 IPC_BEGIN_MESSAGE_MAP(PPB_Instance_Proxy, msg) | 104 IPC_BEGIN_MESSAGE_MAP(PPB_Instance_Proxy, msg) |
| 105 #if !defined(OS_NACL) |
| 103 // Plugin -> Host messages. | 106 // Plugin -> Host messages. |
| 104 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetWindowObject, | 107 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetWindowObject, |
| 105 OnHostMsgGetWindowObject) | 108 OnHostMsgGetWindowObject) |
| 106 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetOwnerElementObject, | 109 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetOwnerElementObject, |
| 107 OnHostMsgGetOwnerElementObject) | 110 OnHostMsgGetOwnerElementObject) |
| 108 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_BindGraphics, | 111 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_BindGraphics, |
| 109 OnHostMsgBindGraphics) | 112 OnHostMsgBindGraphics) |
| 110 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_IsFullFrame, | 113 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_IsFullFrame, |
| 111 OnHostMsgIsFullFrame) | 114 OnHostMsgIsFullFrame) |
| 112 IPC_MESSAGE_HANDLER( | 115 IPC_MESSAGE_HANDLER( |
| (...skipping 25 matching lines...) Expand all Loading... |
| 138 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetCursor, | 141 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetCursor, |
| 139 OnHostMsgSetCursor) | 142 OnHostMsgSetCursor) |
| 140 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetTextInputType, | 143 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetTextInputType, |
| 141 OnHostMsgSetTextInputType) | 144 OnHostMsgSetTextInputType) |
| 142 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UpdateCaretPosition, | 145 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UpdateCaretPosition, |
| 143 OnHostMsgUpdateCaretPosition) | 146 OnHostMsgUpdateCaretPosition) |
| 144 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_CancelCompositionText, | 147 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_CancelCompositionText, |
| 145 OnHostMsgCancelCompositionText) | 148 OnHostMsgCancelCompositionText) |
| 146 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UpdateSurroundingText, | 149 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UpdateSurroundingText, |
| 147 OnHostMsgUpdateSurroundingText) | 150 OnHostMsgUpdateSurroundingText) |
| 148 | |
| 149 #if !defined(OS_NACL) | |
| 150 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ResolveRelativeToDocument, | 151 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ResolveRelativeToDocument, |
| 151 OnHostMsgResolveRelativeToDocument) | 152 OnHostMsgResolveRelativeToDocument) |
| 152 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DocumentCanRequest, | 153 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DocumentCanRequest, |
| 153 OnHostMsgDocumentCanRequest) | 154 OnHostMsgDocumentCanRequest) |
| 154 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DocumentCanAccessDocument, | 155 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DocumentCanAccessDocument, |
| 155 OnHostMsgDocumentCanAccessDocument) | 156 OnHostMsgDocumentCanAccessDocument) |
| 156 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetDocumentURL, | 157 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetDocumentURL, |
| 157 OnHostMsgGetDocumentURL) | 158 OnHostMsgGetDocumentURL) |
| 158 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetPluginInstanceURL, | 159 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetPluginInstanceURL, |
| 159 OnHostMsgGetPluginInstanceURL) | 160 OnHostMsgGetPluginInstanceURL) |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 } | 680 } |
| 680 | 681 |
| 681 void PPB_Instance_Proxy::UpdateSurroundingText(PP_Instance instance, | 682 void PPB_Instance_Proxy::UpdateSurroundingText(PP_Instance instance, |
| 682 const char* text, | 683 const char* text, |
| 683 uint32_t caret, | 684 uint32_t caret, |
| 684 uint32_t anchor) { | 685 uint32_t anchor) { |
| 685 dispatcher()->Send(new PpapiHostMsg_PPBInstance_UpdateSurroundingText( | 686 dispatcher()->Send(new PpapiHostMsg_PPBInstance_UpdateSurroundingText( |
| 686 API_ID_PPB_INSTANCE, instance, text, caret, anchor)); | 687 API_ID_PPB_INSTANCE, instance, text, caret, anchor)); |
| 687 } | 688 } |
| 688 | 689 |
| 690 #if !defined(OS_NACL) |
| 689 void PPB_Instance_Proxy::OnHostMsgGetWindowObject( | 691 void PPB_Instance_Proxy::OnHostMsgGetWindowObject( |
| 690 PP_Instance instance, | 692 PP_Instance instance, |
| 691 SerializedVarReturnValue result) { | 693 SerializedVarReturnValue result) { |
| 692 EnterInstanceNoLock enter(instance); | 694 EnterInstanceNoLock enter(instance); |
| 693 if (enter.succeeded()) | 695 if (enter.succeeded()) |
| 694 result.Return(dispatcher(), enter.functions()->GetWindowObject(instance)); | 696 result.Return(dispatcher(), enter.functions()->GetWindowObject(instance)); |
| 695 } | 697 } |
| 696 | 698 |
| 697 void PPB_Instance_Proxy::OnHostMsgGetOwnerElementObject( | 699 void PPB_Instance_Proxy::OnHostMsgGetOwnerElementObject( |
| 698 PP_Instance instance, | 700 PP_Instance instance, |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1019 PP_Instance instance, | 1021 PP_Instance instance, |
| 1020 const std::string& text, | 1022 const std::string& text, |
| 1021 uint32_t caret, | 1023 uint32_t caret, |
| 1022 uint32_t anchor) { | 1024 uint32_t anchor) { |
| 1023 EnterInstanceNoLock enter(instance); | 1025 EnterInstanceNoLock enter(instance); |
| 1024 if (enter.succeeded()) { | 1026 if (enter.succeeded()) { |
| 1025 enter.functions()->UpdateSurroundingText(instance, text.c_str(), caret, | 1027 enter.functions()->UpdateSurroundingText(instance, text.c_str(), caret, |
| 1026 anchor); | 1028 anchor); |
| 1027 } | 1029 } |
| 1028 } | 1030 } |
| 1031 #endif // !defined(OS_NACL) |
| 1029 | 1032 |
| 1030 void PPB_Instance_Proxy::OnPluginMsgMouseLockComplete(PP_Instance instance, | 1033 void PPB_Instance_Proxy::OnPluginMsgMouseLockComplete(PP_Instance instance, |
| 1031 int32_t result) { | 1034 int32_t result) { |
| 1032 // Save the mouse callback on the instance data. | 1035 // Save the mouse callback on the instance data. |
| 1033 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> | 1036 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> |
| 1034 GetInstanceData(instance); | 1037 GetInstanceData(instance); |
| 1035 if (!data) | 1038 if (!data) |
| 1036 return; // Instance was probably deleted. | 1039 return; // Instance was probably deleted. |
| 1037 if (!TrackedCallback::IsPending(data->mouse_lock_callback)) { | 1040 if (!TrackedCallback::IsPending(data->mouse_lock_callback)) { |
| 1038 NOTREACHED(); | 1041 NOTREACHED(); |
| 1039 return; | 1042 return; |
| 1040 } | 1043 } |
| 1041 TrackedCallback::ClearAndRun(&(data->mouse_lock_callback), result); | 1044 TrackedCallback::ClearAndRun(&(data->mouse_lock_callback), result); |
| 1042 } | 1045 } |
| 1043 | 1046 |
| 1047 #if !defined(OS_NACL) |
| 1044 void PPB_Instance_Proxy::MouseLockCompleteInHost(int32_t result, | 1048 void PPB_Instance_Proxy::MouseLockCompleteInHost(int32_t result, |
| 1045 PP_Instance instance) { | 1049 PP_Instance instance) { |
| 1046 dispatcher()->Send(new PpapiMsg_PPBInstance_MouseLockComplete( | 1050 dispatcher()->Send(new PpapiMsg_PPBInstance_MouseLockComplete( |
| 1047 API_ID_PPB_INSTANCE, instance, result)); | 1051 API_ID_PPB_INSTANCE, instance, result)); |
| 1048 } | 1052 } |
| 1053 #endif // !defined(OS_NACL) |
| 1049 | 1054 |
| 1050 void PPB_Instance_Proxy::CancelAnyPendingRequestSurroundingText( | 1055 void PPB_Instance_Proxy::CancelAnyPendingRequestSurroundingText( |
| 1051 PP_Instance instance) { | 1056 PP_Instance instance) { |
| 1052 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> | 1057 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> |
| 1053 GetInstanceData(instance); | 1058 GetInstanceData(instance); |
| 1054 if (!data) | 1059 if (!data) |
| 1055 return; // Instance was probably deleted. | 1060 return; // Instance was probably deleted. |
| 1056 data->should_do_request_surrounding_text = false; | 1061 data->should_do_request_surrounding_text = false; |
| 1057 } | 1062 } |
| 1058 | 1063 |
| 1059 } // namespace proxy | 1064 } // namespace proxy |
| 1060 } // namespace ppapi | 1065 } // namespace ppapi |
| OLD | NEW |