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

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

Issue 18671004: PPAPI: Move IMEInputEvent and TextInput to stable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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/ppp_text_input_proxy.h" 5 #include "ppapi/proxy/ppp_text_input_proxy.h"
6 6
7 #include "ppapi/c/dev/ppp_text_input_dev.h" 7 #include "ppapi/c/ppp_text_input.h"
8 #include "ppapi/proxy/host_dispatcher.h" 8 #include "ppapi/proxy/host_dispatcher.h"
9 #include "ppapi/proxy/ppapi_messages.h" 9 #include "ppapi/proxy/ppapi_messages.h"
10 #include "ppapi/shared_impl/proxy_lock.h" 10 #include "ppapi/shared_impl/proxy_lock.h"
11 11
12 namespace ppapi { 12 namespace ppapi {
13 namespace proxy { 13 namespace proxy {
14 14
15 namespace { 15 namespace {
16 16
17 #if !defined(OS_NACL) 17 #if !defined(OS_NACL)
18 void RequestSurroundingText(PP_Instance instance, 18 void RequestSurroundingText(PP_Instance instance,
19 uint32_t desired_number_of_characters) { 19 uint32_t desired_number_of_characters) {
20 proxy::HostDispatcher* dispatcher = 20 proxy::HostDispatcher* dispatcher =
21 proxy::HostDispatcher::GetForInstance(instance); 21 proxy::HostDispatcher::GetForInstance(instance);
22 if (!dispatcher) { 22 if (!dispatcher) {
23 // The dispatcher should always be valid. 23 // The dispatcher should always be valid.
24 NOTREACHED(); 24 NOTREACHED();
25 return; 25 return;
26 } 26 }
27 27
28 dispatcher->Send(new PpapiMsg_PPPTextInput_RequestSurroundingText( 28 dispatcher->Send(new PpapiMsg_PPPTextInput_RequestSurroundingText(
29 API_ID_PPP_TEXT_INPUT, instance, desired_number_of_characters)); 29 API_ID_PPP_TEXT_INPUT, instance, desired_number_of_characters));
30 } 30 }
31 31
32 const PPP_TextInput_Dev g_ppp_text_input_thunk = { 32 const PPP_TextInput g_ppp_text_input_thunk = {
33 &RequestSurroundingText 33 &RequestSurroundingText
34 }; 34 };
35 #else 35 #else
36 // The NaCl plugin doesn't need the host side interface - stub it out. 36 // The NaCl plugin doesn't need the host side interface - stub it out.
37 static const PPP_TextInput_Dev g_ppp_text_input_thunk = {}; 37 static const PPP_TextInput g_ppp_text_input_thunk = {};
38 #endif // !defined(OS_NACL) 38 #endif // !defined(OS_NACL)
39 39
40 } // namespace 40 } // namespace
41 41
42 // static 42 // static
43 const PPP_TextInput_Dev* PPP_TextInput_Proxy::GetProxyInterface() { 43 const PPP_TextInput* PPP_TextInput_Proxy::GetProxyInterface() {
44 return &g_ppp_text_input_thunk; 44 return &g_ppp_text_input_thunk;
45 } 45 }
46 46
47 PPP_TextInput_Proxy::PPP_TextInput_Proxy(Dispatcher* dispatcher) 47 PPP_TextInput_Proxy::PPP_TextInput_Proxy(Dispatcher* dispatcher)
48 : InterfaceProxy(dispatcher), 48 : InterfaceProxy(dispatcher),
49 ppp_text_input_impl_(NULL) { 49 ppp_text_input_impl_(NULL) {
50 if (dispatcher->IsPlugin()) { 50 if (dispatcher->IsPlugin()) {
51 ppp_text_input_impl_ = static_cast<const PPP_TextInput_Dev*>( 51 ppp_text_input_impl_ = static_cast<const PPP_TextInput*>(
52 dispatcher->local_get_interface()(PPP_TEXTINPUT_DEV_INTERFACE)); 52 dispatcher->local_get_interface()(PPP_TEXTINPUT_INTERFACE));
53 } 53 }
54 } 54 }
55 55
56 PPP_TextInput_Proxy::~PPP_TextInput_Proxy() { 56 PPP_TextInput_Proxy::~PPP_TextInput_Proxy() {
57 } 57 }
58 58
59 bool PPP_TextInput_Proxy::OnMessageReceived(const IPC::Message& msg) { 59 bool PPP_TextInput_Proxy::OnMessageReceived(const IPC::Message& msg) {
60 if (!dispatcher()->IsPlugin()) 60 if (!dispatcher()->IsPlugin())
61 return false; 61 return false;
62 62
63 bool handled = true; 63 bool handled = true;
64 IPC_BEGIN_MESSAGE_MAP(PPP_TextInput_Proxy, msg) 64 IPC_BEGIN_MESSAGE_MAP(PPP_TextInput_Proxy, msg)
65 IPC_MESSAGE_HANDLER(PpapiMsg_PPPTextInput_RequestSurroundingText, 65 IPC_MESSAGE_HANDLER(PpapiMsg_PPPTextInput_RequestSurroundingText,
66 OnMsgRequestSurroundingText) 66 OnMsgRequestSurroundingText)
67 IPC_MESSAGE_UNHANDLED(handled = false) 67 IPC_MESSAGE_UNHANDLED(handled = false)
68 IPC_END_MESSAGE_MAP() 68 IPC_END_MESSAGE_MAP()
69 return handled; 69 return handled;
70 } 70 }
71 71
72 void PPP_TextInput_Proxy::OnMsgRequestSurroundingText( 72 void PPP_TextInput_Proxy::OnMsgRequestSurroundingText(
73 PP_Instance instance, uint32_t desired_number_of_characters) { 73 PP_Instance instance, uint32_t desired_number_of_characters) {
74 if (ppp_text_input_impl_) { 74 if (ppp_text_input_impl_) {
75 CallWhileUnlocked(ppp_text_input_impl_->RequestSurroundingText, 75 CallWhileUnlocked(ppp_text_input_impl_->RequestSurroundingText,
76 instance, desired_number_of_characters); 76 instance, desired_number_of_characters);
77 } 77 }
78 } 78 }
79 79
80 } // namespace proxy 80 } // namespace proxy
81 } // namespace ppapi 81 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698