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

Side by Side Diff: content/renderer/webplugin_delegate_proxy.cc

Issue 7082034: Send IME events to windowless plug-ins (Chromium side) (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/renderer/webplugin_delegate_proxy.h ('k') | webkit/glue/webkit_glue.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/webplugin_delegate_proxy.h" 5 #include "content/renderer/webplugin_delegate_proxy.h"
6 6
7 #if defined(TOOLKIT_USES_GTK) 7 #if defined(TOOLKIT_USES_GTK)
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #elif defined(USE_X11) 9 #elif defined(USE_X11)
10 #include <cairo/cairo.h> 10 #include <cairo/cairo.h>
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 WebPluginDelegateProxy::~WebPluginDelegateProxy() { 183 WebPluginDelegateProxy::~WebPluginDelegateProxy() {
184 if (npobject_) 184 if (npobject_)
185 WebBindings::releaseObject(npobject_); 185 WebBindings::releaseObject(npobject_);
186 } 186 }
187 187
188 WebPluginDelegateProxy::SharedBitmap::SharedBitmap() {} 188 WebPluginDelegateProxy::SharedBitmap::SharedBitmap() {}
189 189
190 WebPluginDelegateProxy::SharedBitmap::~SharedBitmap() {} 190 WebPluginDelegateProxy::SharedBitmap::~SharedBitmap() {}
191 191
192 void WebPluginDelegateProxy::PluginDestroyed() { 192 void WebPluginDelegateProxy::PluginDestroyed() {
193 #if defined(OS_MACOSX) 193 #if defined(OS_MACOSX) || defined(OS_WIN)
194 // Ensure that the renderer doesn't think the plugin still has focus. 194 // Ensure that the renderer doesn't think the plugin still has focus.
195 if (render_view_) 195 if (render_view_)
196 render_view_->PluginFocusChanged(false, instance_id_); 196 render_view_->PluginFocusChanged(false, instance_id_);
197 #endif 197 #endif
198 198
199 if (window_) 199 if (window_)
200 WillDestroyWindow(); 200 WillDestroyWindow();
201 201
202 if (render_view_) 202 if (render_view_)
203 render_view_->UnregisterPluginDelegate(this); 203 render_view_->UnregisterPluginDelegate(this);
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 418
419 bool WebPluginDelegateProxy::OnMessageReceived(const IPC::Message& msg) { 419 bool WebPluginDelegateProxy::OnMessageReceived(const IPC::Message& msg) {
420 content::GetContentClient()->SetActiveURL(page_url_); 420 content::GetContentClient()->SetActiveURL(page_url_);
421 421
422 bool handled = true; 422 bool handled = true;
423 IPC_BEGIN_MESSAGE_MAP(WebPluginDelegateProxy, msg) 423 IPC_BEGIN_MESSAGE_MAP(WebPluginDelegateProxy, msg)
424 IPC_MESSAGE_HANDLER(PluginHostMsg_SetWindow, OnSetWindow) 424 IPC_MESSAGE_HANDLER(PluginHostMsg_SetWindow, OnSetWindow)
425 #if defined(OS_WIN) 425 #if defined(OS_WIN)
426 IPC_MESSAGE_HANDLER(PluginHostMsg_SetWindowlessPumpEvent, 426 IPC_MESSAGE_HANDLER(PluginHostMsg_SetWindowlessPumpEvent,
427 OnSetWindowlessPumpEvent) 427 OnSetWindowlessPumpEvent)
428 IPC_MESSAGE_HANDLER(PluginHostMsg_NotifyIMEStatus,
429 OnNotifyIMEStatus)
428 #endif 430 #endif
429 IPC_MESSAGE_HANDLER(PluginHostMsg_CancelResource, OnCancelResource) 431 IPC_MESSAGE_HANDLER(PluginHostMsg_CancelResource, OnCancelResource)
430 IPC_MESSAGE_HANDLER(PluginHostMsg_InvalidateRect, OnInvalidateRect) 432 IPC_MESSAGE_HANDLER(PluginHostMsg_InvalidateRect, OnInvalidateRect)
431 IPC_MESSAGE_HANDLER(PluginHostMsg_GetWindowScriptNPObject, 433 IPC_MESSAGE_HANDLER(PluginHostMsg_GetWindowScriptNPObject,
432 OnGetWindowScriptNPObject) 434 OnGetWindowScriptNPObject)
433 IPC_MESSAGE_HANDLER(PluginHostMsg_GetPluginElement, 435 IPC_MESSAGE_HANDLER(PluginHostMsg_GetPluginElement,
434 OnGetPluginElement) 436 OnGetPluginElement)
435 IPC_MESSAGE_HANDLER(PluginHostMsg_ResolveProxy, OnResolveProxy) 437 IPC_MESSAGE_HANDLER(PluginHostMsg_ResolveProxy, OnResolveProxy)
436 IPC_MESSAGE_HANDLER(PluginHostMsg_SetCookie, OnSetCookie) 438 IPC_MESSAGE_HANDLER(PluginHostMsg_SetCookie, OnSetCookie)
437 IPC_MESSAGE_HANDLER(PluginHostMsg_GetCookies, OnGetCookies) 439 IPC_MESSAGE_HANDLER(PluginHostMsg_GetCookies, OnGetCookies)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 if (window_) { 477 if (window_) {
476 // The actual WebPluginDelegate never got a chance to tell the WebPlugin 478 // The actual WebPluginDelegate never got a chance to tell the WebPlugin
477 // its window was going away. Do it on its behalf. 479 // its window was going away. Do it on its behalf.
478 WillDestroyWindow(); 480 WillDestroyWindow();
479 } 481 }
480 plugin_->Invalidate(); 482 plugin_->Invalidate();
481 } 483 }
482 if (!channel_host_->expecting_shutdown()) 484 if (!channel_host_->expecting_shutdown())
483 render_view_->PluginCrashed(info_.path); 485 render_view_->PluginCrashed(info_.path);
484 486
485 #if defined(OS_MACOSX) 487 #if defined(OS_MACOSX) || defined(OS_WIN)
486 // Ensure that the renderer doesn't think the plugin still has focus. 488 // Ensure that the renderer doesn't think the plugin still has focus.
487 if (render_view_) 489 if (render_view_)
488 render_view_->PluginFocusChanged(false, instance_id_); 490 render_view_->PluginFocusChanged(false, instance_id_);
489 #endif 491 #endif
490 } 492 }
491 493
492 static void CopyTransportDIBHandleForMessage( 494 static void CopyTransportDIBHandleForMessage(
493 const TransportDIB::Handle& handle_in, 495 const TransportDIB::Handle& handle_in,
494 TransportDIB::Handle* handle_out) { 496 TransportDIB::Handle* handle_out) {
495 #if defined(OS_MACOSX) 497 #if defined(OS_MACOSX)
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 } 934 }
933 935
934 void WebPluginDelegateProxy::DidFinishLoadWithReason( 936 void WebPluginDelegateProxy::DidFinishLoadWithReason(
935 const GURL& url, NPReason reason, int notify_id) { 937 const GURL& url, NPReason reason, int notify_id) {
936 Send(new PluginMsg_DidFinishLoadWithReason( 938 Send(new PluginMsg_DidFinishLoadWithReason(
937 instance_id_, url, reason, notify_id)); 939 instance_id_, url, reason, notify_id));
938 } 940 }
939 941
940 void WebPluginDelegateProxy::SetFocus(bool focused) { 942 void WebPluginDelegateProxy::SetFocus(bool focused) {
941 Send(new PluginMsg_SetFocus(instance_id_, focused)); 943 Send(new PluginMsg_SetFocus(instance_id_, focused));
944 #if defined(OS_WIN)
945 if (render_view_)
946 render_view_->PluginFocusChanged(focused, instance_id_);
947 #endif
942 } 948 }
943 949
944 bool WebPluginDelegateProxy::HandleInputEvent( 950 bool WebPluginDelegateProxy::HandleInputEvent(
945 const WebInputEvent& event, 951 const WebInputEvent& event,
946 WebCursorInfo* cursor_info) { 952 WebCursorInfo* cursor_info) {
947 bool handled; 953 bool handled;
948 WebCursor cursor; 954 WebCursor cursor;
949 // A windowless plugin can enter a modal loop in the context of a 955 // A windowless plugin can enter a modal loop in the context of a
950 // NPP_HandleEvent call, in which case we need to pump messages to 956 // NPP_HandleEvent call, in which case we need to pump messages to
951 // the plugin. We pass of the corresponding event handle to the 957 // the plugin. We pass of the corresponding event handle to the
(...skipping 12 matching lines...) Expand all
964 970
965 void WebPluginDelegateProxy::SetContentAreaFocus(bool has_focus) { 971 void WebPluginDelegateProxy::SetContentAreaFocus(bool has_focus) {
966 IPC::Message* msg = new PluginMsg_SetContentAreaFocus(instance_id_, 972 IPC::Message* msg = new PluginMsg_SetContentAreaFocus(instance_id_,
967 has_focus); 973 has_focus);
968 // Make sure focus events are delivered in the right order relative to 974 // Make sure focus events are delivered in the right order relative to
969 // sync messages they might interact with (Paint, HandleEvent, etc.). 975 // sync messages they might interact with (Paint, HandleEvent, etc.).
970 msg->set_unblock(true); 976 msg->set_unblock(true);
971 Send(msg); 977 Send(msg);
972 } 978 }
973 979
980 #if defined(OS_WIN)
981 void WebPluginDelegateProxy::ImeCompositionUpdated(
982 const string16& text,
983 const std::vector<int>& clauses,
984 const std::vector<int>& target,
985 int cursor_position,
986 int plugin_id) {
987 // Dispatch the raw IME data if this plug-in is the focused one.
988 if (instance_id_ != plugin_id)
989 return;
990
991 IPC::Message* msg = new PluginMsg_ImeCompositionUpdated(instance_id_,
992 text, clauses, target, cursor_position);
993 msg->set_unblock(true);
994 Send(msg);
995 }
996
997 void WebPluginDelegateProxy::ImeCompositionCompleted(const string16& text,
998 int plugin_id) {
999 // Dispatch the IME text if this plug-in is the focused one.
1000 if (instance_id_ != plugin_id)
1001 return;
1002
1003 IPC::Message* msg = new PluginMsg_ImeCompositionCompleted(instance_id_, text);
1004 msg->set_unblock(true);
1005 Send(msg);
1006 }
1007 #endif
1008
974 #if defined(OS_MACOSX) 1009 #if defined(OS_MACOSX)
975 void WebPluginDelegateProxy::SetWindowFocus(bool window_has_focus) { 1010 void WebPluginDelegateProxy::SetWindowFocus(bool window_has_focus) {
976 IPC::Message* msg = new PluginMsg_SetWindowFocus(instance_id_, 1011 IPC::Message* msg = new PluginMsg_SetWindowFocus(instance_id_,
977 window_has_focus); 1012 window_has_focus);
978 // Make sure focus events are delivered in the right order relative to 1013 // Make sure focus events are delivered in the right order relative to
979 // sync messages they might interact with (Paint, HandleEvent, etc.). 1014 // sync messages they might interact with (Paint, HandleEvent, etc.).
980 msg->set_unblock(true); 1015 msg->set_unblock(true);
981 Send(msg); 1016 Send(msg);
982 } 1017 }
983 1018
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 DCHECK(modal_loop_pump_messages_event_ == NULL); 1084 DCHECK(modal_loop_pump_messages_event_ == NULL);
1050 1085
1051 // Bug 25583: this can be null because some "virus scanners" block the 1086 // Bug 25583: this can be null because some "virus scanners" block the
1052 // DuplicateHandle call in the plugin process. 1087 // DuplicateHandle call in the plugin process.
1053 if (!modal_loop_pump_messages_event) 1088 if (!modal_loop_pump_messages_event)
1054 return; 1089 return;
1055 1090
1056 modal_loop_pump_messages_event_.reset( 1091 modal_loop_pump_messages_event_.reset(
1057 new base::WaitableEvent(modal_loop_pump_messages_event)); 1092 new base::WaitableEvent(modal_loop_pump_messages_event));
1058 } 1093 }
1094
1095 void WebPluginDelegateProxy::OnNotifyIMEStatus(int input_type,
1096 const gfx::Rect& caret_rect) {
1097 if (!render_view_)
1098 return;
1099
1100 render_view_->Send(new ViewHostMsg_ImeUpdateTextInputState(
1101 render_view_->routing_id(),
1102 static_cast<ui::TextInputType>(input_type),
1103 true,
1104 caret_rect));
1105 }
1059 #endif 1106 #endif
1060 1107
1061 void WebPluginDelegateProxy::OnCancelResource(int id) { 1108 void WebPluginDelegateProxy::OnCancelResource(int id) {
1062 if (plugin_) 1109 if (plugin_)
1063 plugin_->CancelResource(id); 1110 plugin_->CancelResource(id);
1064 } 1111 }
1065 1112
1066 void WebPluginDelegateProxy::OnInvalidateRect(const gfx::Rect& rect, 1113 void WebPluginDelegateProxy::OnInvalidateRect(const gfx::Rect& rect,
1067 bool allow_buffer_flipping) { 1114 bool allow_buffer_flipping) {
1068 if (!plugin_) 1115 if (!plugin_)
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
1391 } 1438 }
1392 #endif 1439 #endif
1393 1440
1394 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, 1441 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow,
1395 int resource_id) { 1442 int resource_id) {
1396 if (!plugin_) 1443 if (!plugin_)
1397 return; 1444 return;
1398 1445
1399 plugin_->URLRedirectResponse(allow, resource_id); 1446 plugin_->URLRedirectResponse(allow, resource_id);
1400 } 1447 }
OLDNEW
« no previous file with comments | « content/renderer/webplugin_delegate_proxy.h ('k') | webkit/glue/webkit_glue.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698