Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(387)

Side by Side Diff: ppapi/proxy/ppb_flash_proxy.cc

Issue 10163012: Move the FlashClipboard API into the Flash one. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments & fixes. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/proxy/ppb_flash_proxy.h ('k') | ppapi/shared_impl/api_id.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
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 if (!IsValidClipboardType(clipboard_type) || !IsValidClipboardFormat(format))
214 return PP_FALSE;
215
216 bool result = false;
217 dispatcher()->Send(new PpapiHostMsg_PPBFlash_IsClipboardFormatAvailable(
218 API_ID_PPB_FLASH,
219 instance,
220 static_cast<int>(clipboard_type),
221 static_cast<int>(format),
222 &result));
223 return PP_FromBool(result);
224 }
225
226 PP_Var PPB_Flash_Proxy::ReadClipboardData(
227 PP_Instance instance,
228 PP_Flash_Clipboard_Type clipboard_type,
229 PP_Flash_Clipboard_Format format) {
230 if (!IsValidClipboardType(clipboard_type) || !IsValidClipboardFormat(format))
231 return PP_MakeUndefined();
232
233 ReceiveSerializedVarReturnValue result;
234 dispatcher()->Send(new PpapiHostMsg_PPBFlash_ReadClipboardData(
235 API_ID_PPB_FLASH, instance,
236 static_cast<int>(clipboard_type), static_cast<int>(format), &result));
237 return result.Return(dispatcher());
238 }
239
240 int32_t PPB_Flash_Proxy::WriteClipboardData(
241 PP_Instance instance,
242 PP_Flash_Clipboard_Type clipboard_type,
243 uint32_t data_item_count,
244 const PP_Flash_Clipboard_Format formats[],
245 const PP_Var data_items[]) {
246 if (!IsValidClipboardType(clipboard_type))
247 return PP_ERROR_BADARGUMENT;
248
249 std::vector<SerializedVar> data_items_vector;
250 SerializedVarSendInput::ConvertVector(
251 dispatcher(),
252 data_items,
253 data_item_count,
254 &data_items_vector);
255 for (size_t i = 0; i < data_item_count; ++i) {
256 if (!IsValidClipboardFormat(formats[i]))
257 return PP_ERROR_BADARGUMENT;
258 }
259
260 std::vector<int> formats_vector(formats, formats + data_item_count);
261 dispatcher()->Send(new PpapiHostMsg_PPBFlash_WriteClipboardData(
262 API_ID_PPB_FLASH,
263 instance,
264 static_cast<int>(clipboard_type),
265 formats_vector,
266 data_items_vector));
267 // Assume success, since it allows us to avoid a sync IPC.
268 return PP_OK;
269 }
270
205 PP_Bool PPB_Flash_Proxy::FlashIsFullscreen(PP_Instance instance) { 271 PP_Bool PPB_Flash_Proxy::FlashIsFullscreen(PP_Instance instance) {
206 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> 272 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())->
207 GetInstanceData(instance); 273 GetInstanceData(instance);
208 if (!data) 274 if (!data)
209 return PP_FALSE; 275 return PP_FALSE;
210 return data->flash_fullscreen; 276 return data->flash_fullscreen;
211 } 277 }
212 278
213 PP_Bool PPB_Flash_Proxy::FlashSetFullscreen(PP_Instance instance, 279 PP_Bool PPB_Flash_Proxy::FlashSetFullscreen(PP_Instance instance,
214 PP_Bool fullscreen) { 280 PP_Bool fullscreen) {
215 PP_Bool result = PP_FALSE; 281 PP_Bool result = PP_FALSE;
216 dispatcher()->Send(new PpapiHostMsg_PPBFlash_FlashSetFullscreen( 282 dispatcher()->Send(new PpapiHostMsg_PPBFlash_FlashSetFullscreen(
217 API_ID_PPB_FLASH, instance, fullscreen, &result)); 283 API_ID_PPB_FLASH, instance, fullscreen, &result));
218 return result; 284 return result;
219 } 285 }
220 286
221 PP_Bool PPB_Flash_Proxy::FlashGetScreenSize(PP_Instance instance, 287 PP_Bool PPB_Flash_Proxy::FlashGetScreenSize(PP_Instance instance,
222 PP_Size* size) { 288 PP_Size* size) {
223 PP_Bool result = PP_FALSE; 289 PP_Bool result = PP_FALSE;
224 dispatcher()->Send(new PpapiHostMsg_PPBFlash_FlashGetScreenSize( 290 dispatcher()->Send(new PpapiHostMsg_PPBFlash_FlashGetScreenSize(
225 API_ID_PPB_FLASH, instance, &result, size)); 291 API_ID_PPB_FLASH, instance, &result, size));
226 return result; 292 return result;
227 } 293 }
228 294
229 void PPB_Flash_Proxy::OnHostMsgSetInstanceAlwaysOnTop(PP_Instance instance, 295 void PPB_Flash_Proxy::OnHostMsgSetInstanceAlwaysOnTop(PP_Instance instance,
230 PP_Bool on_top) { 296 PP_Bool on_top) {
231 ppb_flash_impl_->SetInstanceAlwaysOnTop(instance, on_top); 297 EnterInstanceNoLock enter(instance);
298 if (enter.succeeded())
299 enter.functions()->GetFlashAPI()->SetInstanceAlwaysOnTop(instance, on_top);
232 } 300 }
233 301
234 void PPB_Flash_Proxy::OnHostMsgDrawGlyphs( 302 void PPB_Flash_Proxy::OnHostMsgDrawGlyphs(
303 PP_Instance instance,
235 const PPBFlash_DrawGlyphs_Params& params, 304 const PPBFlash_DrawGlyphs_Params& params,
236 PP_Bool* result) { 305 PP_Bool* result) {
237 *result = PP_FALSE; 306 *result = PP_FALSE;
307 EnterInstanceNoLock enter(instance);
308 if (enter.failed())
309 return;
238 310
239 PP_FontDescription_Dev font_desc; 311 PP_FontDescription_Dev font_desc;
240 params.font_desc.SetToPPFontDescription(dispatcher(), &font_desc, false); 312 params.font_desc.SetToPPFontDescription(dispatcher(), &font_desc, false);
241 313
242 if (params.glyph_indices.size() != params.glyph_advances.size() || 314 if (params.glyph_indices.size() != params.glyph_advances.size() ||
243 params.glyph_indices.empty()) 315 params.glyph_indices.empty())
244 return; 316 return;
245 317
246 *result = ppb_flash_impl_->DrawGlyphs( 318 *result = enter.functions()->GetFlashAPI()->DrawGlyphs(
247 0, // Unused instance param. 319 0, // Unused instance param.
248 params.image_data.host_resource(), &font_desc, 320 params.image_data.host_resource(), &font_desc,
249 params.color, &params.position, &params.clip, 321 params.color, &params.position, &params.clip,
250 const_cast<float(*)[3]>(params.transformation), 322 const_cast<float(*)[3]>(params.transformation),
251 params.allow_subpixel_aa, 323 params.allow_subpixel_aa,
252 static_cast<uint32_t>(params.glyph_indices.size()), 324 static_cast<uint32_t>(params.glyph_indices.size()),
253 const_cast<uint16_t*>(&params.glyph_indices[0]), 325 const_cast<uint16_t*>(&params.glyph_indices[0]),
254 const_cast<PP_Point*>(&params.glyph_advances[0])); 326 const_cast<PP_Point*>(&params.glyph_advances[0]));
255 } 327 }
256 328
257 void PPB_Flash_Proxy::OnHostMsgGetProxyForURL(PP_Instance instance, 329 void PPB_Flash_Proxy::OnHostMsgGetProxyForURL(PP_Instance instance,
258 const std::string& url, 330 const std::string& url,
259 SerializedVarReturnValue result) { 331 SerializedVarReturnValue result) {
260 result.Return(dispatcher(), ppb_flash_impl_->GetProxyForURL( 332 EnterInstanceNoLock enter(instance);
261 instance, url.c_str())); 333 if (enter.succeeded()) {
334 result.Return(dispatcher(),
335 enter.functions()->GetFlashAPI()->GetProxyForURL(
336 instance, url.c_str()));
337 } else {
338 result.Return(dispatcher(), PP_MakeUndefined());
339 }
262 } 340 }
263 341
264 void PPB_Flash_Proxy::OnHostMsgNavigate(PP_Instance instance, 342 void PPB_Flash_Proxy::OnHostMsgNavigate(PP_Instance instance,
265 const PPB_URLRequestInfo_Data& data, 343 const PPB_URLRequestInfo_Data& data,
266 const std::string& target, 344 const std::string& target,
267 PP_Bool from_user_action, 345 PP_Bool from_user_action,
268 int32_t* result) { 346 int32_t* result) {
347 EnterInstanceNoLock enter_instance(instance);
348 if (enter_instance.failed()) {
349 *result = PP_ERROR_BADARGUMENT;
350 return;
351 }
269 DCHECK(!dispatcher()->IsPlugin()); 352 DCHECK(!dispatcher()->IsPlugin());
270 353
271 // Validate the PP_Instance since we'll be constructing resources on its 354 // Validate the PP_Instance since we'll be constructing resources on its
272 // behalf. 355 // behalf.
273 HostDispatcher* host_dispatcher = static_cast<HostDispatcher*>(dispatcher()); 356 HostDispatcher* host_dispatcher = static_cast<HostDispatcher*>(dispatcher());
274 if (HostDispatcher::GetForInstance(instance) != host_dispatcher) { 357 if (HostDispatcher::GetForInstance(instance) != host_dispatcher) {
275 NOTREACHED(); 358 NOTREACHED();
276 *result = PP_ERROR_BADARGUMENT; 359 *result = PP_ERROR_BADARGUMENT;
277 return; 360 return;
278 } 361 }
279 362
280 // We need to allow re-entrancy here, because this may call into Javascript 363 // 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 364 // (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. 365 // 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 366 // 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. 367 // would expect re-entrancy. When running in-process, it does re-enter here.
285 host_dispatcher->set_allow_plugin_reentrancy(); 368 host_dispatcher->set_allow_plugin_reentrancy();
286 369
287 // Make a temporary request resource. 370 // Make a temporary request resource.
288 thunk::EnterFunctionNoLock<thunk::ResourceCreationAPI> enter(instance, true); 371 thunk::EnterFunctionNoLock<thunk::ResourceCreationAPI> enter(instance, true);
289 if (enter.failed()) { 372 if (enter.failed()) {
290 *result = PP_ERROR_FAILED; 373 *result = PP_ERROR_FAILED;
291 return; 374 return;
292 } 375 }
293 ScopedPPResource request_resource( 376 ScopedPPResource request_resource(
294 ScopedPPResource::PassRef(), 377 ScopedPPResource::PassRef(),
295 enter.functions()->CreateURLRequestInfo(instance, data)); 378 enter.functions()->CreateURLRequestInfo(instance, data));
296 379
297 *result = ppb_flash_impl_->Navigate(request_resource, 380 *result = enter_instance.functions()->GetFlashAPI()->Navigate(
298 target.c_str(), 381 instance, request_resource, target.c_str(), from_user_action);
299 from_user_action);
300 } 382 }
301 383
302 void PPB_Flash_Proxy::OnHostMsgRunMessageLoop(PP_Instance instance) { 384 void PPB_Flash_Proxy::OnHostMsgRunMessageLoop(PP_Instance instance) {
303 ppb_flash_impl_->RunMessageLoop(instance); 385 EnterInstanceNoLock enter(instance);
386 if (enter.succeeded())
387 enter.functions()->GetFlashAPI()->RunMessageLoop(instance);
304 } 388 }
305 389
306 void PPB_Flash_Proxy::OnHostMsgQuitMessageLoop(PP_Instance instance) { 390 void PPB_Flash_Proxy::OnHostMsgQuitMessageLoop(PP_Instance instance) {
307 ppb_flash_impl_->QuitMessageLoop(instance); 391 EnterInstanceNoLock enter(instance);
392 if (enter.succeeded())
393 enter.functions()->GetFlashAPI()->QuitMessageLoop(instance);
308 } 394 }
309 395
310 void PPB_Flash_Proxy::OnHostMsgGetLocalTimeZoneOffset(PP_Instance instance, 396 void PPB_Flash_Proxy::OnHostMsgGetLocalTimeZoneOffset(PP_Instance instance,
311 PP_Time t, 397 PP_Time t,
312 double* result) { 398 double* result) {
313 *result = ppb_flash_impl_->GetLocalTimeZoneOffset(instance, t); 399 EnterInstanceNoLock enter(instance);
400 if (enter.succeeded()) {
401 *result = enter.functions()->GetFlashAPI()->GetLocalTimeZoneOffset(
402 instance, t);
403 } else {
404 *result = 0.0;
405 }
314 } 406 }
315 407
316 void PPB_Flash_Proxy::OnHostMsgIsRectTopmost(PP_Instance instance, 408 void PPB_Flash_Proxy::OnHostMsgIsRectTopmost(PP_Instance instance,
317 PP_Rect rect, 409 PP_Rect rect,
318 PP_Bool* result) { 410 PP_Bool* result) {
319 *result = ppb_flash_impl_->IsRectTopmost(instance, &rect); 411 EnterInstanceNoLock enter(instance);
412 if (enter.succeeded())
413 *result = enter.functions()->GetFlashAPI()->IsRectTopmost(instance, &rect);
414 else
415 *result = PP_FALSE;
320 } 416 }
321 417
322 void PPB_Flash_Proxy::OnHostMsgFlashSetFullscreen(PP_Instance instance, 418 void PPB_Flash_Proxy::OnHostMsgFlashSetFullscreen(PP_Instance instance,
323 PP_Bool fullscreen, 419 PP_Bool fullscreen,
324 PP_Bool* result) { 420 PP_Bool* result) {
325 thunk::EnterFunctionNoLock<thunk::PPB_Instance_FunctionAPI> enter( 421 EnterInstanceNoLock enter(instance);
326 instance, false); 422 if (enter.succeeded()) {
327 if (enter.failed()) 423 *result = enter.functions()->GetFlashAPI()->FlashSetFullscreen(
328 return; 424 instance, fullscreen);
329 *result = enter.functions()->GetFlashAPI()->FlashSetFullscreen( 425 } else {
330 instance, fullscreen); 426 *result = PP_FALSE;
427 }
331 } 428 }
332 429
333 void PPB_Flash_Proxy::OnHostMsgFlashGetScreenSize(PP_Instance instance, 430 void PPB_Flash_Proxy::OnHostMsgFlashGetScreenSize(PP_Instance instance,
334 PP_Bool* result, 431 PP_Bool* result,
335 PP_Size* size) { 432 PP_Size* size) {
336 thunk::EnterFunctionNoLock<thunk::PPB_Instance_FunctionAPI> enter( 433 EnterInstanceNoLock enter(instance);
337 instance, false); 434 if (enter.succeeded()) {
338 if (enter.failed()) 435 *result = enter.functions()->GetFlashAPI()->FlashGetScreenSize(
339 return; 436 instance, size);
340 *result = enter.functions()->GetFlashAPI()->FlashGetScreenSize( 437 } else {
341 instance, size); 438 size->width = 0;
439 size->height = 0;
440 }
441 }
442
443 void PPB_Flash_Proxy::OnHostMsgIsClipboardFormatAvailable(
444 PP_Instance instance,
445 int clipboard_type,
446 int format,
447 bool* result) {
448 EnterInstanceNoLock enter(instance);
449 if (enter.succeeded()) {
450 *result = PP_ToBool(
451 enter.functions()->GetFlashAPI()->IsClipboardFormatAvailable(
452 instance,
453 static_cast<PP_Flash_Clipboard_Type>(clipboard_type),
454 static_cast<PP_Flash_Clipboard_Format>(format)));
455 } else {
456 *result = false;
457 }
458 }
459
460 void PPB_Flash_Proxy::OnHostMsgReadClipboardData(
461 PP_Instance instance,
462 int clipboard_type,
463 int format,
464 SerializedVarReturnValue result) {
465 EnterInstanceNoLock enter(instance);
466 if (enter.succeeded()) {
467 result.Return(dispatcher(),
468 enter.functions()->GetFlashAPI()->ReadClipboardData(
469 instance,
470 static_cast<PP_Flash_Clipboard_Type>(clipboard_type),
471 static_cast<PP_Flash_Clipboard_Format>(format)));
472 }
473 }
474
475 void PPB_Flash_Proxy::OnHostMsgWriteClipboardData(
476 PP_Instance instance,
477 int clipboard_type,
478 const std::vector<int>& formats,
479 SerializedVarVectorReceiveInput data_items) {
480 EnterInstanceNoLock enter(instance);
481 if (enter.succeeded()) {
482 uint32_t data_item_count;
483 PP_Var* data_items_array = data_items.Get(dispatcher(), &data_item_count);
484 CHECK(data_item_count == formats.size());
485
486 scoped_array<PP_Flash_Clipboard_Format> formats_array(
487 new PP_Flash_Clipboard_Format[formats.size()]);
488 for (uint32_t i = 0; i < formats.size(); ++i)
489 formats_array[i] = static_cast<PP_Flash_Clipboard_Format>(formats[i]);
490
491 int32_t result = enter.functions()->GetFlashAPI()->WriteClipboardData(
492 instance,
493 static_cast<PP_Flash_Clipboard_Type>(clipboard_type),
494 data_item_count,
495 formats_array.get(),
496 data_items_array);
497 DLOG_IF(WARNING, result != PP_OK)
498 << "Write to clipboard failed unexpectedly.";
499 (void)result; // Prevent warning in release mode.
500 }
342 } 501 }
343 502
344 } // namespace proxy 503 } // namespace proxy
345 } // namespace ppapi 504 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_flash_proxy.h ('k') | ppapi/shared_impl/api_id.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698