| 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 <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 | 10 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_QuitMessageLoop, | 115 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_QuitMessageLoop, |
| 116 OnHostMsgQuitMessageLoop) | 116 OnHostMsgQuitMessageLoop) |
| 117 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset, | 117 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset, |
| 118 OnHostMsgGetLocalTimeZoneOffset) | 118 OnHostMsgGetLocalTimeZoneOffset) |
| 119 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_IsRectTopmost, | 119 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_IsRectTopmost, |
| 120 OnHostMsgIsRectTopmost) | 120 OnHostMsgIsRectTopmost) |
| 121 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_FlashSetFullscreen, | 121 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_FlashSetFullscreen, |
| 122 OnHostMsgFlashSetFullscreen) | 122 OnHostMsgFlashSetFullscreen) |
| 123 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_FlashGetScreenSize, | 123 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_FlashGetScreenSize, |
| 124 OnHostMsgFlashGetScreenSize) | 124 OnHostMsgFlashGetScreenSize) |
| 125 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_IsClipboardFormatAvailable, | |
| 126 OnHostMsgIsClipboardFormatAvailable) | |
| 127 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_ReadClipboardData, | |
| 128 OnHostMsgReadClipboardData) | |
| 129 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_WriteClipboardData, | |
| 130 OnHostMsgWriteClipboardData) | |
| 131 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_OpenFileRef, | 125 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_OpenFileRef, |
| 132 OnHostMsgOpenFileRef) | 126 OnHostMsgOpenFileRef) |
| 133 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_QueryFileRef, | 127 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_QueryFileRef, |
| 134 OnHostMsgQueryFileRef) | 128 OnHostMsgQueryFileRef) |
| 135 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetDeviceID, | 129 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetDeviceID, |
| 136 OnHostMsgGetDeviceID) | 130 OnHostMsgGetDeviceID) |
| 137 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_InvokePrinting, | 131 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_InvokePrinting, |
| 138 OnHostMsgInvokePrinting) | 132 OnHostMsgInvokePrinting) |
| 139 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetSetting, | 133 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetSetting, |
| 140 OnHostMsgGetSetting) | 134 OnHostMsgGetSetting) |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 StringVar *url_string_var(StringVar::FromPPVar(value)); | 350 StringVar *url_string_var(StringVar::FromPPVar(value)); |
| 357 if (!url_string_var) | 351 if (!url_string_var) |
| 358 return PP_FALSE; | 352 return PP_FALSE; |
| 359 std::string url_string(url_string_var->value()); | 353 std::string url_string(url_string_var->value()); |
| 360 PluginGlobals::Get()->plugin_proxy_delegate()->SetActiveURL(url_string); | 354 PluginGlobals::Get()->plugin_proxy_delegate()->SetActiveURL(url_string); |
| 361 return PP_TRUE; | 355 return PP_TRUE; |
| 362 } | 356 } |
| 363 return PP_FALSE; | 357 return PP_FALSE; |
| 364 } | 358 } |
| 365 | 359 |
| 366 PP_Bool PPB_Flash_Proxy::IsClipboardFormatAvailable( | |
| 367 PP_Instance instance, | |
| 368 PP_Flash_Clipboard_Type clipboard_type, | |
| 369 PP_Flash_Clipboard_Format format) { | |
| 370 if (!IsValidClipboardType(clipboard_type) || !IsValidClipboardFormat(format)) | |
| 371 return PP_FALSE; | |
| 372 | |
| 373 bool result = false; | |
| 374 dispatcher()->Send(new PpapiHostMsg_PPBFlash_IsClipboardFormatAvailable( | |
| 375 API_ID_PPB_FLASH, | |
| 376 instance, | |
| 377 static_cast<int>(clipboard_type), | |
| 378 static_cast<int>(format), | |
| 379 &result)); | |
| 380 return PP_FromBool(result); | |
| 381 } | |
| 382 | |
| 383 PP_Var PPB_Flash_Proxy::ReadClipboardData( | |
| 384 PP_Instance instance, | |
| 385 PP_Flash_Clipboard_Type clipboard_type, | |
| 386 PP_Flash_Clipboard_Format format) { | |
| 387 if (!IsValidClipboardType(clipboard_type) || !IsValidClipboardFormat(format)) | |
| 388 return PP_MakeUndefined(); | |
| 389 | |
| 390 ReceiveSerializedVarReturnValue result; | |
| 391 dispatcher()->Send(new PpapiHostMsg_PPBFlash_ReadClipboardData( | |
| 392 API_ID_PPB_FLASH, instance, | |
| 393 static_cast<int>(clipboard_type), static_cast<int>(format), &result)); | |
| 394 return result.Return(dispatcher()); | |
| 395 } | |
| 396 | |
| 397 int32_t PPB_Flash_Proxy::WriteClipboardData( | |
| 398 PP_Instance instance, | |
| 399 PP_Flash_Clipboard_Type clipboard_type, | |
| 400 uint32_t data_item_count, | |
| 401 const PP_Flash_Clipboard_Format formats[], | |
| 402 const PP_Var data_items[]) { | |
| 403 if (!IsValidClipboardType(clipboard_type)) | |
| 404 return PP_ERROR_BADARGUMENT; | |
| 405 | |
| 406 std::vector<SerializedVar> data_items_vector; | |
| 407 SerializedVarSendInput::ConvertVector( | |
| 408 dispatcher(), | |
| 409 data_items, | |
| 410 data_item_count, | |
| 411 &data_items_vector); | |
| 412 for (size_t i = 0; i < data_item_count; ++i) { | |
| 413 if (!IsValidClipboardFormat(formats[i])) | |
| 414 return PP_ERROR_BADARGUMENT; | |
| 415 } | |
| 416 | |
| 417 std::vector<int> formats_vector(formats, formats + data_item_count); | |
| 418 dispatcher()->Send(new PpapiHostMsg_PPBFlash_WriteClipboardData( | |
| 419 API_ID_PPB_FLASH, | |
| 420 instance, | |
| 421 static_cast<int>(clipboard_type), | |
| 422 formats_vector, | |
| 423 data_items_vector)); | |
| 424 // Assume success, since it allows us to avoid a sync IPC. | |
| 425 return PP_OK; | |
| 426 } | |
| 427 | |
| 428 bool PPB_Flash_Proxy::CreateThreadAdapterForInstance(PP_Instance instance) { | 360 bool PPB_Flash_Proxy::CreateThreadAdapterForInstance(PP_Instance instance) { |
| 429 return true; | 361 return true; |
| 430 } | 362 } |
| 431 | 363 |
| 432 void PPB_Flash_Proxy::ClearThreadAdapterForInstance(PP_Instance instance) { | 364 void PPB_Flash_Proxy::ClearThreadAdapterForInstance(PP_Instance instance) { |
| 433 } | 365 } |
| 434 | 366 |
| 435 int32_t PPB_Flash_Proxy::OpenFile(PP_Instance, | 367 int32_t PPB_Flash_Proxy::OpenFile(PP_Instance, |
| 436 const char* path, | 368 const char* path, |
| 437 int32_t mode, | 369 int32_t mode, |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 EnterInstanceNoLock enter(instance); | 695 EnterInstanceNoLock enter(instance); |
| 764 if (enter.succeeded()) { | 696 if (enter.succeeded()) { |
| 765 *result = enter.functions()->GetFlashAPI()->FlashGetScreenSize( | 697 *result = enter.functions()->GetFlashAPI()->FlashGetScreenSize( |
| 766 instance, size); | 698 instance, size); |
| 767 } else { | 699 } else { |
| 768 size->width = 0; | 700 size->width = 0; |
| 769 size->height = 0; | 701 size->height = 0; |
| 770 } | 702 } |
| 771 } | 703 } |
| 772 | 704 |
| 773 void PPB_Flash_Proxy::OnHostMsgIsClipboardFormatAvailable( | |
| 774 PP_Instance instance, | |
| 775 int clipboard_type, | |
| 776 int format, | |
| 777 bool* result) { | |
| 778 EnterInstanceNoLock enter(instance); | |
| 779 if (enter.succeeded()) { | |
| 780 *result = PP_ToBool( | |
| 781 enter.functions()->GetFlashAPI()->IsClipboardFormatAvailable( | |
| 782 instance, | |
| 783 static_cast<PP_Flash_Clipboard_Type>(clipboard_type), | |
| 784 static_cast<PP_Flash_Clipboard_Format>(format))); | |
| 785 } else { | |
| 786 *result = false; | |
| 787 } | |
| 788 } | |
| 789 | |
| 790 void PPB_Flash_Proxy::OnHostMsgReadClipboardData( | |
| 791 PP_Instance instance, | |
| 792 int clipboard_type, | |
| 793 int format, | |
| 794 SerializedVarReturnValue result) { | |
| 795 EnterInstanceNoLock enter(instance); | |
| 796 if (enter.succeeded()) { | |
| 797 result.Return(dispatcher(), | |
| 798 enter.functions()->GetFlashAPI()->ReadClipboardData( | |
| 799 instance, | |
| 800 static_cast<PP_Flash_Clipboard_Type>(clipboard_type), | |
| 801 static_cast<PP_Flash_Clipboard_Format>(format))); | |
| 802 } | |
| 803 } | |
| 804 | |
| 805 void PPB_Flash_Proxy::OnHostMsgWriteClipboardData( | |
| 806 PP_Instance instance, | |
| 807 int clipboard_type, | |
| 808 const std::vector<int>& formats, | |
| 809 SerializedVarVectorReceiveInput data_items) { | |
| 810 EnterInstanceNoLock enter(instance); | |
| 811 if (enter.succeeded()) { | |
| 812 uint32_t data_item_count; | |
| 813 PP_Var* data_items_array = data_items.Get(dispatcher(), &data_item_count); | |
| 814 CHECK(data_item_count == formats.size()); | |
| 815 | |
| 816 scoped_array<PP_Flash_Clipboard_Format> formats_array( | |
| 817 new PP_Flash_Clipboard_Format[formats.size()]); | |
| 818 for (uint32_t i = 0; i < formats.size(); ++i) | |
| 819 formats_array[i] = static_cast<PP_Flash_Clipboard_Format>(formats[i]); | |
| 820 | |
| 821 int32_t result = enter.functions()->GetFlashAPI()->WriteClipboardData( | |
| 822 instance, | |
| 823 static_cast<PP_Flash_Clipboard_Type>(clipboard_type), | |
| 824 data_item_count, | |
| 825 formats_array.get(), | |
| 826 data_items_array); | |
| 827 DLOG_IF(WARNING, result != PP_OK) | |
| 828 << "Write to clipboard failed unexpectedly."; | |
| 829 (void)result; // Prevent warning in release mode. | |
| 830 } | |
| 831 } | |
| 832 | |
| 833 void PPB_Flash_Proxy::OnHostMsgOpenFileRef( | 705 void PPB_Flash_Proxy::OnHostMsgOpenFileRef( |
| 834 PP_Instance instance, | 706 PP_Instance instance, |
| 835 const HostResource& host_resource, | 707 const HostResource& host_resource, |
| 836 int32_t mode, | 708 int32_t mode, |
| 837 IPC::PlatformFileForTransit* file_handle, | 709 IPC::PlatformFileForTransit* file_handle, |
| 838 int32_t* result) { | 710 int32_t* result) { |
| 839 EnterInstanceNoLock enter(instance); | 711 EnterInstanceNoLock enter(instance); |
| 840 if (enter.failed()) { | 712 if (enter.failed()) { |
| 841 *result = PP_ERROR_BADARGUMENT; | 713 *result = PP_ERROR_BADARGUMENT; |
| 842 return; | 714 return; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 893 // It's rarely used enough that we just request this interface when needed. | 765 // It's rarely used enough that we just request this interface when needed. |
| 894 const PPB_Flash_Print_1_0* print_interface = | 766 const PPB_Flash_Print_1_0* print_interface = |
| 895 static_cast<const PPB_Flash_Print_1_0*>( | 767 static_cast<const PPB_Flash_Print_1_0*>( |
| 896 dispatcher()->local_get_interface()(PPB_FLASH_PRINT_INTERFACE_1_0)); | 768 dispatcher()->local_get_interface()(PPB_FLASH_PRINT_INTERFACE_1_0)); |
| 897 if (print_interface) | 769 if (print_interface) |
| 898 print_interface->InvokePrinting(instance); | 770 print_interface->InvokePrinting(instance); |
| 899 } | 771 } |
| 900 | 772 |
| 901 } // namespace proxy | 773 } // namespace proxy |
| 902 } // namespace ppapi | 774 } // namespace ppapi |
| OLD | NEW |