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

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

Issue 10170014: Move text input API to Instance. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
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_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 12 matching lines...) Expand all
23 #include "ppapi/shared_impl/ppb_view_shared.h" 23 #include "ppapi/shared_impl/ppb_view_shared.h"
24 #include "ppapi/shared_impl/var.h" 24 #include "ppapi/shared_impl/var.h"
25 #include "ppapi/thunk/enter.h" 25 #include "ppapi/thunk/enter.h"
26 #include "ppapi/thunk/thunk.h" 26 #include "ppapi/thunk/thunk.h"
27 27
28 // Windows headers interfere with this file. 28 // Windows headers interfere with this file.
29 #ifdef PostMessage 29 #ifdef PostMessage
30 #undef PostMessage 30 #undef PostMessage
31 #endif 31 #endif
32 32
33 using ppapi::thunk::EnterFunctionNoLock; 33 using ppapi::thunk::EnterInstanceNoLock;
34 using ppapi::thunk::EnterResourceNoLock; 34 using ppapi::thunk::EnterResourceNoLock;
35 using ppapi::thunk::PPB_Instance_FunctionAPI; 35 using ppapi::thunk::PPB_Instance_FunctionAPI;
36 36
37 namespace ppapi { 37 namespace ppapi {
38 namespace proxy { 38 namespace proxy {
39 39
40 namespace { 40 namespace {
41 41
42 typedef EnterFunctionNoLock<PPB_Instance_FunctionAPI> EnterInstanceNoLock;
43
44 InterfaceProxy* CreateInstanceProxy(Dispatcher* dispatcher) { 42 InterfaceProxy* CreateInstanceProxy(Dispatcher* dispatcher) {
45 return new PPB_Instance_Proxy(dispatcher); 43 return new PPB_Instance_Proxy(dispatcher);
46 } 44 }
47 45
46 void RequestSurroundingText(PP_Instance instance) {
47 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
48 if (!dispatcher)
49 return; // Instance has gone away while message was pending.
50
51 // Just fake out a RequestSurroundingText message to the proxy for the PPP
52 // interface.
53 InterfaceProxy* proxy = dispatcher->GetInterfaceProxy(API_ID_PPB_TEXT_INPUT);
54 if (!proxy)
55 return;
56 proxy->OnMessageReceived(PpapiMsg_PPPTextInput_RequestSurroundingText(
57 API_ID_PPP_TEXT_INPUT, instance,
58 PPB_Instance_Shared::kExtraCharsForTextInput));
59 }
60
48 } // namespace 61 } // namespace
49 62
50 PPB_Instance_Proxy::PPB_Instance_Proxy(Dispatcher* dispatcher) 63 PPB_Instance_Proxy::PPB_Instance_Proxy(Dispatcher* dispatcher)
51 : InterfaceProxy(dispatcher), 64 : InterfaceProxy(dispatcher),
52 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 65 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
53 } 66 }
54 67
55 PPB_Instance_Proxy::~PPB_Instance_Proxy() { 68 PPB_Instance_Proxy::~PPB_Instance_Proxy() {
56 } 69 }
57 70
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ClearInputEvents, 119 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ClearInputEvents,
107 OnHostMsgClearInputEvents) 120 OnHostMsgClearInputEvents)
108 IPC_MESSAGE_HANDLER(PpapiMsg_PPPInputEvent_HandleInputEvent_ACK, 121 IPC_MESSAGE_HANDLER(PpapiMsg_PPPInputEvent_HandleInputEvent_ACK,
109 OnMsgHandleInputEventAck) 122 OnMsgHandleInputEventAck)
110 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_LockMouse, 123 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_LockMouse,
111 OnHostMsgLockMouse) 124 OnHostMsgLockMouse)
112 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UnlockMouse, 125 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UnlockMouse,
113 OnHostMsgUnlockMouse) 126 OnHostMsgUnlockMouse)
114 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetCursor, 127 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetCursor,
115 OnHostMsgSetCursor) 128 OnHostMsgSetCursor)
129 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetTextInputType,
130 OnHostMsgSetTextInputType)
131 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UpdateCaretPosition,
132 OnHostMsgUpdateCaretPosition)
133 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_CancelCompositionText,
134 OnHostMsgCancelCompositionText)
135 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UpdateSurroundingText,
136 OnHostMsgUpdateSurroundingText)
116 #if !defined(OS_NACL) 137 #if !defined(OS_NACL)
117 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ResolveRelativeToDocument, 138 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ResolveRelativeToDocument,
118 OnHostMsgResolveRelativeToDocument) 139 OnHostMsgResolveRelativeToDocument)
119 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DocumentCanRequest, 140 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DocumentCanRequest,
120 OnHostMsgDocumentCanRequest) 141 OnHostMsgDocumentCanRequest)
121 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DocumentCanAccessDocument, 142 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DocumentCanAccessDocument,
122 OnHostMsgDocumentCanAccessDocument) 143 OnHostMsgDocumentCanAccessDocument)
123 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetDocumentURL, 144 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetDocumentURL,
124 OnHostMsgGetDocumentURL) 145 OnHostMsgGetDocumentURL)
125 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetPluginInstanceURL, 146 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetPluginInstanceURL,
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 dispatcher()->Send(new PpapiHostMsg_PPBInstance_LockMouse( 451 dispatcher()->Send(new PpapiHostMsg_PPBInstance_LockMouse(
431 API_ID_PPB_INSTANCE, instance)); 452 API_ID_PPB_INSTANCE, instance));
432 return PP_OK_COMPLETIONPENDING; 453 return PP_OK_COMPLETIONPENDING;
433 } 454 }
434 455
435 void PPB_Instance_Proxy::UnlockMouse(PP_Instance instance) { 456 void PPB_Instance_Proxy::UnlockMouse(PP_Instance instance) {
436 dispatcher()->Send(new PpapiHostMsg_PPBInstance_UnlockMouse( 457 dispatcher()->Send(new PpapiHostMsg_PPBInstance_UnlockMouse(
437 API_ID_PPB_INSTANCE, instance)); 458 API_ID_PPB_INSTANCE, instance));
438 } 459 }
439 460
461 void PPB_Instance_Proxy::SetTextInputType(PP_Instance instance,
462 PP_TextInput_Type type) {
463 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SetTextInputType(
464 API_ID_PPB_INSTANCE, instance, type));
465 }
466
467 void PPB_Instance_Proxy::UpdateCaretPosition(PP_Instance instance,
468 const PP_Rect& caret,
469 const PP_Rect& bounding_box) {
470 dispatcher()->Send(new PpapiHostMsg_PPBInstance_UpdateCaretPosition(
471 API_ID_PPB_INSTANCE, instance, caret, bounding_box));
472 }
473
474 void PPB_Instance_Proxy::CancelCompositionText(PP_Instance instance) {
475 dispatcher()->Send(new PpapiHostMsg_PPBInstance_CancelCompositionText(
476 API_ID_PPB_INSTANCE, instance));
477 }
478
479 void PPB_Instance_Proxy::SelectionChanged(PP_Instance instance) {
480 // The "right" way to do this is to send the message to the host. However,
481 // all it will do it call RequestSurroundingText with a hardcoded number of
482 // characters in response, which is an entire IPC round-trip.
483 //
484 // We can avoid this round-trip by just implementing the
485 // RequestSurroundingText logic in the plugin process. If the logic in the
486 // host becomes more complex (like a more adaptive number of characters),
487 // we'll need to reevanuate whether we want to do the round trip instead.
488 //
489 // Be careful to post a task to avoid reentering the plugin.
490 MessageLoop::current()->PostTask(
491 FROM_HERE,
492 base::Bind(&RequestSurroundingText, instance));
493 }
494
495 void PPB_Instance_Proxy::UpdateSurroundingText(PP_Instance instance,
496 const char* text,
497 uint32_t caret,
498 uint32_t anchor) {
499 dispatcher()->Send(new PpapiHostMsg_PPBInstance_UpdateSurroundingText(
500 API_ID_PPB_INSTANCE, instance, text, caret, anchor));
501 }
502
440 void PPB_Instance_Proxy::OnHostMsgGetWindowObject( 503 void PPB_Instance_Proxy::OnHostMsgGetWindowObject(
441 PP_Instance instance, 504 PP_Instance instance,
442 SerializedVarReturnValue result) { 505 SerializedVarReturnValue result) {
443 EnterInstanceNoLock enter(instance, false); 506 EnterInstanceNoLock enter(instance);
444 if (enter.succeeded()) 507 if (enter.succeeded())
445 result.Return(dispatcher(), enter.functions()->GetWindowObject(instance)); 508 result.Return(dispatcher(), enter.functions()->GetWindowObject(instance));
446 } 509 }
447 510
448 void PPB_Instance_Proxy::OnHostMsgGetOwnerElementObject( 511 void PPB_Instance_Proxy::OnHostMsgGetOwnerElementObject(
449 PP_Instance instance, 512 PP_Instance instance,
450 SerializedVarReturnValue result) { 513 SerializedVarReturnValue result) {
451 EnterInstanceNoLock enter(instance, false); 514 EnterInstanceNoLock enter(instance);
452 if (enter.succeeded()) { 515 if (enter.succeeded()) {
453 result.Return(dispatcher(), 516 result.Return(dispatcher(),
454 enter.functions()->GetOwnerElementObject(instance)); 517 enter.functions()->GetOwnerElementObject(instance));
455 } 518 }
456 } 519 }
457 520
458 void PPB_Instance_Proxy::OnHostMsgBindGraphics(PP_Instance instance, 521 void PPB_Instance_Proxy::OnHostMsgBindGraphics(PP_Instance instance,
459 const HostResource& device, 522 const HostResource& device,
460 PP_Bool* result) { 523 PP_Bool* result) {
461 EnterInstanceNoLock enter(instance, false); 524 EnterInstanceNoLock enter(instance);
462 if (enter.succeeded()) { 525 if (enter.succeeded()) {
463 *result = enter.functions()->BindGraphics(instance, 526 *result = enter.functions()->BindGraphics(instance,
464 device.host_resource()); 527 device.host_resource());
465 } 528 }
466 } 529 }
467 530
468 void PPB_Instance_Proxy::OnHostMsgGetAudioHardwareOutputSampleRate( 531 void PPB_Instance_Proxy::OnHostMsgGetAudioHardwareOutputSampleRate(
469 PP_Instance instance, uint32_t* result) { 532 PP_Instance instance, uint32_t* result) {
470 EnterInstanceNoLock enter(instance, false); 533 EnterInstanceNoLock enter(instance);
471 if (enter.succeeded()) 534 if (enter.succeeded())
472 *result = enter.functions()->GetAudioHardwareOutputSampleRate(instance); 535 *result = enter.functions()->GetAudioHardwareOutputSampleRate(instance);
473 } 536 }
474 537
475 void PPB_Instance_Proxy::OnHostMsgGetAudioHardwareOutputBufferSize( 538 void PPB_Instance_Proxy::OnHostMsgGetAudioHardwareOutputBufferSize(
476 PP_Instance instance, uint32_t* result) { 539 PP_Instance instance, uint32_t* result) {
477 EnterInstanceNoLock enter(instance, false); 540 EnterInstanceNoLock enter(instance);
478 if (enter.succeeded()) 541 if (enter.succeeded())
479 *result = enter.functions()->GetAudioHardwareOutputBufferSize(instance); 542 *result = enter.functions()->GetAudioHardwareOutputBufferSize(instance);
480 } 543 }
481 544
482 void PPB_Instance_Proxy::OnHostMsgIsFullFrame(PP_Instance instance, 545 void PPB_Instance_Proxy::OnHostMsgIsFullFrame(PP_Instance instance,
483 PP_Bool* result) { 546 PP_Bool* result) {
484 EnterInstanceNoLock enter(instance, false); 547 EnterInstanceNoLock enter(instance);
485 if (enter.succeeded()) 548 if (enter.succeeded())
486 *result = enter.functions()->IsFullFrame(instance); 549 *result = enter.functions()->IsFullFrame(instance);
487 } 550 }
488 551
489 void PPB_Instance_Proxy::OnHostMsgExecuteScript( 552 void PPB_Instance_Proxy::OnHostMsgExecuteScript(
490 PP_Instance instance, 553 PP_Instance instance,
491 SerializedVarReceiveInput script, 554 SerializedVarReceiveInput script,
492 SerializedVarOutParam out_exception, 555 SerializedVarOutParam out_exception,
493 SerializedVarReturnValue result) { 556 SerializedVarReturnValue result) {
494 EnterInstanceNoLock enter(instance, false); 557 EnterInstanceNoLock enter(instance);
495 if (enter.failed()) 558 if (enter.failed())
496 return; 559 return;
497 560
498 if (dispatcher()->IsPlugin()) 561 if (dispatcher()->IsPlugin())
499 NOTREACHED(); 562 NOTREACHED();
500 else 563 else
501 static_cast<HostDispatcher*>(dispatcher())->set_allow_plugin_reentrancy(); 564 static_cast<HostDispatcher*>(dispatcher())->set_allow_plugin_reentrancy();
502 565
503 result.Return(dispatcher(), enter.functions()->ExecuteScript( 566 result.Return(dispatcher(), enter.functions()->ExecuteScript(
504 instance, 567 instance,
505 script.Get(dispatcher()), 568 script.Get(dispatcher()),
506 out_exception.OutParam(dispatcher()))); 569 out_exception.OutParam(dispatcher())));
507 } 570 }
508 571
509 void PPB_Instance_Proxy::OnHostMsgGetDefaultCharSet( 572 void PPB_Instance_Proxy::OnHostMsgGetDefaultCharSet(
510 PP_Instance instance, 573 PP_Instance instance,
511 SerializedVarReturnValue result) { 574 SerializedVarReturnValue result) {
512 EnterInstanceNoLock enter(instance, false); 575 EnterInstanceNoLock enter(instance);
513 if (enter.succeeded()) 576 if (enter.succeeded())
514 result.Return(dispatcher(), enter.functions()->GetDefaultCharSet(instance)); 577 result.Return(dispatcher(), enter.functions()->GetDefaultCharSet(instance));
515 } 578 }
516 579
517 void PPB_Instance_Proxy::OnHostMsgSetFullscreen(PP_Instance instance, 580 void PPB_Instance_Proxy::OnHostMsgSetFullscreen(PP_Instance instance,
518 PP_Bool fullscreen, 581 PP_Bool fullscreen,
519 PP_Bool* result) { 582 PP_Bool* result) {
520 EnterInstanceNoLock enter(instance, false); 583 EnterInstanceNoLock enter(instance);
521 if (enter.succeeded()) 584 if (enter.succeeded())
522 *result = enter.functions()->SetFullscreen(instance, fullscreen); 585 *result = enter.functions()->SetFullscreen(instance, fullscreen);
523 } 586 }
524 587
525 588
526 void PPB_Instance_Proxy::OnHostMsgGetScreenSize(PP_Instance instance, 589 void PPB_Instance_Proxy::OnHostMsgGetScreenSize(PP_Instance instance,
527 PP_Bool* result, 590 PP_Bool* result,
528 PP_Size* size) { 591 PP_Size* size) {
529 EnterInstanceNoLock enter(instance, false); 592 EnterInstanceNoLock enter(instance);
530 if (enter.succeeded()) 593 if (enter.succeeded())
531 *result = enter.functions()->GetScreenSize(instance, size); 594 *result = enter.functions()->GetScreenSize(instance, size);
532 } 595 }
533 596
534 void PPB_Instance_Proxy::OnHostMsgRequestInputEvents(PP_Instance instance, 597 void PPB_Instance_Proxy::OnHostMsgRequestInputEvents(PP_Instance instance,
535 bool is_filtering, 598 bool is_filtering,
536 uint32_t event_classes) { 599 uint32_t event_classes) {
537 EnterInstanceNoLock enter(instance, false); 600 EnterInstanceNoLock enter(instance);
538 if (enter.succeeded()) { 601 if (enter.succeeded()) {
539 if (is_filtering) 602 if (is_filtering)
540 enter.functions()->RequestFilteringInputEvents(instance, event_classes); 603 enter.functions()->RequestFilteringInputEvents(instance, event_classes);
541 else 604 else
542 enter.functions()->RequestInputEvents(instance, event_classes); 605 enter.functions()->RequestInputEvents(instance, event_classes);
543 } 606 }
544 } 607 }
545 608
546 void PPB_Instance_Proxy::OnHostMsgClearInputEvents(PP_Instance instance, 609 void PPB_Instance_Proxy::OnHostMsgClearInputEvents(PP_Instance instance,
547 uint32_t event_classes) { 610 uint32_t event_classes) {
548 EnterInstanceNoLock enter(instance, false); 611 EnterInstanceNoLock enter(instance);
549 if (enter.succeeded()) 612 if (enter.succeeded())
550 enter.functions()->ClearInputEventRequest(instance, event_classes); 613 enter.functions()->ClearInputEventRequest(instance, event_classes);
551 } 614 }
552 615
553 void PPB_Instance_Proxy::OnMsgHandleInputEventAck(PP_Instance instance, 616 void PPB_Instance_Proxy::OnMsgHandleInputEventAck(PP_Instance instance,
554 PP_TimeTicks timestamp) { 617 PP_TimeTicks timestamp) {
555 EnterInstanceNoLock enter(instance, false); 618 EnterInstanceNoLock enter(instance);
556 if (enter.succeeded()) 619 if (enter.succeeded())
557 enter.functions()->ClosePendingUserGesture(instance, timestamp); 620 enter.functions()->ClosePendingUserGesture(instance, timestamp);
558 } 621 }
559 622
560 void PPB_Instance_Proxy::OnHostMsgPostMessage( 623 void PPB_Instance_Proxy::OnHostMsgPostMessage(
561 PP_Instance instance, 624 PP_Instance instance,
562 SerializedVarReceiveInput message) { 625 SerializedVarReceiveInput message) {
563 EnterInstanceNoLock enter(instance, false); 626 EnterInstanceNoLock enter(instance);
564 if (enter.succeeded()) 627 if (enter.succeeded())
565 enter.functions()->PostMessage(instance, message.Get(dispatcher())); 628 enter.functions()->PostMessage(instance, message.Get(dispatcher()));
566 } 629 }
567 630
568 void PPB_Instance_Proxy::OnHostMsgLockMouse(PP_Instance instance) { 631 void PPB_Instance_Proxy::OnHostMsgLockMouse(PP_Instance instance) {
569 EnterHostFunctionForceCallback<PPB_Instance_FunctionAPI> enter( 632 EnterHostFunctionForceCallback<PPB_Instance_FunctionAPI> enter(
570 instance, 633 instance,
571 callback_factory_.NewCallback( 634 callback_factory_.NewCallback(
572 &PPB_Instance_Proxy::MouseLockCompleteInHost, 635 &PPB_Instance_Proxy::MouseLockCompleteInHost,
573 instance)); 636 instance));
574 if (enter.succeeded()) 637 if (enter.succeeded())
575 enter.SetResult(enter.functions()->LockMouse(instance, enter.callback())); 638 enter.SetResult(enter.functions()->LockMouse(instance, enter.callback()));
576 } 639 }
577 640
578 void PPB_Instance_Proxy::OnHostMsgUnlockMouse(PP_Instance instance) { 641 void PPB_Instance_Proxy::OnHostMsgUnlockMouse(PP_Instance instance) {
579 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, true); 642 EnterInstanceNoLock enter(instance);
580 if (enter.succeeded()) 643 if (enter.succeeded())
581 enter.functions()->UnlockMouse(instance); 644 enter.functions()->UnlockMouse(instance);
582 } 645 }
583 646
584 #if !defined(OS_NACL) 647 #if !defined(OS_NACL)
585 void PPB_Instance_Proxy::OnHostMsgResolveRelativeToDocument( 648 void PPB_Instance_Proxy::OnHostMsgResolveRelativeToDocument(
586 PP_Instance instance, 649 PP_Instance instance,
587 SerializedVarReceiveInput relative, 650 SerializedVarReceiveInput relative,
588 SerializedVarReturnValue result) { 651 SerializedVarReturnValue result) {
589 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, true); 652 EnterInstanceNoLock enter(instance);
590 if (enter.succeeded()) { 653 if (enter.succeeded()) {
591 result.Return(dispatcher(), 654 result.Return(dispatcher(),
592 enter.functions()->ResolveRelativeToDocument( 655 enter.functions()->ResolveRelativeToDocument(
593 instance, relative.Get(dispatcher()), NULL)); 656 instance, relative.Get(dispatcher()), NULL));
594 } 657 }
595 } 658 }
596 659
597 void PPB_Instance_Proxy::OnHostMsgDocumentCanRequest( 660 void PPB_Instance_Proxy::OnHostMsgDocumentCanRequest(
598 PP_Instance instance, 661 PP_Instance instance,
599 SerializedVarReceiveInput url, 662 SerializedVarReceiveInput url,
600 PP_Bool* result) { 663 PP_Bool* result) {
601 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, true); 664 EnterInstanceNoLock enter(instance);
602 if (enter.succeeded()) { 665 if (enter.succeeded()) {
603 *result = enter.functions()->DocumentCanRequest(instance, 666 *result = enter.functions()->DocumentCanRequest(instance,
604 url.Get(dispatcher())); 667 url.Get(dispatcher()));
605 } 668 }
606 } 669 }
607 670
608 void PPB_Instance_Proxy::OnHostMsgDocumentCanAccessDocument(PP_Instance active, 671 void PPB_Instance_Proxy::OnHostMsgDocumentCanAccessDocument(PP_Instance active,
609 PP_Instance target, 672 PP_Instance target,
610 PP_Bool* result) { 673 PP_Bool* result) {
611 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(active, true); 674 EnterInstanceNoLock enter(active);
612 if (enter.succeeded()) 675 if (enter.succeeded())
613 *result = enter.functions()->DocumentCanAccessDocument(active, target); 676 *result = enter.functions()->DocumentCanAccessDocument(active, target);
614 } 677 }
615 678
616 void PPB_Instance_Proxy::OnHostMsgGetDocumentURL(PP_Instance instance, 679 void PPB_Instance_Proxy::OnHostMsgGetDocumentURL(PP_Instance instance,
617 SerializedVarReturnValue result ) { 680 SerializedVarReturnValue result ) {
618 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, true); 681 EnterInstanceNoLock enter(instance);
619 if (enter.succeeded()) { 682 if (enter.succeeded()) {
620 result.Return(dispatcher(), 683 result.Return(dispatcher(),
621 enter.functions()->GetDocumentURL(instance, NULL)); 684 enter.functions()->GetDocumentURL(instance, NULL));
622 } 685 }
623 } 686 }
624 687
625 void PPB_Instance_Proxy::OnHostMsgGetPluginInstanceURL( 688 void PPB_Instance_Proxy::OnHostMsgGetPluginInstanceURL(
626 PP_Instance instance, 689 PP_Instance instance,
627 SerializedVarReturnValue result) { 690 SerializedVarReturnValue result) {
628 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, true); 691 EnterInstanceNoLock enter(instance);
629 if (enter.succeeded()) { 692 if (enter.succeeded()) {
630 result.Return(dispatcher(), 693 result.Return(dispatcher(),
631 enter.functions()->GetPluginInstanceURL(instance, NULL)); 694 enter.functions()->GetPluginInstanceURL(instance, NULL));
632 } 695 }
633 } 696 }
634 #endif // !defined(OS_NACL) 697 #endif // !defined(OS_NACL)
635 698
636 void PPB_Instance_Proxy::OnHostMsgSetCursor( 699 void PPB_Instance_Proxy::OnHostMsgSetCursor(
637 PP_Instance instance, 700 PP_Instance instance,
638 int32_t type, 701 int32_t type,
639 const ppapi::HostResource& custom_image, 702 const ppapi::HostResource& custom_image,
640 const PP_Point& hot_spot) { 703 const PP_Point& hot_spot) {
641 EnterInstanceNoLock enter(instance, true); 704 EnterInstanceNoLock enter(instance);
642 if (enter.succeeded()) { 705 if (enter.succeeded()) {
643 enter.functions()->SetCursor( 706 enter.functions()->SetCursor(
644 instance, static_cast<PP_MouseCursor_Type>(type), 707 instance, static_cast<PP_MouseCursor_Type>(type),
645 custom_image.host_resource(), &hot_spot); 708 custom_image.host_resource(), &hot_spot);
646 } 709 }
647 } 710 }
648 711
712 void PPB_Instance_Proxy::OnHostMsgSetTextInputType(PP_Instance instance,
713 PP_TextInput_Type type) {
714 EnterInstanceNoLock enter(instance);
715 if (enter.succeeded())
716 enter.functions()->SetTextInputType(instance, type);
717 }
718
719 void PPB_Instance_Proxy::OnHostMsgUpdateCaretPosition(
720 PP_Instance instance,
721 const PP_Rect& caret,
722 const PP_Rect& bounding_box) {
723 EnterInstanceNoLock enter(instance);
724 if (enter.succeeded())
725 enter.functions()->UpdateCaretPosition(instance, caret, bounding_box);
726 }
727
728 void PPB_Instance_Proxy::OnHostMsgCancelCompositionText(PP_Instance instance) {
729 EnterInstanceNoLock enter(instance);
730 if (enter.succeeded())
731 enter.functions()->CancelCompositionText(instance);
732 }
733
734 void PPB_Instance_Proxy::OnHostMsgUpdateSurroundingText(
735 PP_Instance instance,
736 const std::string& text,
737 uint32_t caret,
738 uint32_t anchor) {
739 EnterInstanceNoLock enter(instance);
740 if (enter.succeeded()) {
741 enter.functions()->UpdateSurroundingText(instance, text.c_str(), caret,
742 anchor);
743 }
744 }
745
649 void PPB_Instance_Proxy::OnPluginMsgMouseLockComplete(PP_Instance instance, 746 void PPB_Instance_Proxy::OnPluginMsgMouseLockComplete(PP_Instance instance,
650 int32_t result) { 747 int32_t result) {
651 // Save the mouse callback on the instance data. 748 // Save the mouse callback on the instance data.
652 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> 749 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())->
653 GetInstanceData(instance); 750 GetInstanceData(instance);
654 if (!data) 751 if (!data)
655 return; // Instance was probably deleted. 752 return; // Instance was probably deleted.
656 if (!data->mouse_lock_callback.func) { 753 if (!data->mouse_lock_callback.func) {
657 NOTREACHED(); 754 NOTREACHED();
658 return; 755 return;
659 } 756 }
660 PP_RunAndClearCompletionCallback(&data->mouse_lock_callback, result); 757 PP_RunAndClearCompletionCallback(&data->mouse_lock_callback, result);
661 } 758 }
662 759
663 void PPB_Instance_Proxy::MouseLockCompleteInHost(int32_t result, 760 void PPB_Instance_Proxy::MouseLockCompleteInHost(int32_t result,
664 PP_Instance instance) { 761 PP_Instance instance) {
665 dispatcher()->Send(new PpapiMsg_PPBInstance_MouseLockComplete( 762 dispatcher()->Send(new PpapiMsg_PPBInstance_MouseLockComplete(
666 API_ID_PPB_INSTANCE, instance, result)); 763 API_ID_PPB_INSTANCE, instance, result));
667 } 764 }
668 765
669 } // namespace proxy 766 } // namespace proxy
670 } // namespace ppapi 767 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698