summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/gtk_dnd_util.cc11
-rw-r--r--app/gtk_dnd_util.h5
-rw-r--r--chrome/browser/gtk/tab_contents_drag_source.cc4
-rw-r--r--chrome/browser/gtk/tab_contents_drag_source.h1
-rw-r--r--chrome/browser/tab_contents/tab_contents_view_gtk.cc4
-rw-r--r--chrome/browser/tab_contents/web_drag_dest_gtk.cc46
-rw-r--r--chrome/browser/views/tab_contents/tab_contents_view_gtk.cc3
7 files changed, 53 insertions, 21 deletions
diff --git a/app/gtk_dnd_util.cc b/app/gtk_dnd_util.cc
index 4d8694d..d6b0903 100644
--- a/app/gtk_dnd_util.cc
+++ b/app/gtk_dnd_util.cc
@@ -226,4 +226,15 @@ bool ExtractURIList(GtkSelectionData* selection_data, std::vector<GURL>* urls) {
return true;
}
+GdkDragAction WebDragOpToGdkDragAction(WebKit::WebDragOperationsMask op) {
+ GdkDragAction action = static_cast<GdkDragAction>(0);
+ if (op & WebKit::WebDragOperationCopy)
+ action = static_cast<GdkDragAction>(action | GDK_ACTION_COPY);
+ if (op & WebKit::WebDragOperationLink)
+ action = static_cast<GdkDragAction>(action | GDK_ACTION_LINK);
+ if (op & WebKit::WebDragOperationMove)
+ action = static_cast<GdkDragAction>(action | GDK_ACTION_MOVE);
+ return action;
+}
+
} // namespace gtk_dnd_util
diff --git a/app/gtk_dnd_util.h b/app/gtk_dnd_util.h
index 4471174..f68931d 100644
--- a/app/gtk_dnd_util.h
+++ b/app/gtk_dnd_util.h
@@ -10,6 +10,7 @@
#include <vector>
#include "base/string16.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebDragOperation.h"
class GURL;
@@ -77,6 +78,10 @@ bool ExtractNamedURL(GtkSelectionData* selection_data,
bool ExtractURIList(GtkSelectionData* selection_data,
std::vector<GURL>* urls);
+// Convenience method for converting between a web drag operation and the GDK
+// equivalent.
+GdkDragAction WebDragOpToGdkDragAction(WebKit::WebDragOperationsMask op);
+
} // namespace gtk_dnd_util
#endif // APP_GTK_DND_UTIL_H_
diff --git a/chrome/browser/gtk/tab_contents_drag_source.cc b/chrome/browser/gtk/tab_contents_drag_source.cc
index 6d9ca4c..c0c9c72 100644
--- a/chrome/browser/gtk/tab_contents_drag_source.cc
+++ b/chrome/browser/gtk/tab_contents_drag_source.cc
@@ -24,6 +24,7 @@
#include "webkit/glue/webdropdata.h"
using WebKit::WebDragOperation;
+using WebKit::WebDragOperationsMask;
using WebKit::WebDragOperationNone;
TabContentsDragSource::TabContentsDragSource(
@@ -70,6 +71,7 @@ TabContents* TabContentsDragSource::tab_contents() const {
}
void TabContentsDragSource::StartDragging(const WebDropData& drop_data,
+ WebDragOperationsMask allowed_ops,
GdkEventButton* last_mouse_down,
const SkBitmap& image,
const gfx::Point& image_offset) {
@@ -123,7 +125,7 @@ void TabContentsDragSource::StartDragging(const WebDropData& drop_data,
// initiating event from webkit.
GdkDragContext* context = gtk_drag_begin(
drag_widget_, list,
- static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_LINK),
+ gtk_dnd_util::WebDragOpToGdkDragAction(allowed_ops),
1, // Drags are always initiated by the left button.
reinterpret_cast<GdkEvent*>(last_mouse_down));
// The drag adds a ref; let it own the list.
diff --git a/chrome/browser/gtk/tab_contents_drag_source.h b/chrome/browser/gtk/tab_contents_drag_source.h
index 7740ee6..b7407f3 100644
--- a/chrome/browser/gtk/tab_contents_drag_source.h
+++ b/chrome/browser/gtk/tab_contents_drag_source.h
@@ -33,6 +33,7 @@ class TabContentsDragSource : public MessageLoopForUI::Observer {
// Starts a drag for the tab contents this TabContentsDragSource was
// created for.
void StartDragging(const WebDropData& drop_data,
+ WebKit::WebDragOperationsMask allowed_ops,
GdkEventButton* last_mouse_down,
const SkBitmap& image,
const gfx::Point& image_offset);
diff --git a/chrome/browser/tab_contents/tab_contents_view_gtk.cc b/chrome/browser/tab_contents/tab_contents_view_gtk.cc
index b549ada..804cf56 100644
--- a/chrome/browser/tab_contents/tab_contents_view_gtk.cc
+++ b/chrome/browser/tab_contents/tab_contents_view_gtk.cc
@@ -327,10 +327,8 @@ void TabContentsViewGtk::StartDragging(const WebDropData& drop_data,
const SkBitmap& image,
const gfx::Point& image_offset) {
DCHECK(GetContentNativeView());
-
- drag_source_->StartDragging(drop_data, &last_mouse_down_, image,
+ drag_source_->StartDragging(drop_data, ops, &last_mouse_down_, image,
image_offset);
- // TODO(snej): Make use of the WebDragOperationsMask somehow
}
// -----------------------------------------------------------------------------
diff --git a/chrome/browser/tab_contents/web_drag_dest_gtk.cc b/chrome/browser/tab_contents/web_drag_dest_gtk.cc
index d96f6cf..1d7cd88 100644
--- a/chrome/browser/tab_contents/web_drag_dest_gtk.cc
+++ b/chrome/browser/tab_contents/web_drag_dest_gtk.cc
@@ -16,9 +16,25 @@
#include "net/base/net_util.h"
using WebKit::WebDragOperation;
+using WebKit::WebDragOperationNone;
using WebKit::WebDragOperationCopy;
+using WebKit::WebDragOperationLink;
using WebKit::WebDragOperationMove;
-using WebKit::WebDragOperationNone;
+
+namespace {
+
+WebDragOperation GdkDragActionToWebDragOp(GdkDragAction action) {
+ WebDragOperation op = WebDragOperationNone;
+ if (action & GDK_ACTION_COPY)
+ op = static_cast<WebDragOperation>(op | WebDragOperationCopy);
+ if (action & GDK_ACTION_LINK)
+ op = static_cast<WebDragOperation>(op | WebDragOperationLink);
+ if (action & GDK_ACTION_MOVE)
+ op = static_cast<WebDragOperation>(op | WebDragOperationMove);
+ return op;
+}
+
+} // namespace
WebDragDestGtk::WebDragDestGtk(TabContents* tab_contents, GtkWidget* widget)
: tab_contents_(tab_contents),
@@ -26,7 +42,10 @@ WebDragDestGtk::WebDragDestGtk(TabContents* tab_contents, GtkWidget* widget)
context_(NULL),
method_factory_(this) {
gtk_drag_dest_set(widget, static_cast<GtkDestDefaults>(0),
- NULL, 0, GDK_ACTION_COPY);
+ NULL, 0,
+ static_cast<GdkDragAction>(GDK_ACTION_COPY |
+ GDK_ACTION_LINK |
+ GDK_ACTION_MOVE));
g_signal_connect(widget, "drag-motion",
G_CALLBACK(OnDragMotionThunk), this);
g_signal_connect(widget, "drag-leave",
@@ -35,6 +54,8 @@ WebDragDestGtk::WebDragDestGtk(TabContents* tab_contents, GtkWidget* widget)
G_CALLBACK(OnDragDropThunk), this);
g_signal_connect(widget, "drag-data-received",
G_CALLBACK(OnDragDataReceivedThunk), this);
+ // TODO(tony): Need a drag-data-delete handler for moving content out of
+ // the tab contents. http://crbug.com/38989
destroy_handler_ = g_signal_connect(
widget, "destroy", G_CALLBACK(gtk_widget_destroyed), &widget_);
@@ -49,12 +70,8 @@ WebDragDestGtk::~WebDragDestGtk() {
void WebDragDestGtk::UpdateDragStatus(WebDragOperation operation) {
if (context_) {
- // TODO(estade): we might want to support other actions besides copy,
- // but that would increase the cost of getting our drag success guess
- // wrong.
is_drop_target_ = operation != WebDragOperationNone;
- gdk_drag_status(context_, is_drop_target_ ? GDK_ACTION_COPY :
- static_cast<GdkDragAction>(0),
+ gdk_drag_status(context_, gtk_dnd_util::WebDragOpToGdkDragAction(operation),
drag_over_time_);
}
}
@@ -97,8 +114,7 @@ gboolean WebDragDestGtk::OnDragMotion(GtkWidget* sender,
tab_contents_->render_view_host()->
DragTargetDragOver(gtk_util::ClientPoint(widget_),
gtk_util::ScreenPoint(widget_),
- static_cast<WebDragOperation>(
- WebDragOperationCopy | WebDragOperationMove));
+ GdkDragActionToWebDragOp(context->actions));
if (tab_contents_->GetBookmarkDragDelegate())
tab_contents_->GetBookmarkDragDelegate()->OnDragOver(bookmark_drag_data_);
drag_over_time_ = time;
@@ -186,10 +202,9 @@ void WebDragDestGtk::OnDragDataReceived(
// TODO(snej): Pass appropriate DragOperation instead of hardcoding.
tab_contents_->render_view_host()->
DragTargetDragEnter(*drop_data_.get(),
- gtk_util::ClientPoint(widget_),
- gtk_util::ScreenPoint(widget_),
- static_cast<WebDragOperation>(
- WebDragOperationCopy | WebDragOperationMove));
+ gtk_util::ClientPoint(widget_),
+ gtk_util::ScreenPoint(widget_),
+ GdkDragActionToWebDragOp(context->actions));
// This is non-null if tab_contents_ is showing an ExtensionDOMUI with
// support for (at the moment experimental) drag and drop extensions.
@@ -232,8 +247,9 @@ gboolean WebDragDestGtk::OnDragDrop(GtkWidget* sender, GdkDragContext* context,
if (tab_contents_->GetBookmarkDragDelegate())
tab_contents_->GetBookmarkDragDelegate()->OnDrop(bookmark_drag_data_);
- // The second parameter is just an educated guess, but at least we will
- // get the drag-end animation right sometimes.
+ // The second parameter is just an educated guess as to whether or not the
+ // drag succeeded, but at least we will get the drag-end animation right
+ // sometimes.
gtk_drag_finish(context, is_drop_target_, FALSE, time);
return TRUE;
}
diff --git a/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc b/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc
index bbeb841..e1d4d02 100644
--- a/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc
+++ b/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc
@@ -222,9 +222,8 @@ void TabContentsViewGtk::StartDragging(const WebDropData& drop_data,
WebDragOperationsMask ops,
const SkBitmap& image,
const gfx::Point& image_offset) {
- drag_source_->StartDragging(drop_data, &last_mouse_down_,
+ drag_source_->StartDragging(drop_data, ops, &last_mouse_down_,
image, image_offset);
- // TODO(snej): Make use of WebDragOperationsMask
}
void TabContentsViewGtk::SetPageTitle(const std::wstring& title) {