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

Unified Diff: content/browser/browser_plugin/browser_plugin_guest.cc

Issue 12086095: Fixed drag and drop into and out of Browser Plugin. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Addressed comments Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
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 0ad619d834c8a99fdfe5b948dd18c0a9e3a77d3c..0aabf69f99071b08390f5a535c2671a3692c0714 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/string_util.h"
#include "base/utf_string_conversions.h"
#include "content/browser/browser_plugin/browser_plugin_embedder.h"
@@ -27,6 +28,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/result_codes.h"
#include "content/browser/browser_plugin/browser_plugin_host_factory.h"
#include "net/base/net_errors.h"
@@ -321,13 +323,17 @@ 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));
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableBrowserPluginCompositing)) {
Fady Samuel 2013/02/07 15:37:18 kEnableBrowserPluginGuestViews. This doesn't need
mthiesse 2013/02/07 15:54:05 Done.
+ // Initiating a drag from inside a guest is currently not supported without
+ // the kEnableBrowserPluginCompositing flag. 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));
+ }
SendMessageToEmbedder(new BrowserPluginMsg_LoadStop(embedder_routing_id(),
instance_id()));
}
@@ -371,6 +377,7 @@ bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message)
IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWindow, OnCreateWindow)
+ IPC_MESSAGE_HANDLER(DragHostMsg_DragStopped, OnDragStopped)
IPC_MESSAGE_HANDLER(ViewHostMsg_HandleInputEvent_ACK, OnHandleInputEventAck)
IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers,
OnHasTouchEventHandlers)
@@ -382,8 +389,9 @@ bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnShowPopup)
#endif
IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget)
+ IPC_MESSAGE_HANDLER_GENERIC(DragHostMsg_StartDragging,
+ OnStartDragging(&handled));
IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus)
- IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor)
IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFrameName, OnUpdateFrameName)
IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect)
IPC_MESSAGE_UNHANDLED(handled = false)
@@ -399,12 +407,15 @@ void BrowserPluginGuest::OnDragStatusUpdate(int instance_id,
RenderViewHost* host = web_contents()->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:
@@ -593,6 +604,10 @@ void BrowserPluginGuest::OnCreateWindow(
*cloned_session_storage_namespace_id = 0l;
}
+void BrowserPluginGuest::OnDragStopped() {
+ web_contents()->GetRenderViewHost()->DragSourceSystemDragEnded();
+}
+
void BrowserPluginGuest::OnHandleInputEventAck(
WebKit::WebInputEvent::Type event_type,
InputEventAckState ack_result) {
@@ -640,6 +655,14 @@ void BrowserPluginGuest::OnShowWidget(int route_id,
screen_pos);
}
+void BrowserPluginGuest::OnStartDragging(bool* handled) {
+ embedder_web_contents_->GetBrowserPluginEmbedder()->StartDrag(this);
+ // Don't mark as handled, so that it gets passed up the chain and eventually
+ // gets to WebContentsViewGuest::StartDragging, which starts the drag on the
+ // embedder.
+ *handled = false;
+}
+
void BrowserPluginGuest::OnTakeFocus(bool reverse) {
SendMessageToEmbedder(
new BrowserPluginMsg_AdvanceFocus(embedder_routing_id(),
@@ -647,18 +670,6 @@ void BrowserPluginGuest::OnTakeFocus(bool reverse) {
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::OnUpdateFrameName(int frame_id,
bool is_top_level,
const std::string& name) {
« no previous file with comments | « content/browser/browser_plugin/browser_plugin_guest.h ('k') | content/browser/browser_plugin/browser_plugin_guest_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698