OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "ppapi/proxy/ppp_text_input_proxy.h" |
| 6 |
| 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" |
| 11 |
| 12 namespace ppapi { |
| 13 namespace proxy { |
| 14 |
| 15 namespace { |
| 16 |
| 17 void RequestSurroundingText(PP_Instance instance, |
| 18 uint32_t desired_number_of_characters) { |
| 19 proxy::HostDispatcher* dispatcher = |
| 20 proxy::HostDispatcher::GetForInstance(instance); |
| 21 if (!dispatcher) { |
| 22 // The dispatcher should always be valid. |
| 23 NOTREACHED(); |
| 24 return; |
| 25 } |
| 26 |
| 27 dispatcher->Send(new PpapiMsg_PPPTextInput_RequestSurroundingText( |
| 28 API_ID_PPP_TEXT_INPUT, instance, desired_number_of_characters)); |
| 29 } |
| 30 |
| 31 const PPP_TextInput_Dev g_ppp_text_input_thunk = { |
| 32 &RequestSurroundingText |
| 33 }; |
| 34 |
| 35 } // namespace |
| 36 |
| 37 // static |
| 38 const PPP_TextInput_Dev* PPP_TextInput_Proxy::GetProxyInterface() { |
| 39 return &g_ppp_text_input_thunk; |
| 40 } |
| 41 |
| 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)); |
| 48 } |
| 49 } |
| 50 |
| 51 PPP_TextInput_Proxy::~PPP_TextInput_Proxy() { |
| 52 } |
| 53 |
| 54 bool PPP_TextInput_Proxy::OnMessageReceived(const IPC::Message& msg) { |
| 55 bool handled = true; |
| 56 IPC_BEGIN_MESSAGE_MAP(PPP_TextInput_Proxy, msg) |
| 57 IPC_MESSAGE_HANDLER(PpapiMsg_PPPTextInput_RequestSurroundingText, |
| 58 OnMsgRequestSurroundingText) |
| 59 IPC_MESSAGE_UNHANDLED(handled = false) |
| 60 IPC_END_MESSAGE_MAP() |
| 61 return handled; |
| 62 } |
| 63 |
| 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); |
| 69 } |
| 70 } |
| 71 |
| 72 } // namespace proxy |
| 73 } // namespace ppapi |
OLD | NEW |