| OLD | NEW |
| 1 // Copyright (c) 2011 The Native Client Authors. All rights reserved. | 1 // Copyright (c) 2011 The Native Client 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 "native_client/src/shared/ppapi_proxy/browser_ppp.h" | 5 #include "native_client/src/shared/ppapi_proxy/browser_ppp.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include "native_client/src/include/nacl_scoped_ptr.h" | 9 #include "native_client/src/include/nacl_scoped_ptr.h" |
| 10 #include "native_client/src/include/portability.h" | 10 #include "native_client/src/include/portability.h" |
| 11 #include "native_client/src/include/portability_process.h" | 11 #include "native_client/src/include/portability_process.h" |
| 12 #include "native_client/src/shared/ppapi_proxy/browser_globals.h" | 12 #include "native_client/src/shared/ppapi_proxy/browser_globals.h" |
| 13 #include "native_client/src/shared/ppapi_proxy/browser_ppp_find.h" | 13 #include "native_client/src/shared/ppapi_proxy/browser_ppp_find.h" |
| 14 #include "native_client/src/shared/ppapi_proxy/browser_ppp_input_event.h" |
| 14 #include "native_client/src/shared/ppapi_proxy/browser_ppp_instance.h" | 15 #include "native_client/src/shared/ppapi_proxy/browser_ppp_instance.h" |
| 15 #include "native_client/src/shared/ppapi_proxy/browser_ppp_messaging.h" | 16 #include "native_client/src/shared/ppapi_proxy/browser_ppp_messaging.h" |
| 16 #include "native_client/src/shared/ppapi_proxy/browser_ppp_printing.h" | 17 #include "native_client/src/shared/ppapi_proxy/browser_ppp_printing.h" |
| 17 #include "native_client/src/shared/ppapi_proxy/browser_ppp_scrollbar.h" | 18 #include "native_client/src/shared/ppapi_proxy/browser_ppp_scrollbar.h" |
| 18 #include "native_client/src/shared/ppapi_proxy/browser_ppp_selection.h" | 19 #include "native_client/src/shared/ppapi_proxy/browser_ppp_selection.h" |
| 19 #include "native_client/src/shared/ppapi_proxy/browser_ppp_widget.h" | 20 #include "native_client/src/shared/ppapi_proxy/browser_ppp_widget.h" |
| 20 #include "native_client/src/shared/ppapi_proxy/browser_ppp_zoom.h" | 21 #include "native_client/src/shared/ppapi_proxy/browser_ppp_zoom.h" |
| 21 #include "native_client/src/shared/ppapi_proxy/browser_upcall.h" | 22 #include "native_client/src/shared/ppapi_proxy/browser_upcall.h" |
| 23 #include "native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppb_rpc.h" |
| 24 #include "native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppp_rpc.h" |
| 22 #include "native_client/src/shared/ppapi_proxy/utility.h" | 25 #include "native_client/src/shared/ppapi_proxy/utility.h" |
| 23 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" | 26 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" |
| 24 #include "native_client/src/trusted/plugin/ppapi/plugin_ppapi.h" | 27 #include "native_client/src/trusted/plugin/ppapi/plugin_ppapi.h" |
| 28 #include "native_client/src/third_party/ppapi/c/ppp_input_event.h" |
| 25 #include "native_client/src/third_party/ppapi/c/dev/ppp_find_dev.h" | 29 #include "native_client/src/third_party/ppapi/c/dev/ppp_find_dev.h" |
| 26 #include "native_client/src/third_party/ppapi/c/dev/ppp_printing_dev.h" | 30 #include "native_client/src/third_party/ppapi/c/dev/ppp_printing_dev.h" |
| 27 #include "native_client/src/third_party/ppapi/c/dev/ppp_scrollbar_dev.h" | 31 #include "native_client/src/third_party/ppapi/c/dev/ppp_scrollbar_dev.h" |
| 28 #include "native_client/src/third_party/ppapi/c/dev/ppp_selection_dev.h" | 32 #include "native_client/src/third_party/ppapi/c/dev/ppp_selection_dev.h" |
| 29 #include "native_client/src/third_party/ppapi/c/dev/ppp_widget_dev.h" | 33 #include "native_client/src/third_party/ppapi/c/dev/ppp_widget_dev.h" |
| 30 #include "native_client/src/third_party/ppapi/c/dev/ppp_zoom_dev.h" | 34 #include "native_client/src/third_party/ppapi/c/dev/ppp_zoom_dev.h" |
| 31 #include "native_client/src/third_party/ppapi/c/pp_errors.h" | 35 #include "native_client/src/third_party/ppapi/c/pp_errors.h" |
| 32 #include "native_client/src/third_party/ppapi/c/ppp.h" | 36 #include "native_client/src/third_party/ppapi/c/ppp.h" |
| 33 #include "srpcgen/ppb_rpc.h" | |
| 34 #include "srpcgen/ppp_rpc.h" | |
| 35 | 37 |
| 36 namespace ppapi_proxy { | 38 namespace ppapi_proxy { |
| 37 | 39 |
| 38 // | 40 // |
| 39 // The following methods are the SRPC dispatchers for ppapi/c/ppp.h. | 41 // The following methods are the SRPC dispatchers for ppapi/c/ppp.h. |
| 40 // | 42 // |
| 41 | 43 |
| 42 int32_t BrowserPpp::InitializeModule( | 44 int32_t BrowserPpp::InitializeModule( |
| 43 PP_Module module_id, | 45 PP_Module module_id, |
| 44 PPB_GetInterface get_browser_interface) { | 46 PPB_GetInterface get_browser_interface) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 DebugPrintf("PPP_InitializeModule: pp_error=%"NACL_PRId32"\n", pp_error); | 89 DebugPrintf("PPP_InitializeModule: pp_error=%"NACL_PRId32"\n", pp_error); |
| 88 if (pp_error != PP_OK) { | 90 if (pp_error != PP_OK) { |
| 89 return pp_error; | 91 return pp_error; |
| 90 } | 92 } |
| 91 const void* ppp_instance = GetPluginInterface(PPP_INSTANCE_INTERFACE); | 93 const void* ppp_instance = GetPluginInterface(PPP_INSTANCE_INTERFACE); |
| 92 DebugPrintf("PPP_InitializeModule: ppp_instance=%p\n", ppp_instance); | 94 DebugPrintf("PPP_InitializeModule: ppp_instance=%p\n", ppp_instance); |
| 93 ppp_instance_interface_ = reinterpret_cast<const PPP_Instance*>(ppp_instance); | 95 ppp_instance_interface_ = reinterpret_cast<const PPP_Instance*>(ppp_instance); |
| 94 if (ppp_instance_interface_ == NULL) { // PPP_Instance is required. | 96 if (ppp_instance_interface_ == NULL) { // PPP_Instance is required. |
| 95 return PP_ERROR_NOINTERFACE; | 97 return PP_ERROR_NOINTERFACE; |
| 96 } | 98 } |
| 97 // PPB_Messaging is optional, so it's OK for this to return NULL. | 99 // PPB_Messaging and PPP_InputEvent are optional, so it's OK for them to |
| 100 // return NULL. |
| 98 ppp_messaging_interface_ = reinterpret_cast<const PPP_Messaging*>( | 101 ppp_messaging_interface_ = reinterpret_cast<const PPP_Messaging*>( |
| 99 GetPluginInterface(PPP_MESSAGING_INTERFACE)); | 102 GetPluginInterface(PPP_MESSAGING_INTERFACE)); |
| 103 ppp_input_event_interface_ = reinterpret_cast<const PPP_InputEvent*>( |
| 104 GetPluginInterface(PPP_INPUT_EVENT_INTERFACE)); |
| 100 return PP_OK; | 105 return PP_OK; |
| 101 } | 106 } |
| 102 | 107 |
| 103 void BrowserPpp::ShutdownModule() { | 108 void BrowserPpp::ShutdownModule() { |
| 104 DebugPrintf("PPP_ShutdownModule\n"); | 109 DebugPrintf("PPP_ShutdownModule\n"); |
| 105 NaClSrpcError srpc_result = | 110 NaClSrpcError srpc_result = |
| 106 PppRpcClient::PPP_ShutdownModule(main_channel_); | 111 PppRpcClient::PPP_ShutdownModule(main_channel_); |
| 107 DebugPrintf("PPP_ShutdownModule: %s\n", NaClSrpcErrorString(srpc_result)); | 112 DebugPrintf("PPP_ShutdownModule: %s\n", NaClSrpcErrorString(srpc_result)); |
| 108 NaClThreadJoin(&upcall_thread_); | 113 NaClThreadJoin(&upcall_thread_); |
| 109 UnsetModuleIdForSrpcChannel(main_channel_); | 114 UnsetModuleIdForSrpcChannel(main_channel_); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 121 interface_name, NaClSrpcErrorString(srpc_result)); | 126 interface_name, NaClSrpcErrorString(srpc_result)); |
| 122 const void* ppp_interface = NULL; | 127 const void* ppp_interface = NULL; |
| 123 if (srpc_result != NACL_SRPC_RESULT_OK || !exports_interface_name) { | 128 if (srpc_result != NACL_SRPC_RESULT_OK || !exports_interface_name) { |
| 124 ppp_interface = NULL; | 129 ppp_interface = NULL; |
| 125 } else if (strcmp(interface_name, PPP_INSTANCE_INTERFACE) == 0) { | 130 } else if (strcmp(interface_name, PPP_INSTANCE_INTERFACE) == 0) { |
| 126 ppp_interface = | 131 ppp_interface = |
| 127 reinterpret_cast<const void*>(BrowserInstance::GetInterface()); | 132 reinterpret_cast<const void*>(BrowserInstance::GetInterface()); |
| 128 } else if (strcmp(interface_name, PPP_MESSAGING_INTERFACE) == 0) { | 133 } else if (strcmp(interface_name, PPP_MESSAGING_INTERFACE) == 0) { |
| 129 ppp_interface = | 134 ppp_interface = |
| 130 reinterpret_cast<const void*>(BrowserMessaging::GetInterface()); | 135 reinterpret_cast<const void*>(BrowserMessaging::GetInterface()); |
| 136 } else if (strcmp(interface_name, PPP_INPUT_EVENT_INTERFACE) == 0) { |
| 137 ppp_interface = |
| 138 reinterpret_cast<const void*>(BrowserInputEvent::GetInterface()); |
| 131 } else if (strcmp(interface_name, PPP_FIND_DEV_INTERFACE) == 0) { | 139 } else if (strcmp(interface_name, PPP_FIND_DEV_INTERFACE) == 0) { |
| 132 ppp_interface = | 140 ppp_interface = |
| 133 reinterpret_cast<const void*>(BrowserFind::GetInterface()); | 141 reinterpret_cast<const void*>(BrowserFind::GetInterface()); |
| 134 } else if (strcmp(interface_name, PPP_PRINTING_DEV_INTERFACE) == 0) { | 142 } else if (strcmp(interface_name, PPP_PRINTING_DEV_INTERFACE) == 0) { |
| 135 ppp_interface = | 143 ppp_interface = |
| 136 reinterpret_cast<const void*>(BrowserPrinting::GetInterface()); | 144 reinterpret_cast<const void*>(BrowserPrinting::GetInterface()); |
| 137 } else if (strcmp(interface_name, PPP_SCROLLBAR_DEV_INTERFACE) == 0) { | 145 } else if (strcmp(interface_name, PPP_SCROLLBAR_DEV_INTERFACE) == 0) { |
| 138 ppp_interface = | 146 ppp_interface = |
| 139 reinterpret_cast<const void*>(BrowserScrollbar::GetInterface()); | 147 reinterpret_cast<const void*>(BrowserScrollbar::GetInterface()); |
| 140 } else if (strcmp(interface_name, PPP_SELECTION_DEV_INTERFACE) == 0) { | 148 } else if (strcmp(interface_name, PPP_SELECTION_DEV_INTERFACE) == 0) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 154 | 162 |
| 155 const void* BrowserPpp::GetPluginInterfaceSafe(const char* interface_name) { | 163 const void* BrowserPpp::GetPluginInterfaceSafe(const char* interface_name) { |
| 156 const void* ppp_interface = GetPluginInterface(interface_name); | 164 const void* ppp_interface = GetPluginInterface(interface_name); |
| 157 if (ppp_interface == NULL) | 165 if (ppp_interface == NULL) |
| 158 DebugPrintf("PPB_GetInterface: %s not found\n", interface_name); | 166 DebugPrintf("PPB_GetInterface: %s not found\n", interface_name); |
| 159 CHECK(ppp_interface != NULL); | 167 CHECK(ppp_interface != NULL); |
| 160 return ppp_interface; | 168 return ppp_interface; |
| 161 } | 169 } |
| 162 | 170 |
| 163 } // namespace ppapi_proxy | 171 } // namespace ppapi_proxy |
| OLD | NEW |