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
3 // found in the LICENSE file.
5 #include "ppapi/proxy/ppp_text_input_proxy.h"
7 #include "ppapi/c/dev/ppp_text_input_dev.h"
8 #include "ppapi/proxy/host_dispatcher.h"
9 #include "ppapi/proxy/ppapi_messages.h"
10 #include "ppapi/shared_impl/proxy_lock.h"
17 void RequestSurroundingText(PP_Instance instance
,
18 uint32_t desired_number_of_characters
) {
19 proxy::HostDispatcher
* dispatcher
=
20 proxy::HostDispatcher::GetForInstance(instance
);
22 // The dispatcher should always be valid.
27 dispatcher
->Send(new PpapiMsg_PPPTextInput_RequestSurroundingText(
28 API_ID_PPP_TEXT_INPUT
, instance
, desired_number_of_characters
));
31 const PPP_TextInput_Dev g_ppp_text_input_thunk
= {
32 &RequestSurroundingText
38 const PPP_TextInput_Dev
* PPP_TextInput_Proxy::GetProxyInterface() {
39 return &g_ppp_text_input_thunk
;
42 PPP_TextInput_Proxy::PPP_TextInput_Proxy(Dispatcher
* dispatcher
)
43 : InterfaceProxy(dispatcher
),
44 ppp_text_input_impl_(NULL
) {
45 if (dispatcher
->IsPlugin()) {
46 ppp_text_input_impl_
= static_cast<const PPP_TextInput_Dev
*>(
47 dispatcher
->local_get_interface()(PPP_TEXTINPUT_DEV_INTERFACE
));
51 PPP_TextInput_Proxy::~PPP_TextInput_Proxy() {
54 bool PPP_TextInput_Proxy::OnMessageReceived(const IPC::Message
& msg
) {
56 IPC_BEGIN_MESSAGE_MAP(PPP_TextInput_Proxy
, msg
)
57 IPC_MESSAGE_HANDLER(PpapiMsg_PPPTextInput_RequestSurroundingText
,
58 OnMsgRequestSurroundingText
)
59 IPC_MESSAGE_UNHANDLED(handled
= false)
64 void PPP_TextInput_Proxy::OnMsgRequestSurroundingText(
65 PP_Instance instance
, uint32_t desired_number_of_characters
) {
66 if (ppp_text_input_impl_
) {
67 CallWhileUnlocked(ppp_text_input_impl_
->RequestSurroundingText
,
68 instance
, desired_number_of_characters
);