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

Side by Side Diff: content/browser/browser_plugin/browser_plugin_guest.cc

Issue 103403006: Implement Input Method related WebPlugin interface for browser plugin (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: minor fix (check rwhv and return early) Created 7 years 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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/browser/browser_plugin/browser_plugin_guest.h" 5 #include "content/browser/browser_plugin/browser_plugin_guest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_BuffersSwappedACK, 506 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_BuffersSwappedACK,
507 OnSwapBuffersACK) 507 OnSwapBuffersACK)
508 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CompositorFrameACK, 508 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CompositorFrameACK,
509 OnCompositorFrameACK) 509 OnCompositorFrameACK)
510 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_DragStatusUpdate, 510 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_DragStatusUpdate,
511 OnDragStatusUpdate) 511 OnDragStatusUpdate)
512 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ExecuteEditCommand, 512 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ExecuteEditCommand,
513 OnExecuteEditCommand) 513 OnExecuteEditCommand)
514 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_HandleInputEvent, 514 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_HandleInputEvent,
515 OnHandleInputEvent) 515 OnHandleInputEvent)
516 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ImeConfirmComposition,
517 OnImeConfirmComposition)
518 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ImeSetComposition,
519 OnImeSetComposition)
516 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_LockMouse_ACK, OnLockMouseAck) 520 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_LockMouse_ACK, OnLockMouseAck)
517 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_NavigateGuest, OnNavigateGuest) 521 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_NavigateGuest, OnNavigateGuest)
518 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginDestroyed, OnPluginDestroyed) 522 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginDestroyed, OnPluginDestroyed)
519 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ReclaimCompositorResources, 523 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ReclaimCompositorResources,
520 OnReclaimCompositorResources) 524 OnReclaimCompositorResources)
521 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ResizeGuest, OnResizeGuest) 525 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ResizeGuest, OnResizeGuest)
522 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetAutoSize, OnSetSize) 526 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetAutoSize, OnSetSize)
523 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent, 527 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent,
524 OnSetEditCommandsForNextKeyEvent) 528 OnSetEditCommandsForNextKeyEvent)
525 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetFocus, OnSetFocus) 529 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetFocus, OnSetFocus)
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 1112
1109 // static 1113 // static
1110 bool BrowserPluginGuest::ShouldForwardToBrowserPluginGuest( 1114 bool BrowserPluginGuest::ShouldForwardToBrowserPluginGuest(
1111 const IPC::Message& message) { 1115 const IPC::Message& message) {
1112 switch (message.type()) { 1116 switch (message.type()) {
1113 case BrowserPluginHostMsg_BuffersSwappedACK::ID: 1117 case BrowserPluginHostMsg_BuffersSwappedACK::ID:
1114 case BrowserPluginHostMsg_CompositorFrameACK::ID: 1118 case BrowserPluginHostMsg_CompositorFrameACK::ID:
1115 case BrowserPluginHostMsg_DragStatusUpdate::ID: 1119 case BrowserPluginHostMsg_DragStatusUpdate::ID:
1116 case BrowserPluginHostMsg_ExecuteEditCommand::ID: 1120 case BrowserPluginHostMsg_ExecuteEditCommand::ID:
1117 case BrowserPluginHostMsg_HandleInputEvent::ID: 1121 case BrowserPluginHostMsg_HandleInputEvent::ID:
1122 case BrowserPluginHostMsg_ImeConfirmComposition::ID:
1123 case BrowserPluginHostMsg_ImeSetComposition::ID:
1118 case BrowserPluginHostMsg_LockMouse_ACK::ID: 1124 case BrowserPluginHostMsg_LockMouse_ACK::ID:
1119 case BrowserPluginHostMsg_NavigateGuest::ID: 1125 case BrowserPluginHostMsg_NavigateGuest::ID:
1120 case BrowserPluginHostMsg_PluginDestroyed::ID: 1126 case BrowserPluginHostMsg_PluginDestroyed::ID:
1121 case BrowserPluginHostMsg_ReclaimCompositorResources::ID: 1127 case BrowserPluginHostMsg_ReclaimCompositorResources::ID:
1122 case BrowserPluginHostMsg_ResizeGuest::ID: 1128 case BrowserPluginHostMsg_ResizeGuest::ID:
1123 case BrowserPluginHostMsg_SetAutoSize::ID: 1129 case BrowserPluginHostMsg_SetAutoSize::ID:
1124 case BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent::ID: 1130 case BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent::ID:
1125 case BrowserPluginHostMsg_SetFocus::ID: 1131 case BrowserPluginHostMsg_SetFocus::ID:
1126 case BrowserPluginHostMsg_SetName::ID: 1132 case BrowserPluginHostMsg_SetName::ID:
1127 case BrowserPluginHostMsg_SetContentsOpaque::ID: 1133 case BrowserPluginHostMsg_SetContentsOpaque::ID:
(...skipping 15 matching lines...) Expand all
1143 IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse) 1149 IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse)
1144 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor) 1150 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor)
1145 #if defined(OS_MACOSX) 1151 #if defined(OS_MACOSX)
1146 // MacOSX creates and populates platform-specific select drop-down menus 1152 // MacOSX creates and populates platform-specific select drop-down menus
1147 // whereas other platforms merely create a popup window that the guest 1153 // whereas other platforms merely create a popup window that the guest
1148 // renderer process paints inside. 1154 // renderer process paints inside.
1149 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnShowPopup) 1155 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnShowPopup)
1150 #endif 1156 #endif
1151 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget) 1157 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget)
1152 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) 1158 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus)
1159 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputTypeChanged,
1160 OnTextInputTypeChanged)
1161 IPC_MESSAGE_HANDLER(ViewHostMsg_ImeCancelComposition,
1162 OnImeCancelComposition)
1163 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
1164 IPC_MESSAGE_HANDLER(ViewHostMsg_ImeCompositionRangeChanged,
1165 OnImeCompositionRangeChanged)
1166 #endif
1153 IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse) 1167 IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse)
1154 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFrameName, OnUpdateFrameName) 1168 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFrameName, OnUpdateFrameName)
1155 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) 1169 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect)
1156 IPC_MESSAGE_UNHANDLED(handled = false) 1170 IPC_MESSAGE_UNHANDLED(handled = false)
1157 IPC_END_MESSAGE_MAP() 1171 IPC_END_MESSAGE_MAP()
1158 return handled; 1172 return handled;
1159 } 1173 }
1160 1174
1161 void BrowserPluginGuest::Attach( 1175 void BrowserPluginGuest::Attach(
1162 WebContentsImpl* embedder_web_contents, 1176 WebContentsImpl* embedder_web_contents,
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 case blink::WebDragStatusUnknown: 1265 case blink::WebDragStatusUnknown:
1252 NOTREACHED(); 1266 NOTREACHED();
1253 } 1267 }
1254 } 1268 }
1255 1269
1256 void BrowserPluginGuest::OnExecuteEditCommand(int instance_id, 1270 void BrowserPluginGuest::OnExecuteEditCommand(int instance_id,
1257 const std::string& name) { 1271 const std::string& name) {
1258 Send(new InputMsg_ExecuteEditCommand(routing_id(), name, std::string())); 1272 Send(new InputMsg_ExecuteEditCommand(routing_id(), name, std::string()));
1259 } 1273 }
1260 1274
1275 void BrowserPluginGuest::OnImeSetComposition(
1276 int instance_id,
1277 const std::string& text,
1278 const std::vector<blink::WebCompositionUnderline>& underlines,
1279 int selection_start,
1280 int selection_end) {
1281 Send(new ViewMsg_ImeSetComposition(routing_id(),
1282 UTF8ToUTF16(text), underlines,
1283 selection_start, selection_end));
1284 }
1285
1286 void BrowserPluginGuest::OnImeConfirmComposition(
1287 int instance_id,
1288 const std::string& text,
1289 bool keep_selection) {
1290 Send(new ViewMsg_ImeConfirmComposition(routing_id(),
1291 UTF8ToUTF16(text),
1292 gfx::Range::InvalidRange(),
1293 keep_selection));
1294 }
1295
1261 void BrowserPluginGuest::OnReclaimCompositorResources( 1296 void BrowserPluginGuest::OnReclaimCompositorResources(
1262 int instance_id, 1297 int instance_id,
1263 int route_id, 1298 int route_id,
1264 uint32 output_surface_id, 1299 uint32 output_surface_id,
1265 int renderer_host_id, 1300 int renderer_host_id,
1266 const cc::CompositorFrameAck& ack) { 1301 const cc::CompositorFrameAck& ack) {
1267 RenderWidgetHostImpl::SendReclaimCompositorResources(route_id, 1302 RenderWidgetHostImpl::SendReclaimCompositorResources(route_id,
1268 output_surface_id, 1303 output_surface_id,
1269 renderer_host_id, 1304 renderer_host_id,
1270 ack); 1305 ack);
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
1737 relay_params.damage_buffer_sequence_id = damage_buffer_sequence_id_; 1772 relay_params.damage_buffer_sequence_id = damage_buffer_sequence_id_;
1738 relay_params.bitmap_rect = params.bitmap_rect; 1773 relay_params.bitmap_rect = params.bitmap_rect;
1739 relay_params.scroll_delta = params.scroll_delta; 1774 relay_params.scroll_delta = params.scroll_delta;
1740 relay_params.scroll_rect = params.scroll_rect; 1775 relay_params.scroll_rect = params.scroll_rect;
1741 relay_params.copy_rects = params.copy_rects; 1776 relay_params.copy_rects = params.copy_rects;
1742 1777
1743 SendMessageToEmbedder( 1778 SendMessageToEmbedder(
1744 new BrowserPluginMsg_UpdateRect(instance_id(), relay_params)); 1779 new BrowserPluginMsg_UpdateRect(instance_id(), relay_params));
1745 } 1780 }
1746 1781
1782 void BrowserPluginGuest::OnTextInputTypeChanged(ui::TextInputType type,
1783 ui::TextInputMode input_mode,
1784 bool can_compose_inline) {
1785 RenderWidgetHostImpl* render_widget_host =
1786
1787 RenderWidgetHostImpl::From(GetWebContents()->GetRenderViewHost());
1788 render_widget_host->ChangeTextInputType(type, input_mode, can_compose_inline);
sadrul 2013/12/11 07:01:00 If I am following the code correctly: this calls R
kochi 2013/12/11 08:32:11 Yes your understanding is correct, and as your sug
1789 }
1790
1791 void BrowserPluginGuest::OnImeCancelComposition() {
1792 RenderWidgetHostImpl* render_widget_host =
1793 RenderWidgetHostImpl::From(GetWebContents()->GetRenderViewHost());
1794 render_widget_host->CancelImeComposition();
1795 }
1796
1797 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
1798 void BrowserPluginGuest::OnImeCompositionRangeChanged(
1799 const gfx::Range& range,
1800 const std::vector<gfx::Rect>& character_bounds) {
1801 RenderWidgetHostImpl* render_widget_host =
1802 RenderWidgetHostImpl::From(GetWebContents()->GetRenderViewHost());
1803 render_widget_host->ChangeImeCompositionRange(range, character_bounds);
1804 }
1805 #endif
1806
1747 void BrowserPluginGuest::DidRetrieveDownloadURLFromRequestId( 1807 void BrowserPluginGuest::DidRetrieveDownloadURLFromRequestId(
1748 const std::string& request_method, 1808 const std::string& request_method,
1749 const base::Callback<void(bool)>& callback, 1809 const base::Callback<void(bool)>& callback,
1750 const std::string& url) { 1810 const std::string& url) {
1751 if (url.empty()) { 1811 if (url.empty()) {
1752 callback.Run(false); 1812 callback.Run(false);
1753 return; 1813 return;
1754 } 1814 }
1755 1815
1756 base::DictionaryValue request_info; 1816 base::DictionaryValue request_info;
1757 request_info.Set(browser_plugin::kRequestMethod, 1817 request_info.Set(browser_plugin::kRequestMethod,
1758 base::Value::CreateStringValue(request_method)); 1818 base::Value::CreateStringValue(request_method));
1759 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url)); 1819 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url));
1760 1820
1761 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_DOWNLOAD, 1821 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_DOWNLOAD,
1762 new DownloadRequest(callback), 1822 new DownloadRequest(callback),
1763 request_info); 1823 request_info);
1764 } 1824 }
1765 1825
1766 } // namespace content 1826 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_plugin/browser_plugin_guest.h ('k') | content/browser/renderer_host/render_widget_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698