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

Unified Diff: ppapi/proxy/ppp_text_input_proxy.cc

Issue 8769003: Pepper IME API for surrounding text retrieval. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge master. Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/proxy/ppp_text_input_proxy.h ('k') | ppapi/shared_impl/api_id.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/ppp_text_input_proxy.cc
diff --git a/ppapi/proxy/ppp_text_input_proxy.cc b/ppapi/proxy/ppp_text_input_proxy.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8a8254a40872a5e6db1d7717b105d2e6bbef83b0
--- /dev/null
+++ b/ppapi/proxy/ppp_text_input_proxy.cc
@@ -0,0 +1,73 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ppapi/proxy/ppp_text_input_proxy.h"
+
+#include "ppapi/c/dev/ppp_text_input_dev.h"
+#include "ppapi/proxy/host_dispatcher.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/shared_impl/proxy_lock.h"
+
+namespace ppapi {
+namespace proxy {
+
+namespace {
+
+void RequestSurroundingText(PP_Instance instance,
+ uint32_t desired_number_of_characters) {
+ proxy::HostDispatcher* dispatcher =
+ proxy::HostDispatcher::GetForInstance(instance);
+ if (!dispatcher) {
+ // The dispatcher should always be valid.
+ NOTREACHED();
+ return;
+ }
+
+ dispatcher->Send(new PpapiMsg_PPPTextInput_RequestSurroundingText(
+ API_ID_PPP_TEXT_INPUT, instance, desired_number_of_characters));
+}
+
+const PPP_TextInput_Dev g_ppp_text_input_thunk = {
+ &RequestSurroundingText
+};
+
+} // namespace
+
+// static
+const PPP_TextInput_Dev* PPP_TextInput_Proxy::GetProxyInterface() {
+ return &g_ppp_text_input_thunk;
+}
+
+PPP_TextInput_Proxy::PPP_TextInput_Proxy(Dispatcher* dispatcher)
+ : InterfaceProxy(dispatcher),
+ ppp_text_input_impl_(NULL) {
+ if (dispatcher->IsPlugin()) {
+ ppp_text_input_impl_ = static_cast<const PPP_TextInput_Dev*>(
+ dispatcher->local_get_interface()(PPP_TEXTINPUT_DEV_INTERFACE));
+ }
+}
+
+PPP_TextInput_Proxy::~PPP_TextInput_Proxy() {
+}
+
+bool PPP_TextInput_Proxy::OnMessageReceived(const IPC::Message& msg) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(PPP_TextInput_Proxy, msg)
+ IPC_MESSAGE_HANDLER(PpapiMsg_PPPTextInput_RequestSurroundingText,
+ OnMsgRequestSurroundingText)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+void PPP_TextInput_Proxy::OnMsgRequestSurroundingText(
+ PP_Instance instance, uint32_t desired_number_of_characters) {
+ if (ppp_text_input_impl_) {
+ CallWhileUnlocked(ppp_text_input_impl_->RequestSurroundingText,
+ instance, desired_number_of_characters);
+ }
+}
+
+} // namespace proxy
+} // namespace ppapi
« no previous file with comments | « ppapi/proxy/ppp_text_input_proxy.h ('k') | ppapi/shared_impl/api_id.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698