OLD | NEW |
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 924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
935 // forward them so that the embedder gets a chance to see and process | 935 // forward them so that the embedder gets a chance to see and process |
936 // the load events. | 936 // the load events. |
937 pending_messages_.push(msg); | 937 pending_messages_.push(msg); |
938 return; | 938 return; |
939 } | 939 } |
940 msg->set_routing_id(embedder_web_contents_->GetRoutingID()); | 940 msg->set_routing_id(embedder_web_contents_->GetRoutingID()); |
941 embedder_web_contents_->Send(msg); | 941 embedder_web_contents_->Send(msg); |
942 } | 942 } |
943 | 943 |
944 void BrowserPluginGuest::DragSourceEndedAt(int client_x, int client_y, | 944 void BrowserPluginGuest::DragSourceEndedAt(int client_x, int client_y, |
945 int screen_x, int screen_y, WebKit::WebDragOperation operation) { | 945 int screen_x, int screen_y, blink::WebDragOperation operation) { |
946 web_contents()->GetRenderViewHost()->DragSourceEndedAt(client_x, client_y, | 946 web_contents()->GetRenderViewHost()->DragSourceEndedAt(client_x, client_y, |
947 screen_x, screen_y, operation); | 947 screen_x, screen_y, operation); |
948 } | 948 } |
949 | 949 |
950 void BrowserPluginGuest::DragSourceMovedTo(int client_x, int client_y, | 950 void BrowserPluginGuest::DragSourceMovedTo(int client_x, int client_y, |
951 int screen_x, int screen_y) { | 951 int screen_x, int screen_y) { |
952 web_contents()->GetRenderViewHost()->DragSourceMovedTo(client_x, client_y, | 952 web_contents()->GetRenderViewHost()->DragSourceMovedTo(client_x, client_y, |
953 screen_x, screen_y); | 953 screen_x, screen_y); |
954 } | 954 } |
955 | 955 |
956 void BrowserPluginGuest::EndSystemDrag() { | 956 void BrowserPluginGuest::EndSystemDrag() { |
957 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( | 957 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( |
958 GetWebContents()->GetRenderViewHost()); | 958 GetWebContents()->GetRenderViewHost()); |
959 guest_rvh->DragSourceSystemDragEnded(); | 959 guest_rvh->DragSourceSystemDragEnded(); |
960 // Issue a MouseUp event to get out of a selection state. | 960 // Issue a MouseUp event to get out of a selection state. |
961 WebKit::WebMouseEvent mouse_event; | 961 blink::WebMouseEvent mouse_event; |
962 mouse_event.type = WebKit::WebInputEvent::MouseUp; | 962 mouse_event.type = blink::WebInputEvent::MouseUp; |
963 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft; | 963 mouse_event.button = blink::WebMouseEvent::ButtonLeft; |
964 guest_rvh->ForwardMouseEvent(mouse_event); | 964 guest_rvh->ForwardMouseEvent(mouse_event); |
965 } | 965 } |
966 | 966 |
967 void BrowserPluginGuest::SetDelegate(BrowserPluginGuestDelegate* delegate) { | 967 void BrowserPluginGuest::SetDelegate(BrowserPluginGuestDelegate* delegate) { |
968 DCHECK(!delegate_); | 968 DCHECK(!delegate_); |
969 delegate_.reset(delegate); | 969 delegate_.reset(delegate); |
970 } | 970 } |
971 | 971 |
972 void BrowserPluginGuest::AskEmbedderForGeolocationPermission( | 972 void BrowserPluginGuest::AskEmbedderForGeolocationPermission( |
973 int bridge_id, | 973 int bridge_id, |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1213 uint32 output_surface_id, | 1213 uint32 output_surface_id, |
1214 int renderer_host_id, | 1214 int renderer_host_id, |
1215 const cc::CompositorFrameAck& ack) { | 1215 const cc::CompositorFrameAck& ack) { |
1216 RenderWidgetHostImpl::SendSwapCompositorFrameAck(route_id, | 1216 RenderWidgetHostImpl::SendSwapCompositorFrameAck(route_id, |
1217 output_surface_id, | 1217 output_surface_id, |
1218 renderer_host_id, | 1218 renderer_host_id, |
1219 ack); | 1219 ack); |
1220 } | 1220 } |
1221 | 1221 |
1222 void BrowserPluginGuest::OnDragStatusUpdate(int instance_id, | 1222 void BrowserPluginGuest::OnDragStatusUpdate(int instance_id, |
1223 WebKit::WebDragStatus drag_status, | 1223 blink::WebDragStatus drag_status, |
1224 const DropData& drop_data, | 1224 const DropData& drop_data, |
1225 WebKit::WebDragOperationsMask mask, | 1225 blink::WebDragOperationsMask mask, |
1226 const gfx::Point& location) { | 1226 const gfx::Point& location) { |
1227 RenderViewHost* host = GetWebContents()->GetRenderViewHost(); | 1227 RenderViewHost* host = GetWebContents()->GetRenderViewHost(); |
1228 switch (drag_status) { | 1228 switch (drag_status) { |
1229 case WebKit::WebDragStatusEnter: | 1229 case blink::WebDragStatusEnter: |
1230 embedder_web_contents_->GetBrowserPluginEmbedder()->DragEnteredGuest( | 1230 embedder_web_contents_->GetBrowserPluginEmbedder()->DragEnteredGuest( |
1231 this); | 1231 this); |
1232 host->DragTargetDragEnter(drop_data, location, location, mask, 0); | 1232 host->DragTargetDragEnter(drop_data, location, location, mask, 0); |
1233 break; | 1233 break; |
1234 case WebKit::WebDragStatusOver: | 1234 case blink::WebDragStatusOver: |
1235 host->DragTargetDragOver(location, location, mask, 0); | 1235 host->DragTargetDragOver(location, location, mask, 0); |
1236 break; | 1236 break; |
1237 case WebKit::WebDragStatusLeave: | 1237 case blink::WebDragStatusLeave: |
1238 embedder_web_contents_->GetBrowserPluginEmbedder()->DragLeftGuest(this); | 1238 embedder_web_contents_->GetBrowserPluginEmbedder()->DragLeftGuest(this); |
1239 host->DragTargetDragLeave(); | 1239 host->DragTargetDragLeave(); |
1240 break; | 1240 break; |
1241 case WebKit::WebDragStatusDrop: | 1241 case blink::WebDragStatusDrop: |
1242 host->DragTargetDrop(location, location, 0); | 1242 host->DragTargetDrop(location, location, 0); |
1243 EndSystemDrag(); | 1243 EndSystemDrag(); |
1244 break; | 1244 break; |
1245 case WebKit::WebDragStatusUnknown: | 1245 case blink::WebDragStatusUnknown: |
1246 NOTREACHED(); | 1246 NOTREACHED(); |
1247 } | 1247 } |
1248 } | 1248 } |
1249 | 1249 |
1250 void BrowserPluginGuest::OnExecuteEditCommand(int instance_id, | 1250 void BrowserPluginGuest::OnExecuteEditCommand(int instance_id, |
1251 const std::string& name) { | 1251 const std::string& name) { |
1252 Send(new InputMsg_ExecuteEditCommand(routing_id(), name, std::string())); | 1252 Send(new InputMsg_ExecuteEditCommand(routing_id(), name, std::string())); |
1253 } | 1253 } |
1254 | 1254 |
1255 void BrowserPluginGuest::OnHandleInputEvent( | 1255 void BrowserPluginGuest::OnHandleInputEvent( |
1256 int instance_id, | 1256 int instance_id, |
1257 const gfx::Rect& guest_window_rect, | 1257 const gfx::Rect& guest_window_rect, |
1258 const WebKit::WebInputEvent* event) { | 1258 const blink::WebInputEvent* event) { |
1259 guest_window_rect_ = guest_window_rect; | 1259 guest_window_rect_ = guest_window_rect; |
1260 // If the embedder's RWHV is destroyed then that means that the embedder's | 1260 // If the embedder's RWHV is destroyed then that means that the embedder's |
1261 // window has been closed but the embedder's WebContents has not yet been | 1261 // window has been closed but the embedder's WebContents has not yet been |
1262 // destroyed. Computing screen coordinates of a BrowserPlugin only makes sense | 1262 // destroyed. Computing screen coordinates of a BrowserPlugin only makes sense |
1263 // if there is a visible embedder. | 1263 // if there is a visible embedder. |
1264 if (embedder_web_contents_->GetRenderWidgetHostView()) { | 1264 if (embedder_web_contents_->GetRenderWidgetHostView()) { |
1265 guest_screen_rect_ = guest_window_rect; | 1265 guest_screen_rect_ = guest_window_rect; |
1266 guest_screen_rect_.Offset( | 1266 guest_screen_rect_.Offset( |
1267 embedder_web_contents_->GetRenderWidgetHostView()-> | 1267 embedder_web_contents_->GetRenderWidgetHostView()-> |
1268 GetViewBounds().OffsetFromOrigin()); | 1268 GetViewBounds().OffsetFromOrigin()); |
1269 } | 1269 } |
1270 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( | 1270 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( |
1271 GetWebContents()->GetRenderViewHost()); | 1271 GetWebContents()->GetRenderViewHost()); |
1272 | 1272 |
1273 if (WebKit::WebInputEvent::isMouseEventType(event->type)) { | 1273 if (blink::WebInputEvent::isMouseEventType(event->type)) { |
1274 guest_rvh->ForwardMouseEvent( | 1274 guest_rvh->ForwardMouseEvent( |
1275 *static_cast<const WebKit::WebMouseEvent*>(event)); | 1275 *static_cast<const blink::WebMouseEvent*>(event)); |
1276 return; | 1276 return; |
1277 } | 1277 } |
1278 | 1278 |
1279 if (event->type == WebKit::WebInputEvent::MouseWheel) { | 1279 if (event->type == blink::WebInputEvent::MouseWheel) { |
1280 guest_rvh->ForwardWheelEvent( | 1280 guest_rvh->ForwardWheelEvent( |
1281 *static_cast<const WebKit::WebMouseWheelEvent*>(event)); | 1281 *static_cast<const blink::WebMouseWheelEvent*>(event)); |
1282 return; | 1282 return; |
1283 } | 1283 } |
1284 | 1284 |
1285 if (WebKit::WebInputEvent::isKeyboardEventType(event->type)) { | 1285 if (blink::WebInputEvent::isKeyboardEventType(event->type)) { |
1286 RenderViewHostImpl* embedder_rvh = static_cast<RenderViewHostImpl*>( | 1286 RenderViewHostImpl* embedder_rvh = static_cast<RenderViewHostImpl*>( |
1287 embedder_web_contents_->GetRenderViewHost()); | 1287 embedder_web_contents_->GetRenderViewHost()); |
1288 if (!embedder_rvh->GetLastKeyboardEvent()) | 1288 if (!embedder_rvh->GetLastKeyboardEvent()) |
1289 return; | 1289 return; |
1290 NativeWebKeyboardEvent keyboard_event( | 1290 NativeWebKeyboardEvent keyboard_event( |
1291 *embedder_rvh->GetLastKeyboardEvent()); | 1291 *embedder_rvh->GetLastKeyboardEvent()); |
1292 guest_rvh->ForwardKeyboardEvent(keyboard_event); | 1292 guest_rvh->ForwardKeyboardEvent(keyboard_event); |
1293 return; | 1293 return; |
1294 } | 1294 } |
1295 | 1295 |
1296 if (WebKit::WebInputEvent::isTouchEventType(event->type)) { | 1296 if (blink::WebInputEvent::isTouchEventType(event->type)) { |
1297 guest_rvh->ForwardTouchEventWithLatencyInfo( | 1297 guest_rvh->ForwardTouchEventWithLatencyInfo( |
1298 *static_cast<const WebKit::WebTouchEvent*>(event), | 1298 *static_cast<const blink::WebTouchEvent*>(event), |
1299 ui::LatencyInfo()); | 1299 ui::LatencyInfo()); |
1300 return; | 1300 return; |
1301 } | 1301 } |
1302 | 1302 |
1303 if (WebKit::WebInputEvent::isGestureEventType(event->type)) { | 1303 if (blink::WebInputEvent::isGestureEventType(event->type)) { |
1304 guest_rvh->ForwardGestureEvent( | 1304 guest_rvh->ForwardGestureEvent( |
1305 *static_cast<const WebKit::WebGestureEvent*>(event)); | 1305 *static_cast<const blink::WebGestureEvent*>(event)); |
1306 return; | 1306 return; |
1307 } | 1307 } |
1308 } | 1308 } |
1309 | 1309 |
1310 void BrowserPluginGuest::OnLockMouse(bool user_gesture, | 1310 void BrowserPluginGuest::OnLockMouse(bool user_gesture, |
1311 bool last_unlocked_by_target, | 1311 bool last_unlocked_by_target, |
1312 bool privileged) { | 1312 bool privileged) { |
1313 if (pending_lock_request_) { | 1313 if (pending_lock_request_) { |
1314 // Immediately reject the lock because only one pointerLock may be active | 1314 // Immediately reject the lock because only one pointerLock may be active |
1315 // at a time. | 1315 // at a time. |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1731 request_info.Set(browser_plugin::kRequestMethod, | 1731 request_info.Set(browser_plugin::kRequestMethod, |
1732 base::Value::CreateStringValue(request_method)); | 1732 base::Value::CreateStringValue(request_method)); |
1733 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url)); | 1733 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url)); |
1734 | 1734 |
1735 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_DOWNLOAD, | 1735 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_DOWNLOAD, |
1736 new DownloadRequest(callback), | 1736 new DownloadRequest(callback), |
1737 request_info); | 1737 request_info); |
1738 } | 1738 } |
1739 | 1739 |
1740 } // namespace content | 1740 } // namespace content |
OLD | NEW |