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

Unified Diff: ppapi/proxy/ppb_text_input_proxy.cc

Issue 10053017: Request text context in the plugin process (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review comment Created 8 years, 8 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/ppb_text_input_proxy.h ('k') | ppapi/shared_impl/ppb_instance_shared.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/ppb_text_input_proxy.cc
diff --git a/ppapi/proxy/ppb_text_input_proxy.cc b/ppapi/proxy/ppb_text_input_proxy.cc
index e7434e07e68bcf07abcd9475da3db7f3ef69c661..3d2f873ba48ec8b2d58245d0e69eea838feadcd6 100644
--- a/ppapi/proxy/ppb_text_input_proxy.cc
+++ b/ppapi/proxy/ppb_text_input_proxy.cc
@@ -6,12 +6,32 @@
#include "ppapi/proxy/plugin_dispatcher.h"
#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/shared_impl/ppb_instance_shared.h"
#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/thunk.h"
namespace ppapi {
namespace proxy {
+namespace {
+
+void RequestSurroundingText(PP_Instance instance) {
+ PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
+ if (!dispatcher)
+ return; // Instance has gone away while message was pending.
+
+ // Just fake out a RequestSurroundingText message to the proxy for the PPP
+ // interface.
+ InterfaceProxy* proxy = dispatcher->GetInterfaceProxy(API_ID_PPB_TEXT_INPUT);
+ if (!proxy)
+ return;
+ proxy->OnMessageReceived(PpapiMsg_PPPTextInput_RequestSurroundingText(
+ API_ID_PPP_TEXT_INPUT, instance,
+ PPB_Instance_Shared::kExtraCharsForTextInput));
+}
+
+} // namespace
+
PPB_TextInput_Proxy::PPB_TextInput_Proxy(Dispatcher* dispatcher)
: InterfaceProxy(dispatcher) {
}
@@ -43,8 +63,19 @@ void PPB_TextInput_Proxy::CancelCompositionText(PP_Instance instance) {
}
void PPB_TextInput_Proxy::SelectionChanged(PP_Instance instance) {
- dispatcher()->Send(new PpapiHostMsg_PPBTextInput_SelectionChanged(
- API_ID_PPB_TEXT_INPUT, instance));
+ // The "right" way to do this is to send the message to the host. However,
+ // all it will do it call RequestSurroundingText with a hardcoded number of
+ // characters in response, which is an entire IPC round-trip.
+ //
+ // We can avoid this round-trip by just implementing the
+ // RequestSurroundingText logic in the plugin process. If the logic in the
+ // host becomes more complex (like a more adaptive number of characters),
+ // we'll need to reevanuate whether we want to do the round trip instead.
+ //
+ // Be careful to post a task to avoid reentering the plugin.
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&RequestSurroundingText, instance));
}
void PPB_TextInput_Proxy::UpdateSurroundingText(PP_Instance instance,
@@ -64,8 +95,6 @@ bool PPB_TextInput_Proxy::OnMessageReceived(const IPC::Message& msg) {
OnMsgUpdateCaretPosition)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTextInput_CancelCompositionText,
OnMsgCancelCompositionText)
- IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTextInput_SelectionChanged,
- OnMsgSelectionChanged)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTextInput_UpdateSurroundingText,
OnMsgUpdateSurroundingText)
IPC_MESSAGE_UNHANDLED(handled = false)
@@ -97,13 +126,6 @@ void PPB_TextInput_Proxy::OnMsgCancelCompositionText(PP_Instance instance) {
enter.functions()->CancelCompositionText(instance);
}
-void PPB_TextInput_Proxy::OnMsgSelectionChanged(PP_Instance instance) {
- ppapi::thunk::EnterFunctionNoLock<PPB_TextInput_FunctionAPI> enter(instance,
- true);
- if (enter.succeeded())
- enter.functions()->SelectionChanged(instance);
-}
-
void PPB_TextInput_Proxy::OnMsgUpdateSurroundingText(PP_Instance instance,
const std::string& text,
uint32_t caret,
« no previous file with comments | « ppapi/proxy/ppb_text_input_proxy.h ('k') | ppapi/shared_impl/ppb_instance_shared.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698