Revert 168224 - Update V8 to version 3.15.4.
[chromium-blink-merge.git] / ppapi / proxy / ppp_text_input_proxy.cc
blob8a8254a40872a5e6db1d7717b105d2e6bbef83b0
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"
12 namespace ppapi {
13 namespace proxy {
15 namespace {
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;
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
35 } // namespace
37 // static
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) {
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;
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);
72 } // namespace proxy
73 } // namespace ppapi