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_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" |
11 #include "ppapi/c/dev/ppb_var_deprecated.h" | 11 #include "ppapi/c/dev/ppb_var_deprecated.h" |
12 #include "ppapi/c/pp_errors.h" | 12 #include "ppapi/c/pp_errors.h" |
13 #include "ppapi/c/pp_resource.h" | 13 #include "ppapi/c/pp_resource.h" |
14 #include "ppapi/c/private/ppb_flash.h" | 14 #include "ppapi/c/private/ppb_flash.h" |
15 #include "ppapi/proxy/host_dispatcher.h" | 15 #include "ppapi/proxy/host_dispatcher.h" |
16 #include "ppapi/proxy/plugin_dispatcher.h" | 16 #include "ppapi/proxy/plugin_dispatcher.h" |
17 #include "ppapi/proxy/plugin_globals.h" | 17 #include "ppapi/proxy/plugin_globals.h" |
18 #include "ppapi/proxy/plugin_proxy_delegate.h" | 18 #include "ppapi/proxy/plugin_proxy_delegate.h" |
19 #include "ppapi/proxy/ppapi_messages.h" | 19 #include "ppapi/proxy/ppapi_messages.h" |
20 #include "ppapi/proxy/proxy_module.h" | 20 #include "ppapi/proxy/proxy_module.h" |
21 #include "ppapi/proxy/serialized_var.h" | 21 #include "ppapi/proxy/serialized_var.h" |
22 #include "ppapi/shared_impl/ppapi_globals.h" | 22 #include "ppapi/shared_impl/ppapi_globals.h" |
23 #include "ppapi/shared_impl/proxy_lock.h" | 23 #include "ppapi/shared_impl/proxy_lock.h" |
24 #include "ppapi/shared_impl/resource.h" | 24 #include "ppapi/shared_impl/resource.h" |
25 #include "ppapi/shared_impl/resource_tracker.h" | 25 #include "ppapi/shared_impl/resource_tracker.h" |
26 #include "ppapi/shared_impl/scoped_pp_resource.h" | 26 #include "ppapi/shared_impl/scoped_pp_resource.h" |
27 #include "ppapi/shared_impl/var.h" | 27 #include "ppapi/shared_impl/var.h" |
28 #include "ppapi/thunk/enter.h" | 28 #include "ppapi/thunk/enter.h" |
| 29 #include "ppapi/thunk/ppb_instance_api.h" |
29 #include "ppapi/thunk/ppb_url_request_info_api.h" | 30 #include "ppapi/thunk/ppb_url_request_info_api.h" |
30 #include "ppapi/thunk/resource_creation_api.h" | 31 #include "ppapi/thunk/resource_creation_api.h" |
31 | 32 |
32 namespace ppapi { | 33 namespace ppapi { |
33 namespace proxy { | 34 namespace proxy { |
34 | 35 |
35 namespace { | 36 PPB_Flash_Proxy::PPB_Flash_Proxy(Dispatcher* dispatcher) |
36 | 37 : InterfaceProxy(dispatcher), |
37 void SetInstanceAlwaysOnTop(PP_Instance pp_instance, PP_Bool on_top) { | 38 ppb_flash_impl_(NULL) { |
38 ProxyAutoLock lock; | 39 if (!dispatcher->IsPlugin()) |
39 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(pp_instance); | 40 ppb_flash_impl_ = static_cast<const PPB_Flash*>( |
40 if (dispatcher) { | 41 dispatcher->local_get_interface()(PPB_FLASH_INTERFACE)); |
41 dispatcher->Send(new PpapiHostMsg_PPBFlash_SetInstanceAlwaysOnTop( | |
42 API_ID_PPB_FLASH, pp_instance, on_top)); | |
43 } | |
44 } | 42 } |
45 | 43 |
46 PP_Bool DrawGlyphs(PP_Instance instance, | 44 PPB_Flash_Proxy::~PPB_Flash_Proxy() { |
47 PP_Resource pp_image_data, | 45 } |
48 const PP_FontDescription_Dev* font_desc, | 46 |
49 uint32_t color, | 47 bool PPB_Flash_Proxy::OnMessageReceived(const IPC::Message& msg) { |
50 const PP_Point* position, | 48 // Prevent the dispatcher from going away during a call to Navigate. |
51 const PP_Rect* clip, | 49 // This must happen OUTSIDE of OnMsgNavigate since the handling code use |
52 const float transformation[3][3], | 50 // the dispatcher upon return of the function (sending the reply message). |
53 PP_Bool allow_subpixel_aa, | 51 ScopedModuleReference death_grip(dispatcher()); |
54 uint32_t glyph_count, | 52 |
55 const uint16_t glyph_indices[], | 53 bool handled = true; |
56 const PP_Point glyph_advances[]) { | 54 IPC_BEGIN_MESSAGE_MAP(PPB_Flash_Proxy, msg) |
57 ProxyAutoLock lock; | 55 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_SetInstanceAlwaysOnTop, |
| 56 OnHostMsgSetInstanceAlwaysOnTop) |
| 57 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_DrawGlyphs, |
| 58 OnHostMsgDrawGlyphs) |
| 59 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetProxyForURL, |
| 60 OnHostMsgGetProxyForURL) |
| 61 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_Navigate, OnHostMsgNavigate) |
| 62 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_RunMessageLoop, |
| 63 OnHostMsgRunMessageLoop) |
| 64 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_QuitMessageLoop, |
| 65 OnHostMsgQuitMessageLoop) |
| 66 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset, |
| 67 OnHostMsgGetLocalTimeZoneOffset) |
| 68 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_IsRectTopmost, |
| 69 OnHostMsgIsRectTopmost) |
| 70 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_FlashSetFullscreen, |
| 71 OnHostMsgFlashSetFullscreen) |
| 72 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_FlashGetScreenSize, |
| 73 OnHostMsgFlashGetScreenSize) |
| 74 IPC_MESSAGE_UNHANDLED(handled = false) |
| 75 IPC_END_MESSAGE_MAP() |
| 76 // TODO(brettw) handle bad messages! |
| 77 return handled; |
| 78 } |
| 79 |
| 80 void PPB_Flash_Proxy::SetInstanceAlwaysOnTop(PP_Instance instance, |
| 81 PP_Bool on_top) { |
| 82 dispatcher()->Send(new PpapiHostMsg_PPBFlash_SetInstanceAlwaysOnTop( |
| 83 API_ID_PPB_FLASH, instance, on_top)); |
| 84 } |
| 85 |
| 86 PP_Bool PPB_Flash_Proxy::DrawGlyphs(PP_Instance instance, |
| 87 PP_Resource pp_image_data, |
| 88 const PP_FontDescription_Dev* font_desc, |
| 89 uint32_t color, |
| 90 const PP_Point* position, |
| 91 const PP_Rect* clip, |
| 92 const float transformation[3][3], |
| 93 PP_Bool allow_subpixel_aa, |
| 94 uint32_t glyph_count, |
| 95 const uint16_t glyph_indices[], |
| 96 const PP_Point glyph_advances[]) { |
58 Resource* image_data = | 97 Resource* image_data = |
59 PpapiGlobals::Get()->GetResourceTracker()->GetResource(pp_image_data); | 98 PpapiGlobals::Get()->GetResourceTracker()->GetResource(pp_image_data); |
60 if (!image_data) | 99 if (!image_data) |
61 return PP_FALSE; | 100 return PP_FALSE; |
62 // The instance parameter isn't strictly necessary but we check that it | 101 // The instance parameter isn't strictly necessary but we check that it |
63 // matches anyway. | 102 // matches anyway. |
64 if (image_data->pp_instance() != instance) | 103 if (image_data->pp_instance() != instance) |
65 return PP_FALSE; | 104 return PP_FALSE; |
66 | 105 |
67 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance( | |
68 image_data->pp_instance()); | |
69 if (!dispatcher) | |
70 return PP_FALSE; | |
71 | |
72 PPBFlash_DrawGlyphs_Params params; | 106 PPBFlash_DrawGlyphs_Params params; |
73 params.image_data = image_data->host_resource(); | 107 params.image_data = image_data->host_resource(); |
74 params.font_desc.SetFromPPFontDescription(dispatcher, *font_desc, true); | 108 params.font_desc.SetFromPPFontDescription(dispatcher(), *font_desc, true); |
75 params.color = color; | 109 params.color = color; |
76 params.position = *position; | 110 params.position = *position; |
77 params.clip = *clip; | 111 params.clip = *clip; |
78 for (int i = 0; i < 3; i++) { | 112 for (int i = 0; i < 3; i++) { |
79 for (int j = 0; j < 3; j++) | 113 for (int j = 0; j < 3; j++) |
80 params.transformation[i][j] = transformation[i][j]; | 114 params.transformation[i][j] = transformation[i][j]; |
81 } | 115 } |
82 params.allow_subpixel_aa = allow_subpixel_aa; | 116 params.allow_subpixel_aa = allow_subpixel_aa; |
83 | 117 |
84 params.glyph_indices.insert(params.glyph_indices.begin(), | 118 params.glyph_indices.insert(params.glyph_indices.begin(), |
85 &glyph_indices[0], | 119 &glyph_indices[0], |
86 &glyph_indices[glyph_count]); | 120 &glyph_indices[glyph_count]); |
87 params.glyph_advances.insert(params.glyph_advances.begin(), | 121 params.glyph_advances.insert(params.glyph_advances.begin(), |
88 &glyph_advances[0], | 122 &glyph_advances[0], |
89 &glyph_advances[glyph_count]); | 123 &glyph_advances[glyph_count]); |
90 | 124 |
91 PP_Bool result = PP_FALSE; | 125 PP_Bool result = PP_FALSE; |
92 dispatcher->Send(new PpapiHostMsg_PPBFlash_DrawGlyphs( | 126 dispatcher()->Send(new PpapiHostMsg_PPBFlash_DrawGlyphs( |
93 API_ID_PPB_FLASH, params, &result)); | 127 API_ID_PPB_FLASH, params, &result)); |
94 return result; | 128 return result; |
95 } | 129 } |
96 | 130 |
97 PP_Bool DrawGlyphs11(PP_Instance instance, | 131 PP_Var PPB_Flash_Proxy::GetProxyForURL(PP_Instance instance, const char* url) { |
98 PP_Resource pp_image_data, | 132 ReceiveSerializedVarReturnValue result; |
99 const PP_FontDescription_Dev* font_desc, | 133 dispatcher()->Send(new PpapiHostMsg_PPBFlash_GetProxyForURL( |
100 uint32_t color, | 134 API_ID_PPB_FLASH, instance, url, &result)); |
101 PP_Point position, | 135 return result.Return(dispatcher()); |
102 PP_Rect clip, | |
103 const float transformation[3][3], | |
104 uint32_t glyph_count, | |
105 const uint16_t glyph_indices[], | |
106 const PP_Point glyph_advances[]) { | |
107 // Backwards-compatible version. DrawGlyphs locks; no need to lock here. | |
108 return DrawGlyphs(instance, pp_image_data, font_desc, color, &position, | |
109 &clip, transformation, PP_TRUE, glyph_count, glyph_indices, | |
110 glyph_advances); | |
111 } | 136 } |
112 | 137 |
113 PP_Var GetProxyForURL(PP_Instance instance, const char* url) { | 138 int32_t PPB_Flash_Proxy::Navigate(PP_Instance instance, |
114 ProxyAutoLock lock; | 139 PP_Resource request_info, |
115 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 140 const char* target, |
116 if (!dispatcher) | 141 PP_Bool from_user_action) { |
117 return PP_MakeUndefined(); | 142 thunk::EnterResourceNoLock<thunk::PPB_URLRequestInfo_API> enter( |
118 | 143 request_info, true); |
119 ReceiveSerializedVarReturnValue result; | |
120 dispatcher->Send(new PpapiHostMsg_PPBFlash_GetProxyForURL( | |
121 API_ID_PPB_FLASH, instance, url, &result)); | |
122 return result.Return(dispatcher); | |
123 } | |
124 | |
125 int32_t Navigate(PP_Resource request_id, | |
126 const char* target, | |
127 PP_Bool from_user_action) { | |
128 thunk::EnterResource<thunk::PPB_URLRequestInfo_API> enter(request_id, true); | |
129 if (enter.failed()) | 144 if (enter.failed()) |
130 return PP_ERROR_BADRESOURCE; | 145 return PP_ERROR_BADRESOURCE; |
131 PP_Instance instance = enter.resource()->pp_instance(); | |
132 | |
133 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | |
134 if (!dispatcher) | |
135 return PP_ERROR_FAILED; | |
136 | 146 |
137 int32_t result = PP_ERROR_FAILED; | 147 int32_t result = PP_ERROR_FAILED; |
138 dispatcher->Send(new PpapiHostMsg_PPBFlash_Navigate( | 148 dispatcher()->Send(new PpapiHostMsg_PPBFlash_Navigate( |
139 API_ID_PPB_FLASH, | 149 API_ID_PPB_FLASH, |
140 instance, enter.object()->GetData(), target, from_user_action, | 150 instance, enter.object()->GetData(), target, from_user_action, |
141 &result)); | 151 &result)); |
142 return result; | 152 return result; |
143 } | 153 } |
144 | 154 |
145 int32_t Navigate11(PP_Resource request_id, | 155 void PPB_Flash_Proxy::RunMessageLoop(PP_Instance instance) { |
146 const char* target, | |
147 bool from_user_action) { | |
148 // Backwards-compatible version. Navigate locks; no need to lock here. | |
149 return Navigate(request_id, target, PP_FromBool(from_user_action)); | |
150 } | |
151 | |
152 void RunMessageLoop(PP_Instance instance) { | |
153 ProxyAutoLock lock; | |
154 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | |
155 if (!dispatcher) | |
156 return; | |
157 IPC::SyncMessage* msg = new PpapiHostMsg_PPBFlash_RunMessageLoop( | 156 IPC::SyncMessage* msg = new PpapiHostMsg_PPBFlash_RunMessageLoop( |
158 API_ID_PPB_FLASH, instance); | 157 API_ID_PPB_FLASH, instance); |
159 msg->EnableMessagePumping(); | 158 msg->EnableMessagePumping(); |
160 dispatcher->Send(msg); | 159 dispatcher()->Send(msg); |
161 } | 160 } |
162 | 161 |
163 void QuitMessageLoop(PP_Instance instance) { | 162 void PPB_Flash_Proxy::QuitMessageLoop(PP_Instance instance) { |
164 ProxyAutoLock lock; | 163 dispatcher()->Send(new PpapiHostMsg_PPBFlash_QuitMessageLoop( |
165 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | |
166 if (!dispatcher) | |
167 return; | |
168 dispatcher->Send(new PpapiHostMsg_PPBFlash_QuitMessageLoop( | |
169 API_ID_PPB_FLASH, instance)); | 164 API_ID_PPB_FLASH, instance)); |
170 } | 165 } |
171 | 166 |
172 double GetLocalTimeZoneOffset(PP_Instance instance, PP_Time t) { | 167 double PPB_Flash_Proxy::GetLocalTimeZoneOffset(PP_Instance instance, |
173 ProxyAutoLock lock; | 168 PP_Time t) { |
174 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | |
175 if (!dispatcher) | |
176 return 0.0; | |
177 | |
178 // TODO(brettw) on Windows it should be possible to do the time calculation | 169 // TODO(brettw) on Windows it should be possible to do the time calculation |
179 // in-process since it doesn't need to read files on disk. This will improve | 170 // in-process since it doesn't need to read files on disk. This will improve |
180 // performance. | 171 // performance. |
181 // | 172 // |
182 // On Linux, it would be better to go directly to the browser process for | 173 // On Linux, it would be better to go directly to the browser process for |
183 // this message rather than proxy it through some instance in a renderer. | 174 // this message rather than proxy it through some instance in a renderer. |
184 double result = 0; | 175 double result = 0; |
185 dispatcher->Send(new PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset( | 176 dispatcher()->Send(new PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset( |
186 API_ID_PPB_FLASH, instance, t, &result)); | 177 API_ID_PPB_FLASH, instance, t, &result)); |
187 return result; | 178 return result; |
188 } | 179 } |
189 | 180 |
190 PP_Var GetCommandLineArgs(PP_Module /*pp_module*/) { | 181 PP_Bool PPB_Flash_Proxy::IsRectTopmost(PP_Instance instance, |
191 ProxyAutoLock lock; | 182 const PP_Rect* rect) { |
192 std::string args = ProxyModule::GetInstance()->GetFlashCommandLineArgs(); | |
193 return StringVar::StringToPPVar(args); | |
194 } | |
195 | |
196 void PreLoadFontWin(const void* logfontw) { | |
197 ProxyAutoLock lock; | |
198 PluginGlobals::Get()->plugin_proxy_delegate()->PreCacheFont(logfontw); | |
199 } | |
200 | |
201 PP_Bool IsRectTopmost(PP_Instance instance, const PP_Rect* rect) { | |
202 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | |
203 if (!dispatcher) | |
204 return PP_FALSE; | |
205 PP_Bool result = PP_FALSE; | 183 PP_Bool result = PP_FALSE; |
206 dispatcher->Send(new PpapiHostMsg_PPBFlash_IsRectTopmost( | 184 dispatcher()->Send(new PpapiHostMsg_PPBFlash_IsRectTopmost( |
207 API_ID_PPB_FLASH, instance, *rect, &result)); | 185 API_ID_PPB_FLASH, instance, *rect, &result)); |
208 return result; | 186 return result; |
209 } | 187 } |
210 | 188 |
211 int32_t InvokePrinting(PP_Instance instance) { | 189 int32_t PPB_Flash_Proxy::InvokePrinting(PP_Instance instance) { |
212 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | |
213 if (!dispatcher) | |
214 return PP_ERROR_BADARGUMENT; | |
215 | |
216 // TODO(viettrungluu): Implement me. | |
217 | |
218 return PP_ERROR_NOTSUPPORTED; | 190 return PP_ERROR_NOTSUPPORTED; |
219 } | 191 } |
220 | 192 |
221 void UpdateActivity(PP_Instance instance) { | 193 void PPB_Flash_Proxy::UpdateActivity(PP_Instance instance) { |
222 PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( | 194 PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( |
223 new PpapiHostMsg_PPBFlash_UpdateActivity(API_ID_PPB_FLASH)); | 195 new PpapiHostMsg_PPBFlash_UpdateActivity(API_ID_PPB_FLASH)); |
224 } | 196 } |
225 | 197 |
226 PP_Var GetDeviceID(PP_Instance instance) { | 198 PP_Var PPB_Flash_Proxy::GetDeviceID(PP_Instance instance) { |
227 std::string id; | 199 std::string id; |
228 PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( | 200 PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( |
229 new PpapiHostMsg_PPBFlash_GetDeviceID(API_ID_PPB_FLASH, &id)); | 201 new PpapiHostMsg_PPBFlash_GetDeviceID(API_ID_PPB_FLASH, &id)); |
230 return StringVar::StringToPPVar(id); | 202 return StringVar::StringToPPVar(id); |
231 } | 203 } |
232 | 204 |
233 const PPB_Flash_11 flash_interface_11 = { | 205 PP_Bool PPB_Flash_Proxy::FlashIsFullscreen(PP_Instance instance) { |
234 &SetInstanceAlwaysOnTop, | 206 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> |
235 &DrawGlyphs11, | 207 GetInstanceData(instance); |
236 &GetProxyForURL, | 208 if (!data) |
237 &Navigate11, | 209 return PP_FALSE; |
238 &RunMessageLoop, | 210 return data->flash_fullscreen; |
239 &QuitMessageLoop, | |
240 &GetLocalTimeZoneOffset, | |
241 &GetCommandLineArgs | |
242 }; | |
243 | |
244 const PPB_Flash_12_0 flash_interface_12_0 = { | |
245 &SetInstanceAlwaysOnTop, | |
246 &DrawGlyphs, | |
247 &GetProxyForURL, | |
248 &Navigate, | |
249 &RunMessageLoop, | |
250 &QuitMessageLoop, | |
251 &GetLocalTimeZoneOffset, | |
252 &GetCommandLineArgs, | |
253 &PreLoadFontWin | |
254 }; | |
255 | |
256 const PPB_Flash_12_1 flash_interface_12_1 = { | |
257 &SetInstanceAlwaysOnTop, | |
258 &DrawGlyphs, | |
259 &GetProxyForURL, | |
260 &Navigate, | |
261 &RunMessageLoop, | |
262 &QuitMessageLoop, | |
263 &GetLocalTimeZoneOffset, | |
264 &GetCommandLineArgs, | |
265 &PreLoadFontWin, | |
266 &IsRectTopmost, | |
267 &InvokePrinting, | |
268 &UpdateActivity | |
269 }; | |
270 | |
271 const PPB_Flash_12_2 flash_interface_12_2 = { | |
272 &SetInstanceAlwaysOnTop, | |
273 &DrawGlyphs, | |
274 &GetProxyForURL, | |
275 &Navigate, | |
276 &RunMessageLoop, | |
277 &QuitMessageLoop, | |
278 &GetLocalTimeZoneOffset, | |
279 &GetCommandLineArgs, | |
280 &PreLoadFontWin, | |
281 &IsRectTopmost, | |
282 &InvokePrinting, | |
283 &UpdateActivity, | |
284 &GetDeviceID | |
285 }; | |
286 | |
287 } // namespace | |
288 | |
289 PPB_Flash_Proxy::PPB_Flash_Proxy(Dispatcher* dispatcher) | |
290 : InterfaceProxy(dispatcher), | |
291 ppb_flash_impl_(NULL) { | |
292 if (!dispatcher->IsPlugin()) | |
293 ppb_flash_impl_ = static_cast<const PPB_Flash*>( | |
294 dispatcher->local_get_interface()(PPB_FLASH_INTERFACE)); | |
295 } | 211 } |
296 | 212 |
297 PPB_Flash_Proxy::~PPB_Flash_Proxy() { | 213 PP_Bool PPB_Flash_Proxy::FlashSetFullscreen(PP_Instance instance, |
| 214 PP_Bool fullscreen) { |
| 215 PP_Bool result = PP_FALSE; |
| 216 dispatcher()->Send(new PpapiHostMsg_PPBFlash_FlashSetFullscreen( |
| 217 API_ID_PPB_FLASH, instance, fullscreen, &result)); |
| 218 return result; |
298 } | 219 } |
299 | 220 |
300 // static | 221 PP_Bool PPB_Flash_Proxy::FlashGetScreenSize(PP_Instance instance, |
301 const PPB_Flash_11* PPB_Flash_Proxy::GetInterface11() { | 222 PP_Size* size) { |
302 return &flash_interface_11; | 223 PP_Bool result = PP_FALSE; |
| 224 dispatcher()->Send(new PpapiHostMsg_PPBFlash_FlashGetScreenSize( |
| 225 API_ID_PPB_FLASH, instance, &result, size)); |
| 226 return result; |
303 } | 227 } |
304 | 228 |
305 // static | 229 void PPB_Flash_Proxy::OnHostMsgSetInstanceAlwaysOnTop(PP_Instance instance, |
306 const PPB_Flash_12_0* PPB_Flash_Proxy::GetInterface12_0() { | 230 PP_Bool on_top) { |
307 return &flash_interface_12_0; | |
308 } | |
309 | |
310 // static | |
311 const PPB_Flash_12_1* PPB_Flash_Proxy::GetInterface12_1() { | |
312 return &flash_interface_12_1; | |
313 } | |
314 | |
315 // static | |
316 const PPB_Flash_12_2* PPB_Flash_Proxy::GetInterface12_2() { | |
317 return &flash_interface_12_2; | |
318 } | |
319 | |
320 bool PPB_Flash_Proxy::OnMessageReceived(const IPC::Message& msg) { | |
321 // Prevent the dispatcher from going away during a call to Navigate. | |
322 // This must happen OUTSIDE of OnMsgNavigate since the handling code use | |
323 // the dispatcher upon return of the function (sending the reply message). | |
324 ScopedModuleReference death_grip(dispatcher()); | |
325 | |
326 bool handled = true; | |
327 IPC_BEGIN_MESSAGE_MAP(PPB_Flash_Proxy, msg) | |
328 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_SetInstanceAlwaysOnTop, | |
329 OnMsgSetInstanceAlwaysOnTop) | |
330 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_DrawGlyphs, | |
331 OnMsgDrawGlyphs) | |
332 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetProxyForURL, | |
333 OnMsgGetProxyForURL) | |
334 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_Navigate, OnMsgNavigate) | |
335 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_RunMessageLoop, | |
336 OnMsgRunMessageLoop) | |
337 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_QuitMessageLoop, | |
338 OnMsgQuitMessageLoop) | |
339 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset, | |
340 OnMsgGetLocalTimeZoneOffset) | |
341 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_IsRectTopmost, | |
342 OnMsgIsRectTopmost) | |
343 IPC_MESSAGE_UNHANDLED(handled = false) | |
344 IPC_END_MESSAGE_MAP() | |
345 // TODO(brettw) handle bad messages! | |
346 return handled; | |
347 } | |
348 | |
349 void PPB_Flash_Proxy::OnMsgSetInstanceAlwaysOnTop( | |
350 PP_Instance instance, | |
351 PP_Bool on_top) { | |
352 ppb_flash_impl_->SetInstanceAlwaysOnTop(instance, on_top); | 231 ppb_flash_impl_->SetInstanceAlwaysOnTop(instance, on_top); |
353 } | 232 } |
354 | 233 |
355 void PPB_Flash_Proxy::OnMsgDrawGlyphs(const PPBFlash_DrawGlyphs_Params& params, | 234 void PPB_Flash_Proxy::OnHostMsgDrawGlyphs( |
356 PP_Bool* result) { | 235 const PPBFlash_DrawGlyphs_Params& params, |
| 236 PP_Bool* result) { |
357 *result = PP_FALSE; | 237 *result = PP_FALSE; |
358 | 238 |
359 PP_FontDescription_Dev font_desc; | 239 PP_FontDescription_Dev font_desc; |
360 params.font_desc.SetToPPFontDescription(dispatcher(), &font_desc, false); | 240 params.font_desc.SetToPPFontDescription(dispatcher(), &font_desc, false); |
361 | 241 |
362 if (params.glyph_indices.size() != params.glyph_advances.size() || | 242 if (params.glyph_indices.size() != params.glyph_advances.size() || |
363 params.glyph_indices.empty()) | 243 params.glyph_indices.empty()) |
364 return; | 244 return; |
365 | 245 |
366 *result = ppb_flash_impl_->DrawGlyphs( | 246 *result = ppb_flash_impl_->DrawGlyphs( |
367 0, // Unused instance param. | 247 0, // Unused instance param. |
368 params.image_data.host_resource(), &font_desc, | 248 params.image_data.host_resource(), &font_desc, |
369 params.color, ¶ms.position, ¶ms.clip, | 249 params.color, ¶ms.position, ¶ms.clip, |
370 const_cast<float(*)[3]>(params.transformation), | 250 const_cast<float(*)[3]>(params.transformation), |
371 params.allow_subpixel_aa, | 251 params.allow_subpixel_aa, |
372 static_cast<uint32_t>(params.glyph_indices.size()), | 252 static_cast<uint32_t>(params.glyph_indices.size()), |
373 const_cast<uint16_t*>(¶ms.glyph_indices[0]), | 253 const_cast<uint16_t*>(¶ms.glyph_indices[0]), |
374 const_cast<PP_Point*>(¶ms.glyph_advances[0])); | 254 const_cast<PP_Point*>(¶ms.glyph_advances[0])); |
375 } | 255 } |
376 | 256 |
377 void PPB_Flash_Proxy::OnMsgGetProxyForURL(PP_Instance instance, | 257 void PPB_Flash_Proxy::OnHostMsgGetProxyForURL(PP_Instance instance, |
378 const std::string& url, | 258 const std::string& url, |
379 SerializedVarReturnValue result) { | 259 SerializedVarReturnValue result) { |
380 result.Return(dispatcher(), ppb_flash_impl_->GetProxyForURL( | 260 result.Return(dispatcher(), ppb_flash_impl_->GetProxyForURL( |
381 instance, url.c_str())); | 261 instance, url.c_str())); |
382 } | 262 } |
383 | 263 |
384 void PPB_Flash_Proxy::OnMsgNavigate(PP_Instance instance, | 264 void PPB_Flash_Proxy::OnHostMsgNavigate(PP_Instance instance, |
385 const PPB_URLRequestInfo_Data& data, | 265 const PPB_URLRequestInfo_Data& data, |
386 const std::string& target, | 266 const std::string& target, |
387 PP_Bool from_user_action, | 267 PP_Bool from_user_action, |
388 int32_t* result) { | 268 int32_t* result) { |
389 DCHECK(!dispatcher()->IsPlugin()); | 269 DCHECK(!dispatcher()->IsPlugin()); |
390 | 270 |
391 // Validate the PP_Instance since we'll be constructing resources on its | 271 // Validate the PP_Instance since we'll be constructing resources on its |
392 // behalf. | 272 // behalf. |
393 HostDispatcher* host_dispatcher = static_cast<HostDispatcher*>(dispatcher()); | 273 HostDispatcher* host_dispatcher = static_cast<HostDispatcher*>(dispatcher()); |
394 if (HostDispatcher::GetForInstance(instance) != host_dispatcher) { | 274 if (HostDispatcher::GetForInstance(instance) != host_dispatcher) { |
395 NOTREACHED(); | 275 NOTREACHED(); |
396 *result = PP_ERROR_BADARGUMENT; | 276 *result = PP_ERROR_BADARGUMENT; |
397 return; | 277 return; |
398 } | 278 } |
(...skipping 13 matching lines...) Expand all Loading... |
412 } | 292 } |
413 ScopedPPResource request_resource( | 293 ScopedPPResource request_resource( |
414 ScopedPPResource::PassRef(), | 294 ScopedPPResource::PassRef(), |
415 enter.functions()->CreateURLRequestInfo(instance, data)); | 295 enter.functions()->CreateURLRequestInfo(instance, data)); |
416 | 296 |
417 *result = ppb_flash_impl_->Navigate(request_resource, | 297 *result = ppb_flash_impl_->Navigate(request_resource, |
418 target.c_str(), | 298 target.c_str(), |
419 from_user_action); | 299 from_user_action); |
420 } | 300 } |
421 | 301 |
422 void PPB_Flash_Proxy::OnMsgRunMessageLoop(PP_Instance instance) { | 302 void PPB_Flash_Proxy::OnHostMsgRunMessageLoop(PP_Instance instance) { |
423 ppb_flash_impl_->RunMessageLoop(instance); | 303 ppb_flash_impl_->RunMessageLoop(instance); |
424 } | 304 } |
425 | 305 |
426 void PPB_Flash_Proxy::OnMsgQuitMessageLoop(PP_Instance instance) { | 306 void PPB_Flash_Proxy::OnHostMsgQuitMessageLoop(PP_Instance instance) { |
427 ppb_flash_impl_->QuitMessageLoop(instance); | 307 ppb_flash_impl_->QuitMessageLoop(instance); |
428 } | 308 } |
429 | 309 |
430 void PPB_Flash_Proxy::OnMsgGetLocalTimeZoneOffset(PP_Instance instance, | 310 void PPB_Flash_Proxy::OnHostMsgGetLocalTimeZoneOffset(PP_Instance instance, |
431 PP_Time t, | 311 PP_Time t, |
432 double* result) { | 312 double* result) { |
433 *result = ppb_flash_impl_->GetLocalTimeZoneOffset(instance, t); | 313 *result = ppb_flash_impl_->GetLocalTimeZoneOffset(instance, t); |
434 } | 314 } |
435 | 315 |
436 void PPB_Flash_Proxy::OnMsgIsRectTopmost(PP_Instance instance, | 316 void PPB_Flash_Proxy::OnHostMsgIsRectTopmost(PP_Instance instance, |
437 PP_Rect rect, | 317 PP_Rect rect, |
438 PP_Bool* result) { | 318 PP_Bool* result) { |
439 *result = ppb_flash_impl_->IsRectTopmost(instance, &rect); | 319 *result = ppb_flash_impl_->IsRectTopmost(instance, &rect); |
440 } | 320 } |
441 | 321 |
| 322 void PPB_Flash_Proxy::OnHostMsgFlashSetFullscreen(PP_Instance instance, |
| 323 PP_Bool fullscreen, |
| 324 PP_Bool* result) { |
| 325 thunk::EnterFunctionNoLock<thunk::PPB_Instance_FunctionAPI> enter( |
| 326 instance, false); |
| 327 if (enter.failed()) |
| 328 return; |
| 329 *result = enter.functions()->GetFlashAPI()->FlashSetFullscreen( |
| 330 instance, fullscreen); |
| 331 } |
| 332 |
| 333 void PPB_Flash_Proxy::OnHostMsgFlashGetScreenSize(PP_Instance instance, |
| 334 PP_Bool* result, |
| 335 PP_Size* size) { |
| 336 thunk::EnterFunctionNoLock<thunk::PPB_Instance_FunctionAPI> enter( |
| 337 instance, false); |
| 338 if (enter.failed()) |
| 339 return; |
| 340 *result = enter.functions()->GetFlashAPI()->FlashGetScreenSize( |
| 341 instance, size); |
| 342 } |
| 343 |
442 } // namespace proxy | 344 } // namespace proxy |
443 } // namespace ppapi | 345 } // namespace ppapi |
OLD | NEW |