| 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_instance_proxy.h" | 5 #include "ppapi/proxy/ppb_instance_proxy.h" |
| 6 | 6 |
| 7 #include "ppapi/c/pp_errors.h" | 7 #include "ppapi/c/pp_errors.h" |
| 8 #include "ppapi/c/pp_time.h" | 8 #include "ppapi/c/pp_time.h" |
| 9 #include "ppapi/c/pp_var.h" | 9 #include "ppapi/c/pp_var.h" |
| 10 #include "ppapi/c/ppb_audio_config.h" | 10 #include "ppapi/c/ppb_audio_config.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_RequestInputEvents, | 117 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_RequestInputEvents, |
| 118 OnHostMsgRequestInputEvents) | 118 OnHostMsgRequestInputEvents) |
| 119 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ClearInputEvents, | 119 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ClearInputEvents, |
| 120 OnHostMsgClearInputEvents) | 120 OnHostMsgClearInputEvents) |
| 121 IPC_MESSAGE_HANDLER(PpapiMsg_PPPInputEvent_HandleInputEvent_ACK, | 121 IPC_MESSAGE_HANDLER(PpapiMsg_PPPInputEvent_HandleInputEvent_ACK, |
| 122 OnMsgHandleInputEventAck) | 122 OnMsgHandleInputEventAck) |
| 123 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_LockMouse, | 123 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_LockMouse, |
| 124 OnHostMsgLockMouse) | 124 OnHostMsgLockMouse) |
| 125 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UnlockMouse, | 125 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UnlockMouse, |
| 126 OnHostMsgUnlockMouse) | 126 OnHostMsgUnlockMouse) |
| 127 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBPInstance_GetDefaultPrintSettings, | |
| 128 OnHostMsgGetDefaultPrintSettings) | |
| 129 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetCursor, | 127 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetCursor, |
| 130 OnHostMsgSetCursor) | 128 OnHostMsgSetCursor) |
| 131 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetTextInputType, | 129 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetTextInputType, |
| 132 OnHostMsgSetTextInputType) | 130 OnHostMsgSetTextInputType) |
| 133 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UpdateCaretPosition, | 131 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UpdateCaretPosition, |
| 134 OnHostMsgUpdateCaretPosition) | 132 OnHostMsgUpdateCaretPosition) |
| 135 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_CancelCompositionText, | 133 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_CancelCompositionText, |
| 136 OnHostMsgCancelCompositionText) | 134 OnHostMsgCancelCompositionText) |
| 137 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UpdateSurroundingText, | 135 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UpdateSurroundingText, |
| 138 OnHostMsgUpdateSurroundingText) | 136 OnHostMsgUpdateSurroundingText) |
| 139 #if !defined(OS_NACL) | 137 #if !defined(OS_NACL) |
| 140 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ResolveRelativeToDocument, | 138 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ResolveRelativeToDocument, |
| 141 OnHostMsgResolveRelativeToDocument) | 139 OnHostMsgResolveRelativeToDocument) |
| 142 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DocumentCanRequest, | 140 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DocumentCanRequest, |
| 143 OnHostMsgDocumentCanRequest) | 141 OnHostMsgDocumentCanRequest) |
| 144 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DocumentCanAccessDocument, | 142 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DocumentCanAccessDocument, |
| 145 OnHostMsgDocumentCanAccessDocument) | 143 OnHostMsgDocumentCanAccessDocument) |
| 146 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetDocumentURL, | 144 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetDocumentURL, |
| 147 OnHostMsgGetDocumentURL) | 145 OnHostMsgGetDocumentURL) |
| 148 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetPluginInstanceURL, | 146 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetPluginInstanceURL, |
| 149 OnHostMsgGetPluginInstanceURL) | 147 OnHostMsgGetPluginInstanceURL) |
| 150 #endif // !defined(OS_NACL) | 148 #endif // !defined(OS_NACL) |
| 151 | 149 |
| 152 // Host -> Plugin messages. | 150 // Host -> Plugin messages. |
| 153 IPC_MESSAGE_HANDLER(PpapiMsg_PPBInstance_MouseLockComplete, | 151 IPC_MESSAGE_HANDLER(PpapiMsg_PPBInstance_MouseLockComplete, |
| 154 OnPluginMsgMouseLockComplete) | 152 OnPluginMsgMouseLockComplete) |
| 153 IPC_MESSAGE_HANDLER(PpapiMsg_PPBInstance_GetDefaultPrintSettingsComplete, |
| 154 OnPluginMsgGetDefaultPrintSettingsComplete) |
| 155 | 155 |
| 156 IPC_MESSAGE_UNHANDLED(handled = false) | 156 IPC_MESSAGE_UNHANDLED(handled = false) |
| 157 IPC_END_MESSAGE_MAP() | 157 IPC_END_MESSAGE_MAP() |
| 158 return handled; | 158 return handled; |
| 159 } | 159 } |
| 160 | 160 |
| 161 PP_Bool PPB_Instance_Proxy::BindGraphics(PP_Instance instance, | 161 PP_Bool PPB_Instance_Proxy::BindGraphics(PP_Instance instance, |
| 162 PP_Resource device) { | 162 PP_Resource device) { |
| 163 Resource* object = | 163 Resource* object = |
| 164 PpapiGlobals::Get()->GetResourceTracker()->GetResource(device); | 164 PpapiGlobals::Get()->GetResourceTracker()->GetResource(device); |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 dispatcher()->Send(new PpapiHostMsg_PPBInstance_LockMouse( | 450 dispatcher()->Send(new PpapiHostMsg_PPBInstance_LockMouse( |
| 451 API_ID_PPB_INSTANCE, instance)); | 451 API_ID_PPB_INSTANCE, instance)); |
| 452 return PP_OK_COMPLETIONPENDING; | 452 return PP_OK_COMPLETIONPENDING; |
| 453 } | 453 } |
| 454 | 454 |
| 455 void PPB_Instance_Proxy::UnlockMouse(PP_Instance instance) { | 455 void PPB_Instance_Proxy::UnlockMouse(PP_Instance instance) { |
| 456 dispatcher()->Send(new PpapiHostMsg_PPBInstance_UnlockMouse( | 456 dispatcher()->Send(new PpapiHostMsg_PPBInstance_UnlockMouse( |
| 457 API_ID_PPB_INSTANCE, instance)); | 457 API_ID_PPB_INSTANCE, instance)); |
| 458 } | 458 } |
| 459 | 459 |
| 460 PP_Bool PPB_Instance_Proxy::GetDefaultPrintSettings( | 460 int32_t PPB_Instance_Proxy::GetDefaultPrintSettings( |
| 461 PP_Instance instance, | 461 PP_Instance instance, |
| 462 PP_PrintSettings_Dev* print_settings) { | 462 PP_PrintSettings_Dev* print_settings, |
| 463 scoped_refptr<TrackedCallback> callback) { |
| 463 if (!print_settings) | 464 if (!print_settings) |
| 464 return PP_FALSE; | 465 return PP_ERROR_BADARGUMENT; |
| 466 PluginDispatcher* plugin_dispatcher = |
| 467 static_cast<PluginDispatcher*>(dispatcher()); |
| 468 InstanceData* data = plugin_dispatcher->GetInstanceData(instance); |
| 469 if (!data) |
| 470 return PP_ERROR_BADARGUMENT; |
| 471 if (TrackedCallback::IsPending(data->default_print_settings_callback)) |
| 472 return PP_ERROR_INPROGRESS; // Already have a pending callback. |
| 473 data->default_print_settings_callback = callback; |
| 474 data->default_print_settings = print_settings; |
| 465 | 475 |
| 466 bool result; | 476 PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( |
| 467 dispatcher()->Send(new PpapiHostMsg_PPBPInstance_GetDefaultPrintSettings( | 477 new PpapiHostMsg_PPBPInstance_GetDefaultPrintSettings( |
| 468 API_ID_PPB_INSTANCE, instance, print_settings, &result)); | 478 API_ID_PPB_INSTANCE, plugin_dispatcher->plugin_dispatcher_id(), |
| 479 instance)); |
| 469 | 480 |
| 470 return PP_FromBool(result); | 481 return PP_OK_COMPLETIONPENDING; |
| 471 } | 482 } |
| 472 | 483 |
| 473 void PPB_Instance_Proxy::SetTextInputType(PP_Instance instance, | 484 void PPB_Instance_Proxy::SetTextInputType(PP_Instance instance, |
| 474 PP_TextInput_Type type) { | 485 PP_TextInput_Type type) { |
| 475 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SetTextInputType( | 486 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SetTextInputType( |
| 476 API_ID_PPB_INSTANCE, instance, type)); | 487 API_ID_PPB_INSTANCE, instance, type)); |
| 477 } | 488 } |
| 478 | 489 |
| 479 void PPB_Instance_Proxy::UpdateCaretPosition(PP_Instance instance, | 490 void PPB_Instance_Proxy::UpdateCaretPosition(PP_Instance instance, |
| 480 const PP_Rect& caret, | 491 const PP_Rect& caret, |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 if (enter.succeeded()) | 660 if (enter.succeeded()) |
| 650 enter.SetResult(enter.functions()->LockMouse(instance, enter.callback())); | 661 enter.SetResult(enter.functions()->LockMouse(instance, enter.callback())); |
| 651 } | 662 } |
| 652 | 663 |
| 653 void PPB_Instance_Proxy::OnHostMsgUnlockMouse(PP_Instance instance) { | 664 void PPB_Instance_Proxy::OnHostMsgUnlockMouse(PP_Instance instance) { |
| 654 EnterInstanceNoLock enter(instance); | 665 EnterInstanceNoLock enter(instance); |
| 655 if (enter.succeeded()) | 666 if (enter.succeeded()) |
| 656 enter.functions()->UnlockMouse(instance); | 667 enter.functions()->UnlockMouse(instance); |
| 657 } | 668 } |
| 658 | 669 |
| 659 void PPB_Instance_Proxy::OnHostMsgGetDefaultPrintSettings( | |
| 660 PP_Instance instance, | |
| 661 PP_PrintSettings_Dev* settings, | |
| 662 bool* result) { | |
| 663 // TODO(raymes): This just returns some generic settings. Actually hook this | |
| 664 // up to the browser to return the real defaults. | |
| 665 PP_PrintSettings_Dev default_settings = { | |
| 666 // |printable_area|: all of the sheet of paper. | |
| 667 { { 0, 0 }, { 612, 792 } }, | |
| 668 // |content_area|: 0.5" margins all around. | |
| 669 { { 36, 36 }, { 540, 720 } }, | |
| 670 // |paper_size|: 8.5" x 11" (US letter). | |
| 671 { 612, 792 }, | |
| 672 300, // |dpi|. | |
| 673 PP_PRINTORIENTATION_NORMAL, // |orientation|. | |
| 674 PP_PRINTSCALINGOPTION_NONE, // |print_scaling_option|. | |
| 675 PP_FALSE, // |grayscale|. | |
| 676 PP_PRINTOUTPUTFORMAT_PDF // |format|. | |
| 677 }; | |
| 678 *settings = default_settings; | |
| 679 *result = true; | |
| 680 } | |
| 681 | |
| 682 #if !defined(OS_NACL) | 670 #if !defined(OS_NACL) |
| 683 void PPB_Instance_Proxy::OnHostMsgResolveRelativeToDocument( | 671 void PPB_Instance_Proxy::OnHostMsgResolveRelativeToDocument( |
| 684 PP_Instance instance, | 672 PP_Instance instance, |
| 685 SerializedVarReceiveInput relative, | 673 SerializedVarReceiveInput relative, |
| 686 SerializedVarReturnValue result) { | 674 SerializedVarReturnValue result) { |
| 687 EnterInstanceNoLock enter(instance); | 675 EnterInstanceNoLock enter(instance); |
| 688 if (enter.succeeded()) { | 676 if (enter.succeeded()) { |
| 689 result.Return(dispatcher(), | 677 result.Return(dispatcher(), |
| 690 enter.functions()->ResolveRelativeToDocument( | 678 enter.functions()->ResolveRelativeToDocument( |
| 691 instance, relative.Get(dispatcher()), NULL)); | 679 instance, relative.Get(dispatcher()), NULL)); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 792 } | 780 } |
| 793 TrackedCallback::ClearAndRun(&(data->mouse_lock_callback), result); | 781 TrackedCallback::ClearAndRun(&(data->mouse_lock_callback), result); |
| 794 } | 782 } |
| 795 | 783 |
| 796 void PPB_Instance_Proxy::MouseLockCompleteInHost(int32_t result, | 784 void PPB_Instance_Proxy::MouseLockCompleteInHost(int32_t result, |
| 797 PP_Instance instance) { | 785 PP_Instance instance) { |
| 798 dispatcher()->Send(new PpapiMsg_PPBInstance_MouseLockComplete( | 786 dispatcher()->Send(new PpapiMsg_PPBInstance_MouseLockComplete( |
| 799 API_ID_PPB_INSTANCE, instance, result)); | 787 API_ID_PPB_INSTANCE, instance, result)); |
| 800 } | 788 } |
| 801 | 789 |
| 790 void PPB_Instance_Proxy::OnPluginMsgGetDefaultPrintSettingsComplete( |
| 791 int32 routing_id, |
| 792 PP_Instance instance, |
| 793 const PP_PrintSettings_Dev& settings, |
| 794 int32_t result) { |
| 795 InstanceData* data = |
| 796 static_cast<PluginDispatcher*>(dispatcher())->GetInstanceData(instance); |
| 797 if (!data) |
| 798 return; // Instance was probably deleted. |
| 799 if (!TrackedCallback::IsPending(data->default_print_settings_callback) || |
| 800 !data->default_print_settings) { |
| 801 NOTREACHED(); |
| 802 return; |
| 803 } |
| 804 *data->default_print_settings = settings; |
| 805 TrackedCallback::ClearAndRun( |
| 806 &(data->default_print_settings_callback), result); |
| 807 } |
| 808 |
| 802 } // namespace proxy | 809 } // namespace proxy |
| 803 } // namespace ppapi | 810 } // namespace ppapi |
| OLD | NEW |