Index: content/browser/browser_plugin/browser_plugin_guest.cc |
diff --git a/content/browser/browser_plugin/browser_plugin_guest.cc b/content/browser/browser_plugin/browser_plugin_guest.cc |
index 973408fbd476f1fa1a1d651c24368d9a7ca8a06c..17335bfb77048f46fac0c3b75f8a331b113a76d0 100644 |
--- a/content/browser/browser_plugin/browser_plugin_guest.cc |
+++ b/content/browser/browser_plugin/browser_plugin_guest.cc |
@@ -6,6 +6,7 @@ |
#include <algorithm> |
+#include "base/command_line.h" |
#include "base/message_loop.h" |
#include "base/string_util.h" |
#include "base/utf_string_conversions.h" |
@@ -34,6 +35,7 @@ |
#include "content/public/browser/resource_request_details.h" |
#include "content/public/browser/user_metrics.h" |
#include "content/public/browser/web_contents_view.h" |
+#include "content/public/common/content_switches.h" |
#include "content/public/common/media_stream_request.h" |
#include "content/public/common/result_codes.h" |
#include "net/base/net_errors.h" |
@@ -485,6 +487,22 @@ void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { |
embedder_web_contents_->Send(msg); |
} |
+void BrowserPluginGuest::DragSourceEndedAt(int client_x, int client_y, |
+ int screen_x, int screen_y, WebKit::WebDragOperation operation) { |
+ web_contents()->GetRenderViewHost()->DragSourceEndedAt(client_x, client_y, |
+ screen_x, screen_y, operation); |
+} |
+ |
+void BrowserPluginGuest::DragSourceMovedTo(int client_x, int client_y, |
+ int screen_x, int screen_y) { |
+ web_contents()->GetRenderViewHost()->DragSourceMovedTo(client_x, client_y, |
+ screen_x, screen_y); |
+} |
+ |
+void BrowserPluginGuest::EndSystemDrag() { |
+ web_contents()->GetRenderViewHost()->DragSourceSystemDragEnded(); |
Fady Samuel
2013/04/09 20:49:12
This ought to fix the sticky selection problem:
v
mthiesse
2013/04/18 18:02:03
Done. Thanks.
|
+} |
+ |
void BrowserPluginGuest::LoadRedirect( |
const GURL& old_url, |
const GURL& new_url, |
@@ -557,13 +575,22 @@ void BrowserPluginGuest::DidCommitProvisionalLoadForFrame( |
} |
void BrowserPluginGuest::DidStopLoading(RenderViewHost* render_view_host) { |
- // Initiating a drag from inside a guest is currently not supported. So inject |
- // some JS to disable it. http://crbug.com/161112 |
- const char script[] = "window.addEventListener('dragstart', function() { " |
- " window.event.preventDefault(); " |
- "});"; |
- render_view_host->ExecuteJavascriptInWebFrame(string16(), |
- ASCIIToUTF16(script)); |
+ bool disable_dragdrop = true; |
+#if (defined(OS_LINUX)) |
+ if (CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kEnableBrowserPluginDragDrop)) |
+ disable_dragdrop = false; |
+#endif // (defined(OS_LINUX)) |
+ if (disable_dragdrop) { |
+ // Initiating a drag from inside a guest is currently not supported without |
+ // the kEnableBrowserPluginGuestViews flag. So inject some JS to disable |
Fady Samuel
2013/04/09 20:49:12
Stale comment.
mthiesse
2013/04/18 18:02:03
Done.
|
+ // it. http://crbug.com/161112 |
+ const char script[] = "window.addEventListener('dragstart', function() { " |
+ " window.event.preventDefault(); " |
+ "});"; |
+ render_view_host->ExecuteJavascriptInWebFrame(string16(), |
+ ASCIIToUTF16(script)); |
+ } |
SendMessageToEmbedder(new BrowserPluginMsg_LoadStop(instance_id())); |
} |
@@ -661,9 +688,12 @@ bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message) { |
#endif |
IPC_MESSAGE_HANDLER(ViewHostMsg_ShowView, OnShowView) |
IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget) |
+ IPC_MESSAGE_HANDLER_GENERIC(DragHostMsg_StartDragging, |
+ OnStartDragging(&handled)); |
IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) |
+ IPC_MESSAGE_HANDLER_GENERIC(DragHostMsg_TargetDrop_ACK, |
+ OnTargetDrop_ACK(&handled)); |
IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse) |
- IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor) |
IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFrameName, OnUpdateFrameName) |
IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) |
IPC_MESSAGE_UNHANDLED(handled = false) |
@@ -728,16 +758,20 @@ void BrowserPluginGuest::OnDragStatusUpdate(int instance_id, |
RenderViewHost* host = GetWebContents()->GetRenderViewHost(); |
switch (drag_status) { |
case WebKit::WebDragStatusEnter: |
+ embedder_web_contents_->GetBrowserPluginEmbedder()->DragEnteredGuest( |
+ this); |
host->DragTargetDragEnter(drop_data, location, location, mask, 0); |
break; |
case WebKit::WebDragStatusOver: |
host->DragTargetDragOver(location, location, mask, 0); |
break; |
case WebKit::WebDragStatusLeave: |
+ embedder_web_contents_->GetBrowserPluginEmbedder()->DragLeftGuest(this); |
host->DragTargetDragLeave(); |
break; |
case WebKit::WebDragStatusDrop: |
host->DragTargetDrop(location, location, 0); |
+ host->DragSourceSystemDragEnded(); |
Fady Samuel
2013/04/09 20:49:12
EndSystemDrag();
mthiesse
2013/04/18 18:02:03
Done.
|
break; |
case WebKit::WebDragStatusUnknown: |
NOTREACHED(); |
@@ -1051,21 +1085,23 @@ void BrowserPluginGuest::OnShowWidget(int route_id, |
GetWebContents()->ShowCreatedWidget(route_id, screen_pos); |
} |
+void BrowserPluginGuest::OnStartDragging(bool* handled) { |
+ embedder_web_contents_->GetBrowserPluginEmbedder()->StartDrag(this); |
Fady Samuel
2013/04/09 20:49:12
Why not just move this to WebContentsViewGuest::St
mthiesse
2013/04/18 18:02:03
Done.
|
+ // Don't mark as handled, so that the message gets routed to |
+ // RenderViewHostImpl::OnStartDragging, which in turn calls |
+ // WebContentsViewGuest::StartDragging, which starts the drag on the embedder. |
+ *handled = false; |
+} |
+ |
void BrowserPluginGuest::OnTakeFocus(bool reverse) { |
SendMessageToEmbedder( |
new BrowserPluginMsg_AdvanceFocus(instance_id(), reverse)); |
} |
-void BrowserPluginGuest::OnUpdateDragCursor( |
- WebKit::WebDragOperation operation) { |
- RenderViewHostImpl* embedder_render_view_host = |
- static_cast<RenderViewHostImpl*>( |
- embedder_web_contents_->GetRenderViewHost()); |
- CHECK(embedder_render_view_host); |
- RenderViewHostDelegateView* view = |
- embedder_render_view_host->GetDelegate()->GetDelegateView(); |
- if (view) |
- view->UpdateDragCursor(operation); |
+void BrowserPluginGuest::OnTargetDrop_ACK(bool* handled) { |
+ EndSystemDrag(); |
+ // Don't mark as handled. |
Fady Samuel
2013/04/09 20:49:12
This comment on its own is not very useful. Please
mthiesse
2013/04/18 18:02:03
Ah, meant to clean this up, was part of my experim
|
+ *handled = false; |
} |
void BrowserPluginGuest::OnUpdateFrameName(int frame_id, |