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" |
(...skipping 12 matching lines...) Expand all Loading... | |
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_instance_api.h" |
30 #include "ppapi/thunk/ppb_url_request_info_api.h" | 30 #include "ppapi/thunk/ppb_url_request_info_api.h" |
31 #include "ppapi/thunk/resource_creation_api.h" | 31 #include "ppapi/thunk/resource_creation_api.h" |
32 | 32 |
33 using ppapi::thunk::EnterInstanceNoLock; | |
34 | |
33 namespace ppapi { | 35 namespace ppapi { |
34 namespace proxy { | 36 namespace proxy { |
35 | 37 |
36 PPB_Flash_Proxy::PPB_Flash_Proxy(Dispatcher* dispatcher) | 38 PPB_Flash_Proxy::PPB_Flash_Proxy(Dispatcher* dispatcher) |
37 : InterfaceProxy(dispatcher), | 39 : InterfaceProxy(dispatcher) { |
38 ppb_flash_impl_(NULL) { | |
39 if (!dispatcher->IsPlugin()) | |
40 ppb_flash_impl_ = static_cast<const PPB_Flash*>( | |
41 dispatcher->local_get_interface()(PPB_FLASH_INTERFACE)); | |
42 } | 40 } |
43 | 41 |
44 PPB_Flash_Proxy::~PPB_Flash_Proxy() { | 42 PPB_Flash_Proxy::~PPB_Flash_Proxy() { |
45 } | 43 } |
46 | 44 |
47 bool PPB_Flash_Proxy::OnMessageReceived(const IPC::Message& msg) { | 45 bool PPB_Flash_Proxy::OnMessageReceived(const IPC::Message& msg) { |
48 // Prevent the dispatcher from going away during a call to Navigate. | 46 // Prevent the dispatcher from going away during a call to Navigate. |
49 // This must happen OUTSIDE of OnMsgNavigate since the handling code use | 47 // This must happen OUTSIDE of OnMsgNavigate since the handling code use |
50 // the dispatcher upon return of the function (sending the reply message). | 48 // the dispatcher upon return of the function (sending the reply message). |
51 ScopedModuleReference death_grip(dispatcher()); | 49 ScopedModuleReference death_grip(dispatcher()); |
(...skipping 12 matching lines...) Expand all Loading... | |
64 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_QuitMessageLoop, | 62 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_QuitMessageLoop, |
65 OnHostMsgQuitMessageLoop) | 63 OnHostMsgQuitMessageLoop) |
66 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset, | 64 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset, |
67 OnHostMsgGetLocalTimeZoneOffset) | 65 OnHostMsgGetLocalTimeZoneOffset) |
68 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_IsRectTopmost, | 66 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_IsRectTopmost, |
69 OnHostMsgIsRectTopmost) | 67 OnHostMsgIsRectTopmost) |
70 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_FlashSetFullscreen, | 68 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_FlashSetFullscreen, |
71 OnHostMsgFlashSetFullscreen) | 69 OnHostMsgFlashSetFullscreen) |
72 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_FlashGetScreenSize, | 70 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_FlashGetScreenSize, |
73 OnHostMsgFlashGetScreenSize) | 71 OnHostMsgFlashGetScreenSize) |
72 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_IsClipboardFormatAvailable, | |
73 OnHostMsgIsClipboardFormatAvailable) | |
74 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_ReadClipboardData, | |
75 OnHostMsgReadClipboardData) | |
76 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_WriteClipboardData, | |
77 OnHostMsgWriteClipboardData) | |
74 IPC_MESSAGE_UNHANDLED(handled = false) | 78 IPC_MESSAGE_UNHANDLED(handled = false) |
75 IPC_END_MESSAGE_MAP() | 79 IPC_END_MESSAGE_MAP() |
76 // TODO(brettw) handle bad messages! | 80 // TODO(brettw) handle bad messages! |
77 return handled; | 81 return handled; |
78 } | 82 } |
79 | 83 |
80 void PPB_Flash_Proxy::SetInstanceAlwaysOnTop(PP_Instance instance, | 84 void PPB_Flash_Proxy::SetInstanceAlwaysOnTop(PP_Instance instance, |
81 PP_Bool on_top) { | 85 PP_Bool on_top) { |
82 dispatcher()->Send(new PpapiHostMsg_PPBFlash_SetInstanceAlwaysOnTop( | 86 dispatcher()->Send(new PpapiHostMsg_PPBFlash_SetInstanceAlwaysOnTop( |
83 API_ID_PPB_FLASH, instance, on_top)); | 87 API_ID_PPB_FLASH, instance, on_top)); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 | 121 |
118 params.glyph_indices.insert(params.glyph_indices.begin(), | 122 params.glyph_indices.insert(params.glyph_indices.begin(), |
119 &glyph_indices[0], | 123 &glyph_indices[0], |
120 &glyph_indices[glyph_count]); | 124 &glyph_indices[glyph_count]); |
121 params.glyph_advances.insert(params.glyph_advances.begin(), | 125 params.glyph_advances.insert(params.glyph_advances.begin(), |
122 &glyph_advances[0], | 126 &glyph_advances[0], |
123 &glyph_advances[glyph_count]); | 127 &glyph_advances[glyph_count]); |
124 | 128 |
125 PP_Bool result = PP_FALSE; | 129 PP_Bool result = PP_FALSE; |
126 dispatcher()->Send(new PpapiHostMsg_PPBFlash_DrawGlyphs( | 130 dispatcher()->Send(new PpapiHostMsg_PPBFlash_DrawGlyphs( |
127 API_ID_PPB_FLASH, params, &result)); | 131 API_ID_PPB_FLASH, instance, params, &result)); |
128 return result; | 132 return result; |
129 } | 133 } |
130 | 134 |
131 PP_Var PPB_Flash_Proxy::GetProxyForURL(PP_Instance instance, const char* url) { | 135 PP_Var PPB_Flash_Proxy::GetProxyForURL(PP_Instance instance, const char* url) { |
132 ReceiveSerializedVarReturnValue result; | 136 ReceiveSerializedVarReturnValue result; |
133 dispatcher()->Send(new PpapiHostMsg_PPBFlash_GetProxyForURL( | 137 dispatcher()->Send(new PpapiHostMsg_PPBFlash_GetProxyForURL( |
134 API_ID_PPB_FLASH, instance, url, &result)); | 138 API_ID_PPB_FLASH, instance, url, &result)); |
135 return result.Return(dispatcher()); | 139 return result.Return(dispatcher()); |
136 } | 140 } |
137 | 141 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 new PpapiHostMsg_PPBFlash_UpdateActivity(API_ID_PPB_FLASH)); | 199 new PpapiHostMsg_PPBFlash_UpdateActivity(API_ID_PPB_FLASH)); |
196 } | 200 } |
197 | 201 |
198 PP_Var PPB_Flash_Proxy::GetDeviceID(PP_Instance instance) { | 202 PP_Var PPB_Flash_Proxy::GetDeviceID(PP_Instance instance) { |
199 std::string id; | 203 std::string id; |
200 PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( | 204 PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( |
201 new PpapiHostMsg_PPBFlash_GetDeviceID(API_ID_PPB_FLASH, &id)); | 205 new PpapiHostMsg_PPBFlash_GetDeviceID(API_ID_PPB_FLASH, &id)); |
202 return StringVar::StringToPPVar(id); | 206 return StringVar::StringToPPVar(id); |
203 } | 207 } |
204 | 208 |
209 PP_Bool PPB_Flash_Proxy::IsClipboardFormatAvailable( | |
210 PP_Instance instance, | |
211 PP_Flash_Clipboard_Type clipboard_type, | |
212 PP_Flash_Clipboard_Format format) { | |
213 bool result = false; | |
214 dispatcher()->Send(new PpapiHostMsg_PPBFlash_IsClipboardFormatAvailable( | |
215 API_ID_PPB_FLASH, | |
216 instance, | |
217 static_cast<int>(clipboard_type), | |
218 static_cast<int>(format), | |
219 &result)); | |
220 return PP_FromBool(result); | |
221 } | |
222 | |
223 PP_Var PPB_Flash_Proxy::ReadClipboardData( | |
224 PP_Instance instance, | |
225 PP_Flash_Clipboard_Type clipboard_type, | |
226 PP_Flash_Clipboard_Format format) { | |
227 ReceiveSerializedVarReturnValue result; | |
228 dispatcher()->Send(new PpapiHostMsg_PPBFlash_ReadClipboardData( | |
229 API_ID_PPB_FLASH, instance, | |
230 static_cast<int>(clipboard_type), static_cast<int>(format), &result)); | |
231 return result.Return(dispatcher()); | |
232 } | |
233 | |
234 int32_t PPB_Flash_Proxy::WriteClipboardData( | |
235 PP_Instance instance, | |
236 PP_Flash_Clipboard_Type clipboard_type, | |
237 uint32_t data_item_count, | |
238 const PP_Flash_Clipboard_Format formats[], | |
239 const PP_Var data_items[]) { | |
240 std::vector<int> formats_vector(formats, formats + data_item_count); | |
241 | |
242 std::vector<SerializedVar> data_items_vector; | |
243 SerializedVarSendInput::ConvertVector( | |
244 dispatcher(), | |
245 data_items, | |
246 data_item_count, | |
247 &data_items_vector); | |
248 | |
249 dispatcher()->Send(new PpapiHostMsg_PPBFlash_WriteClipboardData( | |
250 API_ID_PPB_FLASH, | |
251 instance, | |
252 static_cast<int>(clipboard_type), | |
253 formats_vector, | |
254 data_items_vector)); | |
255 // Assume success, since it allows us to avoid a sync IPC. | |
256 return PP_OK; | |
257 } | |
258 | |
205 PP_Bool PPB_Flash_Proxy::FlashIsFullscreen(PP_Instance instance) { | 259 PP_Bool PPB_Flash_Proxy::FlashIsFullscreen(PP_Instance instance) { |
206 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> | 260 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> |
207 GetInstanceData(instance); | 261 GetInstanceData(instance); |
208 if (!data) | 262 if (!data) |
209 return PP_FALSE; | 263 return PP_FALSE; |
210 return data->flash_fullscreen; | 264 return data->flash_fullscreen; |
211 } | 265 } |
212 | 266 |
213 PP_Bool PPB_Flash_Proxy::FlashSetFullscreen(PP_Instance instance, | 267 PP_Bool PPB_Flash_Proxy::FlashSetFullscreen(PP_Instance instance, |
214 PP_Bool fullscreen) { | 268 PP_Bool fullscreen) { |
215 PP_Bool result = PP_FALSE; | 269 PP_Bool result = PP_FALSE; |
216 dispatcher()->Send(new PpapiHostMsg_PPBFlash_FlashSetFullscreen( | 270 dispatcher()->Send(new PpapiHostMsg_PPBFlash_FlashSetFullscreen( |
217 API_ID_PPB_INSTANCE, instance, fullscreen, &result)); | 271 API_ID_PPB_INSTANCE, instance, fullscreen, &result)); |
218 return result; | 272 return result; |
219 } | 273 } |
220 | 274 |
221 PP_Bool PPB_Flash_Proxy::FlashGetScreenSize(PP_Instance instance, | 275 PP_Bool PPB_Flash_Proxy::FlashGetScreenSize(PP_Instance instance, |
222 PP_Size* size) { | 276 PP_Size* size) { |
223 PP_Bool result = PP_FALSE; | 277 PP_Bool result = PP_FALSE; |
224 dispatcher()->Send(new PpapiHostMsg_PPBFlash_FlashGetScreenSize( | 278 dispatcher()->Send(new PpapiHostMsg_PPBFlash_FlashGetScreenSize( |
225 API_ID_PPB_INSTANCE, instance, &result, size)); | 279 API_ID_PPB_INSTANCE, instance, &result, size)); |
226 return result; | 280 return result; |
227 } | 281 } |
228 | 282 |
229 void PPB_Flash_Proxy::OnHostMsgSetInstanceAlwaysOnTop(PP_Instance instance, | 283 void PPB_Flash_Proxy::OnHostMsgSetInstanceAlwaysOnTop(PP_Instance instance, |
230 PP_Bool on_top) { | 284 PP_Bool on_top) { |
231 ppb_flash_impl_->SetInstanceAlwaysOnTop(instance, on_top); | 285 EnterInstanceNoLock enter(instance); |
286 if (enter.succeeded()) | |
287 enter.functions()->GetFlashAPI()->SetInstanceAlwaysOnTop(instance, on_top); | |
232 } | 288 } |
233 | 289 |
234 void PPB_Flash_Proxy::OnHostMsgDrawGlyphs( | 290 void PPB_Flash_Proxy::OnHostMsgDrawGlyphs( |
291 PP_Instance instance, | |
235 const PPBFlash_DrawGlyphs_Params& params, | 292 const PPBFlash_DrawGlyphs_Params& params, |
236 PP_Bool* result) { | 293 PP_Bool* result) { |
237 *result = PP_FALSE; | 294 *result = PP_FALSE; |
295 EnterInstanceNoLock enter(instance); | |
296 if (enter.failed()) | |
297 return; | |
238 | 298 |
239 PP_FontDescription_Dev font_desc; | 299 PP_FontDescription_Dev font_desc; |
240 params.font_desc.SetToPPFontDescription(dispatcher(), &font_desc, false); | 300 params.font_desc.SetToPPFontDescription(dispatcher(), &font_desc, false); |
241 | 301 |
242 if (params.glyph_indices.size() != params.glyph_advances.size() || | 302 if (params.glyph_indices.size() != params.glyph_advances.size() || |
243 params.glyph_indices.empty()) | 303 params.glyph_indices.empty()) |
244 return; | 304 return; |
245 | 305 |
246 *result = ppb_flash_impl_->DrawGlyphs( | 306 *result = enter.functions()->GetFlashAPI()->DrawGlyphs( |
247 0, // Unused instance param. | 307 0, // Unused instance param. |
248 params.image_data.host_resource(), &font_desc, | 308 params.image_data.host_resource(), &font_desc, |
249 params.color, ¶ms.position, ¶ms.clip, | 309 params.color, ¶ms.position, ¶ms.clip, |
250 const_cast<float(*)[3]>(params.transformation), | 310 const_cast<float(*)[3]>(params.transformation), |
251 params.allow_subpixel_aa, | 311 params.allow_subpixel_aa, |
252 static_cast<uint32_t>(params.glyph_indices.size()), | 312 static_cast<uint32_t>(params.glyph_indices.size()), |
253 const_cast<uint16_t*>(¶ms.glyph_indices[0]), | 313 const_cast<uint16_t*>(¶ms.glyph_indices[0]), |
254 const_cast<PP_Point*>(¶ms.glyph_advances[0])); | 314 const_cast<PP_Point*>(¶ms.glyph_advances[0])); |
255 } | 315 } |
256 | 316 |
257 void PPB_Flash_Proxy::OnHostMsgGetProxyForURL(PP_Instance instance, | 317 void PPB_Flash_Proxy::OnHostMsgGetProxyForURL(PP_Instance instance, |
258 const std::string& url, | 318 const std::string& url, |
259 SerializedVarReturnValue result) { | 319 SerializedVarReturnValue result) { |
260 result.Return(dispatcher(), ppb_flash_impl_->GetProxyForURL( | 320 EnterInstanceNoLock enter(instance); |
261 instance, url.c_str())); | 321 if (enter.succeeded()) { |
322 result.Return(dispatcher(), | |
323 enter.functions()->GetFlashAPI()->GetProxyForURL( | |
324 instance, url.c_str())); | |
325 } else { | |
326 result.Return(dispatcher(), PP_MakeUndefined()); | |
raymes
2012/04/23 03:18:10
I assume we should have been setting return values
brettw
2012/04/24 19:48:29
It was always set before. Now that there is a way
| |
327 } | |
262 } | 328 } |
263 | 329 |
264 void PPB_Flash_Proxy::OnHostMsgNavigate(PP_Instance instance, | 330 void PPB_Flash_Proxy::OnHostMsgNavigate(PP_Instance instance, |
265 const PPB_URLRequestInfo_Data& data, | 331 const PPB_URLRequestInfo_Data& data, |
266 const std::string& target, | 332 const std::string& target, |
267 PP_Bool from_user_action, | 333 PP_Bool from_user_action, |
268 int32_t* result) { | 334 int32_t* result) { |
335 EnterInstanceNoLock enter_instance(instance); | |
336 if (enter_instance.failed()) { | |
337 *result = PP_ERROR_BADARGUMENT; | |
338 return; | |
339 } | |
269 DCHECK(!dispatcher()->IsPlugin()); | 340 DCHECK(!dispatcher()->IsPlugin()); |
270 | 341 |
271 // Validate the PP_Instance since we'll be constructing resources on its | 342 // Validate the PP_Instance since we'll be constructing resources on its |
272 // behalf. | 343 // behalf. |
273 HostDispatcher* host_dispatcher = static_cast<HostDispatcher*>(dispatcher()); | 344 HostDispatcher* host_dispatcher = static_cast<HostDispatcher*>(dispatcher()); |
274 if (HostDispatcher::GetForInstance(instance) != host_dispatcher) { | 345 if (HostDispatcher::GetForInstance(instance) != host_dispatcher) { |
275 NOTREACHED(); | 346 NOTREACHED(); |
276 *result = PP_ERROR_BADARGUMENT; | 347 *result = PP_ERROR_BADARGUMENT; |
277 return; | 348 return; |
278 } | 349 } |
279 | 350 |
280 // We need to allow re-entrancy here, because this may call into Javascript | 351 // We need to allow re-entrancy here, because this may call into Javascript |
281 // (e.g. with a "javascript:" URL), or do things like navigate away from the | 352 // (e.g. with a "javascript:" URL), or do things like navigate away from the |
282 // page, either one of which will need to re-enter into the plugin. | 353 // page, either one of which will need to re-enter into the plugin. |
283 // It is safe, because it is essentially equivalent to NPN_GetURL, where Flash | 354 // It is safe, because it is essentially equivalent to NPN_GetURL, where Flash |
284 // would expect re-entrancy. When running in-process, it does re-enter here. | 355 // would expect re-entrancy. When running in-process, it does re-enter here. |
285 host_dispatcher->set_allow_plugin_reentrancy(); | 356 host_dispatcher->set_allow_plugin_reentrancy(); |
286 | 357 |
287 // Make a temporary request resource. | 358 // Make a temporary request resource. |
288 thunk::EnterFunctionNoLock<thunk::ResourceCreationAPI> enter(instance, true); | 359 thunk::EnterFunctionNoLock<thunk::ResourceCreationAPI> enter(instance, true); |
289 if (enter.failed()) { | 360 if (enter.failed()) { |
290 *result = PP_ERROR_FAILED; | 361 *result = PP_ERROR_FAILED; |
291 return; | 362 return; |
292 } | 363 } |
293 ScopedPPResource request_resource( | 364 ScopedPPResource request_resource( |
294 ScopedPPResource::PassRef(), | 365 ScopedPPResource::PassRef(), |
295 enter.functions()->CreateURLRequestInfo(instance, data)); | 366 enter.functions()->CreateURLRequestInfo(instance, data)); |
296 | 367 |
297 *result = ppb_flash_impl_->Navigate(request_resource, | 368 *result = enter_instance.functions()->GetFlashAPI()->Navigate( |
298 target.c_str(), | 369 instance, request_resource, target.c_str(), from_user_action); |
299 from_user_action); | |
300 } | 370 } |
301 | 371 |
302 void PPB_Flash_Proxy::OnHostMsgRunMessageLoop(PP_Instance instance) { | 372 void PPB_Flash_Proxy::OnHostMsgRunMessageLoop(PP_Instance instance) { |
303 ppb_flash_impl_->RunMessageLoop(instance); | 373 EnterInstanceNoLock enter(instance); |
374 if (enter.succeeded()) | |
375 enter.functions()->GetFlashAPI()->RunMessageLoop(instance); | |
304 } | 376 } |
305 | 377 |
306 void PPB_Flash_Proxy::OnHostMsgQuitMessageLoop(PP_Instance instance) { | 378 void PPB_Flash_Proxy::OnHostMsgQuitMessageLoop(PP_Instance instance) { |
307 ppb_flash_impl_->QuitMessageLoop(instance); | 379 EnterInstanceNoLock enter(instance); |
380 if (enter.succeeded()) | |
381 enter.functions()->GetFlashAPI()->QuitMessageLoop(instance); | |
308 } | 382 } |
309 | 383 |
310 void PPB_Flash_Proxy::OnHostMsgGetLocalTimeZoneOffset(PP_Instance instance, | 384 void PPB_Flash_Proxy::OnHostMsgGetLocalTimeZoneOffset(PP_Instance instance, |
311 PP_Time t, | 385 PP_Time t, |
312 double* result) { | 386 double* result) { |
313 *result = ppb_flash_impl_->GetLocalTimeZoneOffset(instance, t); | 387 EnterInstanceNoLock enter(instance); |
388 if (enter.succeeded()) { | |
389 *result = enter.functions()->GetFlashAPI()->GetLocalTimeZoneOffset( | |
390 instance, t); | |
391 } else { | |
392 *result = 0.0; | |
393 } | |
314 } | 394 } |
315 | 395 |
316 void PPB_Flash_Proxy::OnHostMsgIsRectTopmost(PP_Instance instance, | 396 void PPB_Flash_Proxy::OnHostMsgIsRectTopmost(PP_Instance instance, |
317 PP_Rect rect, | 397 PP_Rect rect, |
318 PP_Bool* result) { | 398 PP_Bool* result) { |
319 *result = ppb_flash_impl_->IsRectTopmost(instance, &rect); | 399 EnterInstanceNoLock enter(instance); |
400 if (enter.succeeded()) | |
401 *result = enter.functions()->GetFlashAPI()->IsRectTopmost(instance, &rect); | |
402 else | |
403 *result = PP_FALSE; | |
320 } | 404 } |
321 | 405 |
322 void PPB_Flash_Proxy::OnHostMsgFlashSetFullscreen(PP_Instance instance, | 406 void PPB_Flash_Proxy::OnHostMsgFlashSetFullscreen(PP_Instance instance, |
323 PP_Bool fullscreen, | 407 PP_Bool fullscreen, |
324 PP_Bool* result) { | 408 PP_Bool* result) { |
325 thunk::EnterFunctionNoLock<thunk::PPB_Instance_FunctionAPI> enter( | 409 EnterInstanceNoLock enter(instance); |
326 instance, false); | 410 if (enter.succeeded()) { |
327 if (enter.failed()) | 411 *result = enter.functions()->GetFlashAPI()->FlashSetFullscreen( |
328 return; | 412 instance, fullscreen); |
329 *result = enter.functions()->GetFlashAPI()->FlashSetFullscreen( | 413 } else { |
330 instance, fullscreen); | 414 *result = PP_FALSE; |
415 } | |
331 } | 416 } |
332 | 417 |
333 void PPB_Flash_Proxy::OnHostMsgFlashGetScreenSize(PP_Instance instance, | 418 void PPB_Flash_Proxy::OnHostMsgFlashGetScreenSize(PP_Instance instance, |
334 PP_Bool* result, | 419 PP_Bool* result, |
335 PP_Size* size) { | 420 PP_Size* size) { |
336 thunk::EnterFunctionNoLock<thunk::PPB_Instance_FunctionAPI> enter( | 421 EnterInstanceNoLock enter(instance); |
337 instance, false); | 422 if (enter.succeeded()) { |
338 if (enter.failed()) | 423 *result = enter.functions()->GetFlashAPI()->FlashGetScreenSize( |
339 return; | 424 instance, size); |
340 *result = enter.functions()->GetFlashAPI()->FlashGetScreenSize( | 425 } else { |
341 instance, size); | 426 size->width = 0; |
427 size->height = 0; | |
428 } | |
429 } | |
430 | |
431 void PPB_Flash_Proxy::OnHostMsgIsClipboardFormatAvailable( | |
432 PP_Instance instance, | |
433 int clipboard_type, | |
434 int format, | |
435 bool* result) { | |
436 EnterInstanceNoLock enter(instance); | |
437 if (enter.succeeded()) { | |
438 *result = PP_ToBool( | |
439 enter.functions()->GetFlashAPI()->IsClipboardFormatAvailable( | |
440 instance, | |
441 static_cast<PP_Flash_Clipboard_Type>(clipboard_type), | |
442 static_cast<PP_Flash_Clipboard_Format>(format))); | |
443 } else { | |
444 *result = false; | |
445 } | |
446 } | |
447 | |
448 void PPB_Flash_Proxy::OnHostMsgReadClipboardData( | |
449 PP_Instance instance, | |
450 int clipboard_type, | |
451 int format, | |
452 SerializedVarReturnValue result) { | |
453 EnterInstanceNoLock enter(instance); | |
454 if (enter.succeeded()) { | |
455 result.Return(dispatcher(), | |
456 enter.functions()->GetFlashAPI()->ReadClipboardData( | |
457 instance, | |
458 static_cast<PP_Flash_Clipboard_Type>(clipboard_type), | |
459 static_cast<PP_Flash_Clipboard_Format>(format))); | |
460 } | |
461 } | |
462 | |
463 void PPB_Flash_Proxy::OnHostMsgWriteClipboardData( | |
464 PP_Instance instance, | |
465 int clipboard_type, | |
466 const std::vector<int>& formats, | |
467 SerializedVarVectorReceiveInput data_items) { | |
468 EnterInstanceNoLock enter(instance); | |
469 if (enter.succeeded()) { | |
470 uint32_t data_item_count; | |
471 PP_Var* data_items_array = data_items.Get(dispatcher(), &data_item_count); | |
472 CHECK(data_item_count == formats.size()); | |
473 | |
474 scoped_array<PP_Flash_Clipboard_Format> formats_array( | |
475 new PP_Flash_Clipboard_Format[formats.size()]); | |
476 for (uint32_t i = 0; i < formats.size(); ++i) | |
477 formats_array[i] = static_cast<PP_Flash_Clipboard_Format>(formats[i]); | |
478 | |
479 int32_t result = enter.functions()->GetFlashAPI()->WriteClipboardData( | |
480 instance, | |
481 static_cast<PP_Flash_Clipboard_Type>(clipboard_type), | |
482 data_item_count, | |
483 formats_array.get(), | |
484 data_items_array); | |
485 DLOG_IF(WARNING, result != PP_OK) | |
486 << "Write to clipboard failed unexpectedly."; | |
487 (void)result; // Prevent warning in release mode. | |
488 } | |
342 } | 489 } |
343 | 490 |
344 } // namespace proxy | 491 } // namespace proxy |
345 } // namespace ppapi | 492 } // namespace ppapi |
OLD | NEW |