Chromium Code Reviews| 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(PpapiMsg_PPBPrinting_GetDefaultPrintSettings, | |
| 128 OnHostMsgGetDefaultPrintSettings) | |
| 127 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetCursor, | 129 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetCursor, |
| 128 OnHostMsgSetCursor) | 130 OnHostMsgSetCursor) |
| 129 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetTextInputType, | 131 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetTextInputType, |
| 130 OnHostMsgSetTextInputType) | 132 OnHostMsgSetTextInputType) |
| 131 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UpdateCaretPosition, | 133 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UpdateCaretPosition, |
| 132 OnHostMsgUpdateCaretPosition) | 134 OnHostMsgUpdateCaretPosition) |
| 133 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_CancelCompositionText, | 135 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_CancelCompositionText, |
| 134 OnHostMsgCancelCompositionText) | 136 OnHostMsgCancelCompositionText) |
| 135 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UpdateSurroundingText, | 137 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UpdateSurroundingText, |
| 136 OnHostMsgUpdateSurroundingText) | 138 OnHostMsgUpdateSurroundingText) |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 451 dispatcher()->Send(new PpapiHostMsg_PPBInstance_LockMouse( | 453 dispatcher()->Send(new PpapiHostMsg_PPBInstance_LockMouse( |
| 452 API_ID_PPB_INSTANCE, instance)); | 454 API_ID_PPB_INSTANCE, instance)); |
| 453 return PP_OK_COMPLETIONPENDING; | 455 return PP_OK_COMPLETIONPENDING; |
| 454 } | 456 } |
| 455 | 457 |
| 456 void PPB_Instance_Proxy::UnlockMouse(PP_Instance instance) { | 458 void PPB_Instance_Proxy::UnlockMouse(PP_Instance instance) { |
| 457 dispatcher()->Send(new PpapiHostMsg_PPBInstance_UnlockMouse( | 459 dispatcher()->Send(new PpapiHostMsg_PPBInstance_UnlockMouse( |
| 458 API_ID_PPB_INSTANCE, instance)); | 460 API_ID_PPB_INSTANCE, instance)); |
| 459 } | 461 } |
| 460 | 462 |
| 463 PP_Bool PPB_Instance_Proxy::GetDefaultPrintSettings( | |
| 464 PP_Instance instance, | |
| 465 PP_PrintSettings_Dev* print_settings) { | |
| 466 std::string settings_string; | |
| 467 bool result; | |
| 468 dispatcher()->Send(new PpapiMsg_PPBPrinting_GetDefaultPrintSettings( | |
| 469 API_ID_PPB_INSTANCE, instance, &settings_string, &result)); | |
| 470 | |
| 471 if (result && print_settings && | |
|
yzshen1
2012/06/12 23:14:34
You could test print_settings at the top of the me
raymes
2012/06/13 18:23:47
Done.
| |
| 472 settings_string.size() == sizeof(*print_settings)) { | |
| 473 memcpy(print_settings, &settings_string[0], sizeof(*print_settings)); | |
|
yzshen1
2012/06/12 23:14:34
I don't think it is a good idea to pass a raw buff
raymes
2012/06/13 18:23:47
This is what was done in the existing code that tr
| |
| 474 return PP_TRUE; | |
| 475 } | |
| 476 return PP_FALSE; | |
| 477 } | |
| 478 | |
| 461 void PPB_Instance_Proxy::SetTextInputType(PP_Instance instance, | 479 void PPB_Instance_Proxy::SetTextInputType(PP_Instance instance, |
| 462 PP_TextInput_Type type) { | 480 PP_TextInput_Type type) { |
| 463 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SetTextInputType( | 481 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SetTextInputType( |
| 464 API_ID_PPB_INSTANCE, instance, type)); | 482 API_ID_PPB_INSTANCE, instance, type)); |
| 465 } | 483 } |
| 466 | 484 |
| 467 void PPB_Instance_Proxy::UpdateCaretPosition(PP_Instance instance, | 485 void PPB_Instance_Proxy::UpdateCaretPosition(PP_Instance instance, |
| 468 const PP_Rect& caret, | 486 const PP_Rect& caret, |
| 469 const PP_Rect& bounding_box) { | 487 const PP_Rect& bounding_box) { |
| 470 dispatcher()->Send(new PpapiHostMsg_PPBInstance_UpdateCaretPosition( | 488 dispatcher()->Send(new PpapiHostMsg_PPBInstance_UpdateCaretPosition( |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 643 if (result != PP_OK_COMPLETIONPENDING) | 661 if (result != PP_OK_COMPLETIONPENDING) |
| 644 cb.Run(result); | 662 cb.Run(result); |
| 645 } | 663 } |
| 646 | 664 |
| 647 void PPB_Instance_Proxy::OnHostMsgUnlockMouse(PP_Instance instance) { | 665 void PPB_Instance_Proxy::OnHostMsgUnlockMouse(PP_Instance instance) { |
| 648 EnterInstanceNoLock enter(instance); | 666 EnterInstanceNoLock enter(instance); |
| 649 if (enter.succeeded()) | 667 if (enter.succeeded()) |
| 650 enter.functions()->UnlockMouse(instance); | 668 enter.functions()->UnlockMouse(instance); |
| 651 } | 669 } |
| 652 | 670 |
| 671 void PPB_Instance_Proxy::OnHostMsgGetDefaultPrintSettings( | |
| 672 PP_Instance instance, | |
| 673 std::string* settings_string, | |
| 674 bool* result) { | |
| 675 // TODO(raymes): This just returns some generic settings. Actually hook this | |
| 676 // up to the browser to return the real defaults. | |
| 677 PP_PrintSettings_Dev generic_print_settings = { | |
| 678 // |printable_area|: all of the sheet of paper. | |
| 679 { { 0, 0 }, { 612, 792 } }, | |
| 680 // |content_area|: 0.5" margins all around. | |
| 681 { { 36, 36 }, { 540, 720 } }, | |
| 682 // |paper_size|: 8.5" x 11" (US letter). | |
| 683 { 612, 792 }, | |
| 684 300, // |dpi|. | |
| 685 PP_PRINTORIENTATION_NORMAL, // |orientation|. | |
| 686 PP_PRINTSCALINGOPTION_NONE, // |print_scaling_option|. | |
| 687 PP_FALSE, // |grayscale|. | |
| 688 PP_PRINTOUTPUTFORMAT_PDF // |format|. | |
| 689 }; | |
| 690 settings_string->resize(sizeof(generic_print_settings)); | |
| 691 memcpy(&(*settings_string)[0], &generic_print_settings, | |
| 692 sizeof(generic_print_settings)); | |
| 693 *result = true; | |
| 694 } | |
| 695 | |
| 653 #if !defined(OS_NACL) | 696 #if !defined(OS_NACL) |
| 654 void PPB_Instance_Proxy::OnHostMsgResolveRelativeToDocument( | 697 void PPB_Instance_Proxy::OnHostMsgResolveRelativeToDocument( |
| 655 PP_Instance instance, | 698 PP_Instance instance, |
| 656 SerializedVarReceiveInput relative, | 699 SerializedVarReceiveInput relative, |
| 657 SerializedVarReturnValue result) { | 700 SerializedVarReturnValue result) { |
| 658 EnterInstanceNoLock enter(instance); | 701 EnterInstanceNoLock enter(instance); |
| 659 if (enter.succeeded()) { | 702 if (enter.succeeded()) { |
| 660 result.Return(dispatcher(), | 703 result.Return(dispatcher(), |
| 661 enter.functions()->ResolveRelativeToDocument( | 704 enter.functions()->ResolveRelativeToDocument( |
| 662 instance, relative.Get(dispatcher()), NULL)); | 705 instance, relative.Get(dispatcher()), NULL)); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 764 } | 807 } |
| 765 | 808 |
| 766 void PPB_Instance_Proxy::MouseLockCompleteInHost(int32_t result, | 809 void PPB_Instance_Proxy::MouseLockCompleteInHost(int32_t result, |
| 767 PP_Instance instance) { | 810 PP_Instance instance) { |
| 768 dispatcher()->Send(new PpapiMsg_PPBInstance_MouseLockComplete( | 811 dispatcher()->Send(new PpapiMsg_PPBInstance_MouseLockComplete( |
| 769 API_ID_PPB_INSTANCE, instance, result)); | 812 API_ID_PPB_INSTANCE, instance, result)); |
| 770 } | 813 } |
| 771 | 814 |
| 772 } // namespace proxy | 815 } // namespace proxy |
| 773 } // namespace ppapi | 816 } // namespace ppapi |
| OLD | NEW |