| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_flash_proxy.h" | 5 #include "ppapi/proxy/ppb_flash_proxy.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "ppapi/c/dev/ppb_font_dev.h" | 10 #include "ppapi/c/dev/ppb_font_dev.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 namespace ppapi { | 29 namespace ppapi { |
| 30 namespace proxy { | 30 namespace proxy { |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 void SetInstanceAlwaysOnTop(PP_Instance pp_instance, PP_Bool on_top) { | 34 void SetInstanceAlwaysOnTop(PP_Instance pp_instance, PP_Bool on_top) { |
| 35 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(pp_instance); | 35 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(pp_instance); |
| 36 if (dispatcher) { | 36 if (dispatcher) { |
| 37 dispatcher->Send(new PpapiHostMsg_PPBFlash_SetInstanceAlwaysOnTop( | 37 dispatcher->Send(new PpapiHostMsg_PPBFlash_SetInstanceAlwaysOnTop( |
| 38 INTERFACE_ID_PPB_FLASH, pp_instance, on_top)); | 38 API_ID_PPB_FLASH, pp_instance, on_top)); |
| 39 } | 39 } |
| 40 } | 40 } |
| 41 | 41 |
| 42 PP_Bool DrawGlyphs(PP_Instance instance, | 42 PP_Bool DrawGlyphs(PP_Instance instance, |
| 43 PP_Resource pp_image_data, | 43 PP_Resource pp_image_data, |
| 44 const PP_FontDescription_Dev* font_desc, | 44 const PP_FontDescription_Dev* font_desc, |
| 45 uint32_t color, | 45 uint32_t color, |
| 46 PP_Point position, | 46 PP_Point position, |
| 47 PP_Rect clip, | 47 PP_Rect clip, |
| 48 const float transformation[3][3], | 48 const float transformation[3][3], |
| (...skipping 27 matching lines...) Expand all Loading... |
| 76 | 76 |
| 77 params.glyph_indices.insert(params.glyph_indices.begin(), | 77 params.glyph_indices.insert(params.glyph_indices.begin(), |
| 78 &glyph_indices[0], | 78 &glyph_indices[0], |
| 79 &glyph_indices[glyph_count]); | 79 &glyph_indices[glyph_count]); |
| 80 params.glyph_advances.insert(params.glyph_advances.begin(), | 80 params.glyph_advances.insert(params.glyph_advances.begin(), |
| 81 &glyph_advances[0], | 81 &glyph_advances[0], |
| 82 &glyph_advances[glyph_count]); | 82 &glyph_advances[glyph_count]); |
| 83 | 83 |
| 84 PP_Bool result = PP_FALSE; | 84 PP_Bool result = PP_FALSE; |
| 85 dispatcher->Send(new PpapiHostMsg_PPBFlash_DrawGlyphs( | 85 dispatcher->Send(new PpapiHostMsg_PPBFlash_DrawGlyphs( |
| 86 INTERFACE_ID_PPB_FLASH, params, &result)); | 86 API_ID_PPB_FLASH, params, &result)); |
| 87 return result; | 87 return result; |
| 88 } | 88 } |
| 89 | 89 |
| 90 PP_Var GetProxyForURL(PP_Instance instance, const char* url) { | 90 PP_Var GetProxyForURL(PP_Instance instance, const char* url) { |
| 91 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 91 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
| 92 if (!dispatcher) | 92 if (!dispatcher) |
| 93 return PP_MakeUndefined(); | 93 return PP_MakeUndefined(); |
| 94 | 94 |
| 95 ReceiveSerializedVarReturnValue result; | 95 ReceiveSerializedVarReturnValue result; |
| 96 dispatcher->Send(new PpapiHostMsg_PPBFlash_GetProxyForURL( | 96 dispatcher->Send(new PpapiHostMsg_PPBFlash_GetProxyForURL( |
| 97 INTERFACE_ID_PPB_FLASH, instance, url, &result)); | 97 API_ID_PPB_FLASH, instance, url, &result)); |
| 98 return result.Return(dispatcher); | 98 return result.Return(dispatcher); |
| 99 } | 99 } |
| 100 | 100 |
| 101 int32_t Navigate(PP_Resource request_id, | 101 int32_t Navigate(PP_Resource request_id, |
| 102 const char* target, | 102 const char* target, |
| 103 bool from_user_action) { | 103 bool from_user_action) { |
| 104 thunk::EnterResource<thunk::PPB_URLRequestInfo_API> enter(request_id, true); | 104 thunk::EnterResource<thunk::PPB_URLRequestInfo_API> enter(request_id, true); |
| 105 if (enter.failed()) | 105 if (enter.failed()) |
| 106 return PP_ERROR_BADRESOURCE; | 106 return PP_ERROR_BADRESOURCE; |
| 107 PP_Instance instance = enter.resource()->pp_instance(); | 107 PP_Instance instance = enter.resource()->pp_instance(); |
| 108 | 108 |
| 109 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 109 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
| 110 if (!dispatcher) | 110 if (!dispatcher) |
| 111 return PP_ERROR_FAILED; | 111 return PP_ERROR_FAILED; |
| 112 | 112 |
| 113 int32_t result = PP_ERROR_FAILED; | 113 int32_t result = PP_ERROR_FAILED; |
| 114 dispatcher->Send(new PpapiHostMsg_PPBFlash_Navigate( | 114 dispatcher->Send(new PpapiHostMsg_PPBFlash_Navigate( |
| 115 INTERFACE_ID_PPB_FLASH, | 115 API_ID_PPB_FLASH, |
| 116 instance, enter.object()->GetData(), target, from_user_action, | 116 instance, enter.object()->GetData(), target, from_user_action, |
| 117 &result)); | 117 &result)); |
| 118 return result; | 118 return result; |
| 119 } | 119 } |
| 120 | 120 |
| 121 void RunMessageLoop(PP_Instance instance) { | 121 void RunMessageLoop(PP_Instance instance) { |
| 122 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 122 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
| 123 if (!dispatcher) | 123 if (!dispatcher) |
| 124 return; | 124 return; |
| 125 IPC::SyncMessage* msg = new PpapiHostMsg_PPBFlash_RunMessageLoop( | 125 IPC::SyncMessage* msg = new PpapiHostMsg_PPBFlash_RunMessageLoop( |
| 126 INTERFACE_ID_PPB_FLASH, instance); | 126 API_ID_PPB_FLASH, instance); |
| 127 msg->EnableMessagePumping(); | 127 msg->EnableMessagePumping(); |
| 128 dispatcher->Send(msg); | 128 dispatcher->Send(msg); |
| 129 } | 129 } |
| 130 | 130 |
| 131 void QuitMessageLoop(PP_Instance instance) { | 131 void QuitMessageLoop(PP_Instance instance) { |
| 132 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 132 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
| 133 if (!dispatcher) | 133 if (!dispatcher) |
| 134 return; | 134 return; |
| 135 dispatcher->Send(new PpapiHostMsg_PPBFlash_QuitMessageLoop( | 135 dispatcher->Send(new PpapiHostMsg_PPBFlash_QuitMessageLoop( |
| 136 INTERFACE_ID_PPB_FLASH, instance)); | 136 API_ID_PPB_FLASH, instance)); |
| 137 } | 137 } |
| 138 | 138 |
| 139 double GetLocalTimeZoneOffset(PP_Instance instance, PP_Time t) { | 139 double GetLocalTimeZoneOffset(PP_Instance instance, PP_Time t) { |
| 140 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 140 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
| 141 if (!dispatcher) | 141 if (!dispatcher) |
| 142 return 0.0; | 142 return 0.0; |
| 143 | 143 |
| 144 // TODO(brettw) on Windows it should be possible to do the time calculation | 144 // TODO(brettw) on Windows it should be possible to do the time calculation |
| 145 // in-process since it doesn't need to read files on disk. This will improve | 145 // in-process since it doesn't need to read files on disk. This will improve |
| 146 // performance. | 146 // performance. |
| 147 // | 147 // |
| 148 // On Linux, it would be better to go directly to the browser process for | 148 // On Linux, it would be better to go directly to the browser process for |
| 149 // this message rather than proxy it through some instance in a renderer. | 149 // this message rather than proxy it through some instance in a renderer. |
| 150 double result = 0; | 150 double result = 0; |
| 151 dispatcher->Send(new PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset( | 151 dispatcher->Send(new PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset( |
| 152 INTERFACE_ID_PPB_FLASH, instance, t, &result)); | 152 API_ID_PPB_FLASH, instance, t, &result)); |
| 153 return result; | 153 return result; |
| 154 } | 154 } |
| 155 | 155 |
| 156 PP_Var GetCommandLineArgs(PP_Module pp_module) { | 156 PP_Var GetCommandLineArgs(PP_Module pp_module) { |
| 157 std::string args = ProxyModule::GetInstance()->GetFlashCommandLineArgs(); | 157 std::string args = ProxyModule::GetInstance()->GetFlashCommandLineArgs(); |
| 158 return StringVar::StringToPPVar(pp_module, args); | 158 return StringVar::StringToPPVar(pp_module, args); |
| 159 } | 159 } |
| 160 | 160 |
| 161 const PPB_Flash flash_interface = { | 161 const PPB_Flash flash_interface = { |
| 162 &SetInstanceAlwaysOnTop, | 162 &SetInstanceAlwaysOnTop, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 184 } | 184 } |
| 185 | 185 |
| 186 PPB_Flash_Proxy::~PPB_Flash_Proxy() { | 186 PPB_Flash_Proxy::~PPB_Flash_Proxy() { |
| 187 } | 187 } |
| 188 | 188 |
| 189 // static | 189 // static |
| 190 const InterfaceProxy::Info* PPB_Flash_Proxy::GetInfo() { | 190 const InterfaceProxy::Info* PPB_Flash_Proxy::GetInfo() { |
| 191 static const Info info = { | 191 static const Info info = { |
| 192 &flash_interface, | 192 &flash_interface, |
| 193 PPB_FLASH_INTERFACE, | 193 PPB_FLASH_INTERFACE, |
| 194 INTERFACE_ID_PPB_FLASH, | 194 API_ID_PPB_FLASH, |
| 195 true, | 195 true, |
| 196 &CreateFlashProxy, | 196 &CreateFlashProxy, |
| 197 }; | 197 }; |
| 198 return &info; | 198 return &info; |
| 199 } | 199 } |
| 200 | 200 |
| 201 bool PPB_Flash_Proxy::OnMessageReceived(const IPC::Message& msg) { | 201 bool PPB_Flash_Proxy::OnMessageReceived(const IPC::Message& msg) { |
| 202 // Prevent the dispatcher from going away during a call to Navigate. | 202 // Prevent the dispatcher from going away during a call to Navigate. |
| 203 // This must happen OUTSIDE of OnMsgNavigate since the handling code use | 203 // This must happen OUTSIDE of OnMsgNavigate since the handling code use |
| 204 // the dispatcher upon return of the function (sending the reply message). | 204 // the dispatcher upon return of the function (sending the reply message). |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 } | 306 } |
| 307 | 307 |
| 308 void PPB_Flash_Proxy::OnMsgGetLocalTimeZoneOffset(PP_Instance instance, | 308 void PPB_Flash_Proxy::OnMsgGetLocalTimeZoneOffset(PP_Instance instance, |
| 309 PP_Time t, | 309 PP_Time t, |
| 310 double* result) { | 310 double* result) { |
| 311 *result = ppb_flash_impl_->GetLocalTimeZoneOffset(instance, t); | 311 *result = ppb_flash_impl_->GetLocalTimeZoneOffset(instance, t); |
| 312 } | 312 } |
| 313 | 313 |
| 314 } // namespace proxy | 314 } // namespace proxy |
| 315 } // namespace ppapi | 315 } // namespace ppapi |
| OLD | NEW |