[email protected] | b697e1a | 2011-01-06 22:20:28 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "ppapi/proxy/dispatcher.h" |
| 6 | |
| 7 | #include <string.h> // For memset. |
| 8 | |
| 9 | #include <map> |
| 10 | |
[email protected] | 709a847e | 2010-11-10 01:16:11 | [diff] [blame] | 11 | #include "base/compiler_specific.h" |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 12 | #include "base/logging.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 13 | #include "base/memory/singleton.h" |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 14 | #include "ppapi/c/dev/ppb_buffer_dev.h" |
[email protected] | 9ca952d | 2010-11-11 20:43:50 | [diff] [blame] | 15 | #include "ppapi/c/dev/ppb_char_set_dev.h" |
[email protected] | f56279c | 2011-02-02 18:12:31 | [diff] [blame] | 16 | #include "ppapi/c/dev/ppb_context_3d_dev.h" |
[email protected] | f682ad7 | 2011-04-20 15:25:55 | [diff] [blame] | 17 | #include "ppapi/c/dev/ppb_crypto_dev.h" |
[email protected] | a301033 | 2010-11-12 07:09:35 | [diff] [blame] | 18 | #include "ppapi/c/dev/ppb_cursor_control_dev.h" |
[email protected] | f56279c | 2011-02-02 18:12:31 | [diff] [blame] | 19 | #include "ppapi/c/dev/ppb_gles_chromium_texture_mapping_dev.h" |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 20 | #include "ppapi/c/dev/ppb_font_dev.h" |
[email protected] | f56279c | 2011-02-02 18:12:31 | [diff] [blame] | 21 | #include "ppapi/c/dev/ppb_opengles_dev.h" |
| 22 | #include "ppapi/c/dev/ppb_surface_3d_dev.h" |
[email protected] | 799d1ab | 2010-11-09 17:16:28 | [diff] [blame] | 23 | #include "ppapi/c/dev/ppb_testing_dev.h" |
[email protected] | 9ca245e | 2011-03-18 01:50:31 | [diff] [blame] | 24 | #include "ppapi/c/dev/ppb_url_util_dev.h" |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 25 | #include "ppapi/c/dev/ppb_var_deprecated.h" |
| 26 | #include "ppapi/c/pp_errors.h" |
[email protected] | b9a5984 | 2011-01-15 01:04:00 | [diff] [blame] | 27 | #include "ppapi/c/ppb_audio.h" |
| 28 | #include "ppapi/c/ppb_audio_config.h" |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 29 | #include "ppapi/c/ppb_core.h" |
| 30 | #include "ppapi/c/ppb_graphics_2d.h" |
| 31 | #include "ppapi/c/ppb_image_data.h" |
| 32 | #include "ppapi/c/ppb_instance.h" |
[email protected] | 5a3f6285 | 2010-11-10 21:43:01 | [diff] [blame] | 33 | #include "ppapi/c/ppb_url_loader.h" |
| 34 | #include "ppapi/c/ppb_url_request_info.h" |
| 35 | #include "ppapi/c/ppb_url_response_info.h" |
[email protected] | 0925622c | 2011-06-08 20:22:02 | [diff] [blame] | 36 | #include "ppapi/c/ppb_var.h" |
[email protected] | 9ca952d | 2010-11-11 20:43:50 | [diff] [blame] | 37 | #include "ppapi/c/ppp_instance.h" |
[email protected] | b697e1a | 2011-01-06 22:20:28 | [diff] [blame] | 38 | #include "ppapi/c/private/ppb_flash.h" |
[email protected] | 5cf8a5b | 2011-03-09 19:00:05 | [diff] [blame] | 39 | #include "ppapi/c/private/ppb_flash_clipboard.h" |
[email protected] | d07fa379 | 2011-02-24 18:58:01 | [diff] [blame] | 40 | #include "ppapi/c/private/ppb_flash_file.h" |
[email protected] | 7358d57 | 2011-02-15 18:44:40 | [diff] [blame] | 41 | #include "ppapi/c/private/ppb_flash_menu.h" |
[email protected] | 7d3782f | 2011-03-29 19:16:23 | [diff] [blame] | 42 | #include "ppapi/c/private/ppb_flash_net_connector.h" |
[email protected] | 373a95a | 2011-07-01 16:58:14 | [diff] [blame] | 43 | #include "ppapi/c/private/ppb_flash_tcp_socket.h" |
[email protected] | 917a44b0 | 2011-01-13 17:07:29 | [diff] [blame] | 44 | #include "ppapi/c/private/ppb_pdf.h" |
[email protected] | 5f251761 | 2010-12-02 22:36:48 | [diff] [blame] | 45 | #include "ppapi/c/trusted/ppb_url_loader_trusted.h" |
[email protected] | 9ca952d | 2010-11-11 20:43:50 | [diff] [blame] | 46 | #include "ppapi/proxy/ppapi_messages.h" |
[email protected] | 5d84d01 | 2010-12-02 17:17:21 | [diff] [blame] | 47 | #include "ppapi/proxy/ppb_audio_config_proxy.h" |
| 48 | #include "ppapi/proxy/ppb_audio_proxy.h" |
[email protected] | ae971c2 | 2011-04-17 00:13:22 | [diff] [blame] | 49 | #include "ppapi/proxy/ppb_broker_proxy.h" |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 50 | #include "ppapi/proxy/ppb_buffer_proxy.h" |
[email protected] | 9ca952d | 2010-11-11 20:43:50 | [diff] [blame] | 51 | #include "ppapi/proxy/ppb_char_set_proxy.h" |
[email protected] | d38c5740 | 2011-03-11 20:20:56 | [diff] [blame] | 52 | #include "ppapi/proxy/ppb_console_proxy.h" |
[email protected] | f56279c | 2011-02-02 18:12:31 | [diff] [blame] | 53 | #include "ppapi/proxy/ppb_context_3d_proxy.h" |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 54 | #include "ppapi/proxy/ppb_core_proxy.h" |
[email protected] | f682ad7 | 2011-04-20 15:25:55 | [diff] [blame] | 55 | #include "ppapi/proxy/ppb_crypto_proxy.h" |
[email protected] | a301033 | 2010-11-12 07:09:35 | [diff] [blame] | 56 | #include "ppapi/proxy/ppb_cursor_control_proxy.h" |
[email protected] | 4deeb43 | 2011-02-17 23:59:39 | [diff] [blame] | 57 | #include "ppapi/proxy/ppb_file_chooser_proxy.h" |
| 58 | #include "ppapi/proxy/ppb_file_ref_proxy.h" |
[email protected] | ce482df | 2011-02-21 23:49:16 | [diff] [blame] | 59 | #include "ppapi/proxy/ppb_file_system_proxy.h" |
[email protected] | 5cf8a5b | 2011-03-09 19:00:05 | [diff] [blame] | 60 | #include "ppapi/proxy/ppb_flash_clipboard_proxy.h" |
[email protected] | d07fa379 | 2011-02-24 18:58:01 | [diff] [blame] | 61 | #include "ppapi/proxy/ppb_flash_file_proxy.h" |
[email protected] | 5f251761 | 2010-12-02 22:36:48 | [diff] [blame] | 62 | #include "ppapi/proxy/ppb_flash_proxy.h" |
[email protected] | 7358d57 | 2011-02-15 18:44:40 | [diff] [blame] | 63 | #include "ppapi/proxy/ppb_flash_menu_proxy.h" |
[email protected] | 7d3782f | 2011-03-29 19:16:23 | [diff] [blame] | 64 | #include "ppapi/proxy/ppb_flash_net_connector_proxy.h" |
[email protected] | 373a95a | 2011-07-01 16:58:14 | [diff] [blame] | 65 | #include "ppapi/proxy/ppb_flash_tcp_socket_proxy.h" |
[email protected] | 9ca952d | 2010-11-11 20:43:50 | [diff] [blame] | 66 | #include "ppapi/proxy/ppb_font_proxy.h" |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 67 | #include "ppapi/proxy/ppb_graphics_2d_proxy.h" |
[email protected] | 0e50fc4d | 2011-08-01 15:33:51 | [diff] [blame] | 68 | #include "ppapi/proxy/ppb_graphics_3d_proxy.h" |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 69 | #include "ppapi/proxy/ppb_image_data_proxy.h" |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 70 | #include "ppapi/proxy/ppb_input_event_proxy.h" |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 71 | #include "ppapi/proxy/ppb_instance_proxy.h" |
[email protected] | dc0156ac | 2011-07-06 22:17:14 | [diff] [blame] | 72 | #include "ppapi/proxy/ppb_memory_proxy.h" |
[email protected] | f56279c | 2011-02-02 18:12:31 | [diff] [blame] | 73 | #include "ppapi/proxy/ppb_opengles2_proxy.h" |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 74 | #include "ppapi/proxy/ppb_pdf_proxy.h" |
[email protected] | f56279c | 2011-02-02 18:12:31 | [diff] [blame] | 75 | #include "ppapi/proxy/ppb_surface_3d_proxy.h" |
[email protected] | 799d1ab | 2010-11-09 17:16:28 | [diff] [blame] | 76 | #include "ppapi/proxy/ppb_testing_proxy.h" |
| 77 | #include "ppapi/proxy/ppb_url_loader_proxy.h" |
| 78 | #include "ppapi/proxy/ppb_url_request_info_proxy.h" |
| 79 | #include "ppapi/proxy/ppb_url_response_info_proxy.h" |
[email protected] | 9ca245e | 2011-03-18 01:50:31 | [diff] [blame] | 80 | #include "ppapi/proxy/ppb_url_util_proxy.h" |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 81 | #include "ppapi/proxy/ppb_var_deprecated_proxy.h" |
[email protected] | 0925622c | 2011-06-08 20:22:02 | [diff] [blame] | 82 | #include "ppapi/proxy/ppb_var_proxy.h" |
[email protected] | 0fa46e8 | 2011-08-09 07:31:49 | [diff] [blame] | 83 | #include "ppapi/proxy/ppb_video_capture_proxy.h" |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 84 | #include "ppapi/proxy/ppb_video_decoder_proxy.h" |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 85 | #include "ppapi/proxy/ppp_class_proxy.h" |
[email protected] | 8c3bd1d | 2011-04-12 20:01:42 | [diff] [blame] | 86 | #include "ppapi/proxy/ppp_graphics_3d_proxy.h" |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 87 | #include "ppapi/proxy/ppp_input_event_proxy.h" |
[email protected] | 792f1ca3 | 2011-05-25 16:43:43 | [diff] [blame] | 88 | #include "ppapi/proxy/ppp_instance_private_proxy.h" |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 89 | #include "ppapi/proxy/ppp_instance_proxy.h" |
[email protected] | b20df1c | 2011-08-03 14:38:24 | [diff] [blame] | 90 | #include "ppapi/proxy/ppp_messaging_proxy.h" |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 91 | #include "ppapi/proxy/ppp_video_decoder_proxy.h" |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 92 | #include "ppapi/proxy/var_serialization_rules.h" |
| 93 | |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame^] | 94 | namespace ppapi { |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 95 | namespace proxy { |
| 96 | |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 97 | namespace { |
| 98 | |
| 99 | struct InterfaceList { |
| 100 | InterfaceList(); |
| 101 | |
| 102 | static InterfaceList* GetInstance(); |
| 103 | |
| 104 | void AddPPP(const InterfaceProxy::Info* info); |
| 105 | void AddPPB(const InterfaceProxy::Info* info); |
| 106 | |
| 107 | typedef std::map<std::string, const InterfaceProxy::Info*> NameToInfo; |
| 108 | NameToInfo name_to_plugin_info_; |
| 109 | NameToInfo name_to_browser_info_; |
| 110 | |
[email protected] | ceadc39 | 2011-06-15 23:04:24 | [diff] [blame] | 111 | // Note that there can be multiple interface names mapping to the same ID. |
| 112 | // In this case, the ID will map to one of them. This is temporary while |
| 113 | // we're converting to the thunk system, when that is complete, we need to |
| 114 | // have a better way of handling multiple interface implemented by one |
| 115 | // proxy object. |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 116 | const InterfaceProxy::Info* id_to_browser_info_[INTERFACE_ID_COUNT]; |
| 117 | }; |
| 118 | |
| 119 | InterfaceList::InterfaceList() { |
[email protected] | ce482df | 2011-02-21 23:49:16 | [diff] [blame] | 120 | memset(id_to_browser_info_, 0, sizeof(id_to_browser_info_)); |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 121 | |
| 122 | // PPB (browser) interfaces. |
| 123 | AddPPB(PPB_AudioConfig_Proxy::GetInfo()); |
| 124 | AddPPB(PPB_Audio_Proxy::GetInfo()); |
[email protected] | ae971c2 | 2011-04-17 00:13:22 | [diff] [blame] | 125 | AddPPB(PPB_Broker_Proxy::GetInfo()); |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 126 | AddPPB(PPB_Buffer_Proxy::GetInfo()); |
| 127 | AddPPB(PPB_CharSet_Proxy::GetInfo()); |
[email protected] | d38c5740 | 2011-03-11 20:20:56 | [diff] [blame] | 128 | AddPPB(PPB_Console_Proxy::GetInfo()); |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 129 | AddPPB(PPB_Context3D_Proxy::GetInfo()); |
[email protected] | e18e639 | 2011-06-22 20:57:00 | [diff] [blame] | 130 | AddPPB(PPB_Context3D_Proxy::GetTextureMappingInfo()); |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 131 | AddPPB(PPB_Core_Proxy::GetInfo()); |
[email protected] | f682ad7 | 2011-04-20 15:25:55 | [diff] [blame] | 132 | AddPPB(PPB_Crypto_Proxy::GetInfo()); |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 133 | AddPPB(PPB_CursorControl_Proxy::GetInfo()); |
[email protected] | 4deeb43 | 2011-02-17 23:59:39 | [diff] [blame] | 134 | AddPPB(PPB_FileChooser_Proxy::GetInfo()); |
| 135 | AddPPB(PPB_FileRef_Proxy::GetInfo()); |
[email protected] | ce482df | 2011-02-21 23:49:16 | [diff] [blame] | 136 | AddPPB(PPB_FileSystem_Proxy::GetInfo()); |
[email protected] | 5cf8a5b | 2011-03-09 19:00:05 | [diff] [blame] | 137 | AddPPB(PPB_Flash_Clipboard_Proxy::GetInfo()); |
[email protected] | d062d96 | 2011-03-02 01:27:26 | [diff] [blame] | 138 | AddPPB(PPB_Flash_File_FileRef_Proxy::GetInfo()); |
[email protected] | d07fa379 | 2011-02-24 18:58:01 | [diff] [blame] | 139 | AddPPB(PPB_Flash_File_ModuleLocal_Proxy::GetInfo()); |
[email protected] | 7358d57 | 2011-02-15 18:44:40 | [diff] [blame] | 140 | AddPPB(PPB_Flash_Menu_Proxy::GetInfo()); |
[email protected] | f3579d1 | 2011-07-22 15:47:42 | [diff] [blame] | 141 | AddPPB(PPB_Flash_Proxy::GetInfo()); |
[email protected] | 373a95a | 2011-07-01 16:58:14 | [diff] [blame] | 142 | AddPPB(PPB_Flash_TCPSocket_Proxy::GetInfo()); |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 143 | AddPPB(PPB_Font_Proxy::GetInfo()); |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 144 | AddPPB(PPB_Graphics2D_Proxy::GetInfo()); |
[email protected] | 0e50fc4d | 2011-08-01 15:33:51 | [diff] [blame] | 145 | AddPPB(PPB_Graphics3D_Proxy::GetInfo()); |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 146 | AddPPB(PPB_ImageData_Proxy::GetInfo()); |
[email protected] | f3579d1 | 2011-07-22 15:47:42 | [diff] [blame] | 147 | AddPPB(PPB_InputEvent_Proxy::GetInputEventInfo()); |
| 148 | AddPPB(PPB_InputEvent_Proxy::GetKeyboardInputEventInfo()); |
| 149 | AddPPB(PPB_InputEvent_Proxy::GetMouseInputEventInfo()); |
| 150 | AddPPB(PPB_InputEvent_Proxy::GetWheelInputEventInfo()); |
[email protected] | ceadc39 | 2011-06-15 23:04:24 | [diff] [blame] | 151 | AddPPB(PPB_Instance_Proxy::GetInfo0_5()); |
[email protected] | 7d0284e0 | 2011-07-13 03:48:24 | [diff] [blame] | 152 | AddPPB(PPB_Instance_Proxy::GetInfo1_0()); |
[email protected] | ceadc39 | 2011-06-15 23:04:24 | [diff] [blame] | 153 | AddPPB(PPB_Instance_Proxy::GetInfoFullscreen()); |
[email protected] | 7f801d8 | 2011-07-08 23:30:11 | [diff] [blame] | 154 | AddPPB(PPB_Instance_Proxy::GetInfoMessaging()); |
| 155 | AddPPB(PPB_Instance_Proxy::GetInfoPrivate()); |
[email protected] | dc0156ac | 2011-07-06 22:17:14 | [diff] [blame] | 156 | AddPPB(PPB_Memory_Proxy::GetInfo()); |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 157 | AddPPB(PPB_OpenGLES2_Proxy::GetInfo()); |
| 158 | AddPPB(PPB_PDF_Proxy::GetInfo()); |
| 159 | AddPPB(PPB_Surface3D_Proxy::GetInfo()); |
| 160 | AddPPB(PPB_Testing_Proxy::GetInfo()); |
| 161 | AddPPB(PPB_URLLoader_Proxy::GetInfo()); |
[email protected] | bf712f8e | 2011-06-17 02:10:45 | [diff] [blame] | 162 | AddPPB(PPB_URLLoader_Proxy::GetTrustedInfo()); |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 163 | AddPPB(PPB_URLRequestInfo_Proxy::GetInfo()); |
| 164 | AddPPB(PPB_URLResponseInfo_Proxy::GetInfo()); |
[email protected] | 9ca245e | 2011-03-18 01:50:31 | [diff] [blame] | 165 | AddPPB(PPB_URLUtil_Proxy::GetInfo()); |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 166 | AddPPB(PPB_Var_Deprecated_Proxy::GetInfo()); |
[email protected] | 0925622c | 2011-06-08 20:22:02 | [diff] [blame] | 167 | AddPPB(PPB_Var_Proxy::GetInfo()); |
[email protected] | 0fa46e8 | 2011-08-09 07:31:49 | [diff] [blame] | 168 | AddPPB(PPB_VideoCapture_Proxy::GetInfo()); |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 169 | AddPPB(PPB_VideoDecoder_Proxy::GetInfo()); |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 170 | |
[email protected] | 7d3782f | 2011-03-29 19:16:23 | [diff] [blame] | 171 | #ifdef ENABLE_FLAPPER_HACKS |
| 172 | AddPPB(PPB_Flash_NetConnector_Proxy::GetInfo()); |
| 173 | #endif |
| 174 | |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 175 | // PPP (plugin) interfaces. |
[email protected] | 8c3bd1d | 2011-04-12 20:01:42 | [diff] [blame] | 176 | AddPPP(PPP_Graphics3D_Proxy::GetInfo()); |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 177 | AddPPP(PPP_InputEvent_Proxy::GetInfo()); |
[email protected] | 792f1ca3 | 2011-05-25 16:43:43 | [diff] [blame] | 178 | AddPPP(PPP_Instance_Private_Proxy::GetInfo()); |
[email protected] | 13a8f49 | 2011-07-20 19:55:39 | [diff] [blame] | 179 | AddPPP(PPP_Instance_Proxy::GetInfo1_0()); |
[email protected] | b20df1c | 2011-08-03 14:38:24 | [diff] [blame] | 180 | AddPPP(PPP_Messaging_Proxy::GetInfo()); |
[email protected] | 0fa46e8 | 2011-08-09 07:31:49 | [diff] [blame] | 181 | AddPPP(PPP_VideoCapture_Proxy::GetInfo()); |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 182 | AddPPP(PPP_VideoDecoder_Proxy::GetInfo()); |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | void InterfaceList::AddPPP(const InterfaceProxy::Info* info) { |
| 186 | DCHECK(name_to_plugin_info_.find(info->name) == |
| 187 | name_to_plugin_info_.end()); |
[email protected] | ceadc39 | 2011-06-15 23:04:24 | [diff] [blame] | 188 | DCHECK(info->id >= INTERFACE_ID_NONE && info->id < INTERFACE_ID_COUNT); |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 189 | |
| 190 | name_to_plugin_info_[info->name] = info; |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 191 | } |
| 192 | |
| 193 | void InterfaceList::AddPPB(const InterfaceProxy::Info* info) { |
| 194 | DCHECK(name_to_browser_info_.find(info->name) == |
| 195 | name_to_browser_info_.end()); |
[email protected] | ceadc39 | 2011-06-15 23:04:24 | [diff] [blame] | 196 | DCHECK(info->id >= INTERFACE_ID_NONE && info->id < INTERFACE_ID_COUNT); |
| 197 | DCHECK(info->id == INTERFACE_ID_NONE || |
| 198 | id_to_browser_info_[info->id] == NULL); |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 199 | |
| 200 | name_to_browser_info_[std::string(info->name)] = info; |
[email protected] | ceadc39 | 2011-06-15 23:04:24 | [diff] [blame] | 201 | if (info->id != INTERFACE_ID_NONE) |
| 202 | id_to_browser_info_[info->id] = info; |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | // static |
| 206 | InterfaceList* InterfaceList::GetInstance() { |
| 207 | return Singleton<InterfaceList>::get(); |
| 208 | } |
| 209 | |
| 210 | } // namespace |
| 211 | |
[email protected] | 5d84d01 | 2010-12-02 17:17:21 | [diff] [blame] | 212 | Dispatcher::Dispatcher(base::ProcessHandle remote_process_handle, |
| 213 | GetInterfaceFunc local_get_interface) |
[email protected] | e2614c6 | 2011-04-16 22:12:45 | [diff] [blame] | 214 | : ProxyChannel(remote_process_handle), |
[email protected] | 5f251761 | 2010-12-02 22:36:48 | [diff] [blame] | 215 | disallow_trusted_interfaces_(false), // TODO(brettw) make this settable. |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 216 | local_get_interface_(local_get_interface), |
[email protected] | 709a847e | 2010-11-10 01:16:11 | [diff] [blame] | 217 | callback_tracker_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | Dispatcher::~Dispatcher() { |
| 221 | } |
| 222 | |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 223 | bool Dispatcher::OnMessageReceived(const IPC::Message& msg) { |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 224 | // Control messages. |
| 225 | if (msg.routing_id() == MSG_ROUTING_CONTROL) { |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 226 | bool handled = true; |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 227 | IPC_BEGIN_MESSAGE_MAP(Dispatcher, msg) |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 228 | IPC_MESSAGE_FORWARD(PpapiMsg_ExecuteCallback, &callback_tracker_, |
| 229 | CallbackTracker::ReceiveExecuteSerializedCallback) |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 230 | IPC_MESSAGE_UNHANDLED(handled = false) |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 231 | IPC_END_MESSAGE_MAP() |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 232 | return handled; |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 233 | } |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 234 | return false; |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 235 | } |
| 236 | |
[email protected] | 465faa2 | 2011-02-08 16:31:46 | [diff] [blame] | 237 | // static |
| 238 | const InterfaceProxy::Info* Dispatcher::GetPPBInterfaceInfo( |
| 239 | const std::string& name) { |
| 240 | const InterfaceList* list = InterfaceList::GetInstance(); |
| 241 | InterfaceList::NameToInfo::const_iterator found = |
| 242 | list->name_to_browser_info_.find(name); |
| 243 | if (found == list->name_to_browser_info_.end()) |
| 244 | return NULL; |
| 245 | return found->second; |
| 246 | } |
| 247 | |
| 248 | // static |
| 249 | const InterfaceProxy::Info* Dispatcher::GetPPBInterfaceInfo(InterfaceID id) { |
| 250 | if (id <= 0 || id >= INTERFACE_ID_COUNT) |
| 251 | return NULL; |
| 252 | const InterfaceList* list = InterfaceList::GetInstance(); |
| 253 | return list->id_to_browser_info_[id]; |
| 254 | } |
| 255 | |
| 256 | // static |
| 257 | const InterfaceProxy::Info* Dispatcher::GetPPPInterfaceInfo( |
| 258 | const std::string& name) { |
| 259 | const InterfaceList* list = InterfaceList::GetInstance(); |
| 260 | InterfaceList::NameToInfo::const_iterator found = |
| 261 | list->name_to_plugin_info_.find(name); |
| 262 | if (found == list->name_to_plugin_info_.end()) |
| 263 | return NULL; |
| 264 | return found->second; |
| 265 | } |
| 266 | |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 267 | void Dispatcher::SetSerializationRules( |
| 268 | VarSerializationRules* var_serialization_rules) { |
| 269 | serialization_rules_.reset(var_serialization_rules); |
| 270 | } |
| 271 | |
[email protected] | 84396dbc | 2011-04-14 06:33:42 | [diff] [blame] | 272 | const void* Dispatcher::GetLocalInterface(const char* interface_name) { |
| 273 | return local_get_interface_(interface_name); |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 274 | } |
| 275 | |
[email protected] | 92bf906 | 2011-05-02 18:00:49 | [diff] [blame] | 276 | base::MessageLoopProxy* Dispatcher::GetIPCMessageLoop() { |
[email protected] | e2614c6 | 2011-04-16 22:12:45 | [diff] [blame] | 277 | return delegate()->GetIPCMessageLoop(); |
[email protected] | 1609d0d | 2011-04-15 22:06:21 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | void Dispatcher::AddIOThreadMessageFilter( |
| 281 | IPC::ChannelProxy::MessageFilter* filter) { |
[email protected] | e2614c6 | 2011-04-16 22:12:45 | [diff] [blame] | 282 | channel()->AddFilter(filter); |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 283 | } |
| 284 | |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 285 | } // namespace proxy |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame^] | 286 | } // namespace ppapi |