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

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: Translate coordinates of parameter for ImeCompositionRangeChanged 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"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "content/browser/browser_plugin/browser_plugin_embedder.h" 12 #include "content/browser/browser_plugin/browser_plugin_embedder.h"
13 #include "content/browser/browser_plugin/browser_plugin_guest_manager.h" 13 #include "content/browser/browser_plugin/browser_plugin_guest_manager.h"
14 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" 14 #include "content/browser/browser_plugin/browser_plugin_host_factory.h"
15 #include "content/browser/browser_thread_impl.h" 15 #include "content/browser/browser_thread_impl.h"
16 #include "content/browser/child_process_security_policy_impl.h" 16 #include "content/browser/child_process_security_policy_impl.h"
17 #include "content/browser/loader/resource_dispatcher_host_impl.h" 17 #include "content/browser/loader/resource_dispatcher_host_impl.h"
18 #include "content/browser/renderer_host/render_view_host_impl.h" 18 #include "content/browser/renderer_host/render_view_host_impl.h"
19 #include "content/browser/renderer_host/render_widget_host_impl.h" 19 #include "content/browser/renderer_host/render_widget_host_impl.h"
20 #include "content/browser/web_contents/web_contents_impl.h" 20 #include "content/browser/web_contents/web_contents_impl.h"
21 #include "content/browser/web_contents/web_contents_view_guest.h" 21 #include "content/browser/web_contents/web_contents_view_guest.h"
22 #include "content/common/browser_plugin/browser_plugin_constants.h" 22 #include "content/common/browser_plugin/browser_plugin_constants.h"
23 #include "content/common/browser_plugin/browser_plugin_messages.h" 23 #include "content/common/browser_plugin/browser_plugin_messages.h"
24 #include "content/common/content_constants_internal.h" 24 #include "content/common/content_constants_internal.h"
25 #include "content/common/drag_messages.h" 25 #include "content/common/drag_messages.h"
26 #include "content/common/gpu/gpu_messages.h" 26 #include "content/common/gpu/gpu_messages.h"
27 #include "content/common/input_messages.h" 27 #include "content/common/input_messages.h"
28 #include "content/common/view_messages.h" 28 #include "content/common/view_messages.h"
29 #include "content/port/browser/render_view_host_delegate_view.h" 29 #include "content/port/browser/render_view_host_delegate_view.h"
30 #include "content/port/browser/render_widget_host_view_port.h"
30 #include "content/public/browser/browser_context.h" 31 #include "content/public/browser/browser_context.h"
31 #include "content/public/browser/content_browser_client.h" 32 #include "content/public/browser/content_browser_client.h"
32 #include "content/public/browser/geolocation_permission_context.h" 33 #include "content/public/browser/geolocation_permission_context.h"
33 #include "content/public/browser/navigation_controller.h" 34 #include "content/public/browser/navigation_controller.h"
34 #include "content/public/browser/render_process_host.h" 35 #include "content/public/browser/render_process_host.h"
35 #include "content/public/browser/render_widget_host_view.h" 36 #include "content/public/browser/render_widget_host_view.h"
36 #include "content/public/browser/resource_request_details.h" 37 #include "content/public/browser/resource_request_details.h"
37 #include "content/public/browser/user_metrics.h" 38 #include "content/public/browser/user_metrics.h"
38 #include "content/public/browser/web_contents_observer.h" 39 #include "content/public/browser/web_contents_observer.h"
39 #include "content/public/browser/web_contents_view.h" 40 #include "content/public/browser/web_contents_view.h"
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_BuffersSwappedACK, 508 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_BuffersSwappedACK,
508 OnSwapBuffersACK) 509 OnSwapBuffersACK)
509 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CompositorFrameACK, 510 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CompositorFrameACK,
510 OnCompositorFrameACK) 511 OnCompositorFrameACK)
511 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CopyFromCompositingSurfaceAck, 512 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CopyFromCompositingSurfaceAck,
512 OnCopyFromCompositingSurfaceAck) 513 OnCopyFromCompositingSurfaceAck)
513 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_DragStatusUpdate, 514 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_DragStatusUpdate,
514 OnDragStatusUpdate) 515 OnDragStatusUpdate)
515 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ExecuteEditCommand, 516 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ExecuteEditCommand,
516 OnExecuteEditCommand) 517 OnExecuteEditCommand)
518 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ExtendSelectionAndDelete,
519 OnExtendSelectionAndDelete)
517 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_HandleInputEvent, 520 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_HandleInputEvent,
518 OnHandleInputEvent) 521 OnHandleInputEvent)
522 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ImeConfirmComposition,
523 OnImeConfirmComposition)
524 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ImeSetComposition,
525 OnImeSetComposition)
519 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_LockMouse_ACK, OnLockMouseAck) 526 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_LockMouse_ACK, OnLockMouseAck)
520 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_NavigateGuest, OnNavigateGuest) 527 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_NavigateGuest, OnNavigateGuest)
521 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginDestroyed, OnPluginDestroyed) 528 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginDestroyed, OnPluginDestroyed)
522 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ReclaimCompositorResources, 529 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ReclaimCompositorResources,
523 OnReclaimCompositorResources) 530 OnReclaimCompositorResources)
524 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ResizeGuest, OnResizeGuest) 531 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ResizeGuest, OnResizeGuest)
525 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetAutoSize, OnSetSize) 532 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetAutoSize, OnSetSize)
526 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent, 533 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent,
527 OnSetEditCommandsForNextKeyEvent) 534 OnSetEditCommandsForNextKeyEvent)
528 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetFocus, OnSetFocus) 535 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetFocus, OnSetFocus)
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 1137
1131 // static 1138 // static
1132 bool BrowserPluginGuest::ShouldForwardToBrowserPluginGuest( 1139 bool BrowserPluginGuest::ShouldForwardToBrowserPluginGuest(
1133 const IPC::Message& message) { 1140 const IPC::Message& message) {
1134 switch (message.type()) { 1141 switch (message.type()) {
1135 case BrowserPluginHostMsg_BuffersSwappedACK::ID: 1142 case BrowserPluginHostMsg_BuffersSwappedACK::ID:
1136 case BrowserPluginHostMsg_CompositorFrameACK::ID: 1143 case BrowserPluginHostMsg_CompositorFrameACK::ID:
1137 case BrowserPluginHostMsg_CopyFromCompositingSurfaceAck::ID: 1144 case BrowserPluginHostMsg_CopyFromCompositingSurfaceAck::ID:
1138 case BrowserPluginHostMsg_DragStatusUpdate::ID: 1145 case BrowserPluginHostMsg_DragStatusUpdate::ID:
1139 case BrowserPluginHostMsg_ExecuteEditCommand::ID: 1146 case BrowserPluginHostMsg_ExecuteEditCommand::ID:
1147 case BrowserPluginHostMsg_ExtendSelectionAndDelete::ID:
1140 case BrowserPluginHostMsg_HandleInputEvent::ID: 1148 case BrowserPluginHostMsg_HandleInputEvent::ID:
1149 case BrowserPluginHostMsg_ImeConfirmComposition::ID:
1150 case BrowserPluginHostMsg_ImeSetComposition::ID:
1141 case BrowserPluginHostMsg_LockMouse_ACK::ID: 1151 case BrowserPluginHostMsg_LockMouse_ACK::ID:
1142 case BrowserPluginHostMsg_NavigateGuest::ID: 1152 case BrowserPluginHostMsg_NavigateGuest::ID:
1143 case BrowserPluginHostMsg_PluginDestroyed::ID: 1153 case BrowserPluginHostMsg_PluginDestroyed::ID:
1144 case BrowserPluginHostMsg_ReclaimCompositorResources::ID: 1154 case BrowserPluginHostMsg_ReclaimCompositorResources::ID:
1145 case BrowserPluginHostMsg_ResizeGuest::ID: 1155 case BrowserPluginHostMsg_ResizeGuest::ID:
1146 case BrowserPluginHostMsg_SetAutoSize::ID: 1156 case BrowserPluginHostMsg_SetAutoSize::ID:
1147 case BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent::ID: 1157 case BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent::ID:
1148 case BrowserPluginHostMsg_SetFocus::ID: 1158 case BrowserPluginHostMsg_SetFocus::ID:
1149 case BrowserPluginHostMsg_SetName::ID: 1159 case BrowserPluginHostMsg_SetName::ID:
1150 case BrowserPluginHostMsg_SetContentsOpaque::ID: 1160 case BrowserPluginHostMsg_SetContentsOpaque::ID:
(...skipping 15 matching lines...) Expand all
1166 IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse) 1176 IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse)
1167 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor) 1177 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor)
1168 #if defined(OS_MACOSX) 1178 #if defined(OS_MACOSX)
1169 // MacOSX creates and populates platform-specific select drop-down menus 1179 // MacOSX creates and populates platform-specific select drop-down menus
1170 // whereas other platforms merely create a popup window that the guest 1180 // whereas other platforms merely create a popup window that the guest
1171 // renderer process paints inside. 1181 // renderer process paints inside.
1172 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnShowPopup) 1182 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnShowPopup)
1173 #endif 1183 #endif
1174 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget) 1184 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget)
1175 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) 1185 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus)
1186 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputTypeChanged,
1187 OnTextInputTypeChanged)
1188 IPC_MESSAGE_HANDLER(ViewHostMsg_ImeCancelComposition,
1189 OnImeCancelComposition)
1190 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
1191 IPC_MESSAGE_HANDLER(ViewHostMsg_ImeCompositionRangeChanged,
1192 OnImeCompositionRangeChanged)
1193 #endif
1176 IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse) 1194 IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse)
1177 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFrameName, OnUpdateFrameName) 1195 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFrameName, OnUpdateFrameName)
1178 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) 1196 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect)
1179 IPC_MESSAGE_UNHANDLED(handled = false) 1197 IPC_MESSAGE_UNHANDLED(handled = false)
1180 IPC_END_MESSAGE_MAP() 1198 IPC_END_MESSAGE_MAP()
1181 return handled; 1199 return handled;
1182 } 1200 }
1183 1201
1184 void BrowserPluginGuest::Attach( 1202 void BrowserPluginGuest::Attach(
1185 WebContentsImpl* embedder_web_contents, 1203 WebContentsImpl* embedder_web_contents,
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1274 case blink::WebDragStatusUnknown: 1292 case blink::WebDragStatusUnknown:
1275 NOTREACHED(); 1293 NOTREACHED();
1276 } 1294 }
1277 } 1295 }
1278 1296
1279 void BrowserPluginGuest::OnExecuteEditCommand(int instance_id, 1297 void BrowserPluginGuest::OnExecuteEditCommand(int instance_id,
1280 const std::string& name) { 1298 const std::string& name) {
1281 Send(new InputMsg_ExecuteEditCommand(routing_id(), name, std::string())); 1299 Send(new InputMsg_ExecuteEditCommand(routing_id(), name, std::string()));
1282 } 1300 }
1283 1301
1302 void BrowserPluginGuest::OnImeSetComposition(
1303 int instance_id,
1304 const std::string& text,
1305 const std::vector<blink::WebCompositionUnderline>& underlines,
1306 int selection_start,
1307 int selection_end) {
1308 Send(new ViewMsg_ImeSetComposition(routing_id(),
1309 UTF8ToUTF16(text), underlines,
1310 selection_start, selection_end));
1311 }
1312
1313 void BrowserPluginGuest::OnImeConfirmComposition(
1314 int instance_id,
1315 const std::string& text,
1316 bool keep_selection) {
1317 Send(new ViewMsg_ImeConfirmComposition(routing_id(),
1318 UTF8ToUTF16(text),
1319 gfx::Range::InvalidRange(),
1320 keep_selection));
1321 }
1322
1323 void BrowserPluginGuest::OnExtendSelectionAndDelete(
1324 int instance_id,
1325 int before,
1326 int after) {
1327 Send(new ViewMsg_ExtendSelectionAndDelete(routing_id(), before, after));
1328 }
1329
1284 void BrowserPluginGuest::OnReclaimCompositorResources( 1330 void BrowserPluginGuest::OnReclaimCompositorResources(
1285 int instance_id, 1331 int instance_id,
1286 int route_id, 1332 int route_id,
1287 uint32 output_surface_id, 1333 uint32 output_surface_id,
1288 int renderer_host_id, 1334 int renderer_host_id,
1289 const cc::CompositorFrameAck& ack) { 1335 const cc::CompositorFrameAck& ack) {
1290 RenderWidgetHostImpl::SendReclaimCompositorResources(route_id, 1336 RenderWidgetHostImpl::SendReclaimCompositorResources(route_id,
1291 output_surface_id, 1337 output_surface_id,
1292 renderer_host_id, 1338 renderer_host_id,
1293 ack); 1339 ack);
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
1772 relay_params.damage_buffer_sequence_id = damage_buffer_sequence_id_; 1818 relay_params.damage_buffer_sequence_id = damage_buffer_sequence_id_;
1773 relay_params.bitmap_rect = params.bitmap_rect; 1819 relay_params.bitmap_rect = params.bitmap_rect;
1774 relay_params.scroll_delta = params.scroll_delta; 1820 relay_params.scroll_delta = params.scroll_delta;
1775 relay_params.scroll_rect = params.scroll_rect; 1821 relay_params.scroll_rect = params.scroll_rect;
1776 relay_params.copy_rects = params.copy_rects; 1822 relay_params.copy_rects = params.copy_rects;
1777 1823
1778 SendMessageToEmbedder( 1824 SendMessageToEmbedder(
1779 new BrowserPluginMsg_UpdateRect(instance_id(), relay_params)); 1825 new BrowserPluginMsg_UpdateRect(instance_id(), relay_params));
1780 } 1826 }
1781 1827
1828 void BrowserPluginGuest::OnTextInputTypeChanged(ui::TextInputType type,
1829 ui::TextInputMode input_mode,
1830 bool can_compose_inline) {
1831 RenderWidgetHostViewPort::FromRWHV(
1832 web_contents()->GetRenderWidgetHostView())->TextInputTypeChanged(
1833 type, input_mode, can_compose_inline);
1834 }
1835
1836 void BrowserPluginGuest::OnImeCancelComposition() {
1837 RenderWidgetHostViewPort::FromRWHV(
1838 web_contents()->GetRenderWidgetHostView())->ImeCancelComposition();
1839 }
1840
1841 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
1842 void BrowserPluginGuest::OnImeCompositionRangeChanged(
1843 const gfx::Range& range,
1844 const std::vector<gfx::Rect>& character_bounds) {
1845 RenderWidgetHostViewPort::FromRWHV(
1846 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged(
1847 range, character_bounds);
1848 }
1849 #endif
1850
1782 void BrowserPluginGuest::DidRetrieveDownloadURLFromRequestId( 1851 void BrowserPluginGuest::DidRetrieveDownloadURLFromRequestId(
1783 const std::string& request_method, 1852 const std::string& request_method,
1784 const base::Callback<void(bool)>& callback, 1853 const base::Callback<void(bool)>& callback,
1785 const std::string& url) { 1854 const std::string& url) {
1786 if (url.empty()) { 1855 if (url.empty()) {
1787 callback.Run(false); 1856 callback.Run(false);
1788 return; 1857 return;
1789 } 1858 }
1790 1859
1791 base::DictionaryValue request_info; 1860 base::DictionaryValue request_info;
1792 request_info.Set(browser_plugin::kRequestMethod, 1861 request_info.Set(browser_plugin::kRequestMethod,
1793 base::Value::CreateStringValue(request_method)); 1862 base::Value::CreateStringValue(request_method));
1794 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url)); 1863 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url));
1795 1864
1796 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_DOWNLOAD, 1865 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_DOWNLOAD,
1797 new DownloadRequest(callback), 1866 new DownloadRequest(callback),
1798 request_info); 1867 request_info);
1799 } 1868 }
1800 1869
1801 } // namespace content 1870 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698