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

Unified Diff: content/browser/browser_plugin/browser_plugin_embedder.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: Drag and drop enabled for linux only Created 7 years, 9 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_embedder.cc
diff --git a/content/browser/browser_plugin/browser_plugin_embedder.cc b/content/browser/browser_plugin/browser_plugin_embedder.cc
index 10df740f72cfa02ff764c122d77bb56c5475abc4..7facecedaeb2f946cf0425a0bc79601cdf117756 100644
--- a/content/browser/browser_plugin/browser_plugin_embedder.cc
+++ b/content/browser/browser_plugin/browser_plugin_embedder.cc
@@ -10,6 +10,7 @@
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/common/browser_plugin/browser_plugin_constants.h"
#include "content/common/browser_plugin/browser_plugin_messages.h"
+#include "content/common/drag_messages.h"
#include "content/common/gpu/gpu_messages.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/user_metrics.h"
@@ -40,6 +41,28 @@ BrowserPluginEmbedder* BrowserPluginEmbedder::Create(
return new BrowserPluginEmbedder(web_contents);
}
+void BrowserPluginEmbedder::DragEnteredGuest(BrowserPluginGuest* guest) {
+ guest_dragging_over_ = guest->AsWeakPtr();
+}
+
+void BrowserPluginEmbedder::DragLeftGuest(BrowserPluginGuest* guest) {
+ // Avoid race conditions in switching between guests being hovered over by
+ // only un-setting if the caller is marked as the guest being dragged over.
+ if (guest_dragging_over_ == guest) {
+ guest_dragging_over_.reset();
+ }
+}
+
+void BrowserPluginEmbedder::StartDrag(BrowserPluginGuest* guest) {
+ guest_started_drag_ = guest->AsWeakPtr();
+}
+
+void BrowserPluginEmbedder::StopDrag(BrowserPluginGuest* guest) {
+ if (guest_started_drag_ == guest) {
+ guest_started_drag_.reset();
+ }
+}
+
void BrowserPluginEmbedder::GetRenderViewHostAtPosition(
int x, int y, const WebContents::GetRenderViewHostCallback& callback) {
// Store the callback so we can call it later when we have the response.
@@ -65,11 +88,38 @@ bool BrowserPluginEmbedder::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CreateGuest, OnCreateGuest)
IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginAtPositionResponse,
OnPluginAtPositionResponse)
+ IPC_MESSAGE_HANDLER_GENERIC(DragHostMsg_UpdateDragCursor,
+ OnUpdateDragCursor(&handled));
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
+void BrowserPluginEmbedder::DragSourceEndedAt(int client_x, int client_y,
+ int screen_x, int screen_y, WebKit::WebDragOperation operation) {
Fady Samuel 2013/04/09 20:49:12 Hmm, is client_x, client_y in the right coordinate
mthiesse 2013/04/18 18:02:03 Good catch, doesn't seem to change much (if anythi
+ if (guest_started_drag_)
Fady Samuel 2013/04/09 20:49:12 Put in block: if (guest_started_drag_) { guest_
mthiesse 2013/04/18 18:02:03 Done.
+ guest_started_drag_->DragSourceEndedAt(client_x, client_y,
+ screen_x, screen_y, operation);
+}
+
+void BrowserPluginEmbedder::DragSourceMovedTo(int client_x, int client_y,
Fady Samuel 2013/04/09 20:49:12 ditto
mthiesse 2013/04/18 18:02:03 Done.
+ int screen_x, int screen_y) {
+ if (guest_started_drag_)
+ guest_started_drag_->DragSourceMovedTo(client_x, client_y,
Fady Samuel 2013/04/09 20:49:12 { ... }
mthiesse 2013/04/18 18:02:03 Done.
+ screen_x, screen_y);
+}
+
+void BrowserPluginEmbedder::SystemDragEnded() {
+ if (guest_started_drag_ && (guest_started_drag_ != guest_dragging_over_))
+ guest_started_drag_->EndSystemDrag();
+ guest_started_drag_.reset();
+ guest_dragging_over_.reset();
+}
+
+void BrowserPluginEmbedder::OnUpdateDragCursor(bool* handled) {
+ *handled = (guest_dragging_over_ != NULL);
+}
+
void BrowserPluginEmbedder::CleanUp() {
// CleanUp gets called when BrowserPluginEmbedder's WebContents goes away
// or the associated RenderViewHost is destroyed or swapped out. Therefore we

Powered by Google App Engine
This is Rietveld 408576698