summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-15 07:36:56 +0000
committersatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-15 07:36:56 +0000
commit18be1c4fd101a9cb559d6428a23de14e71c8502b (patch)
tree52ad26663ecdcc96658354f6e6e26fe06270c251
parente2203352429b98a5757f00f27ad6645cad2d6f84 (diff)
downloadchromium_src-18be1c4fd101a9cb559d6428a23de14e71c8502b.zip
chromium_src-18be1c4fd101a9cb559d6428a23de14e71c8502b.tar.gz
chromium_src-18be1c4fd101a9cb559d6428a23de14e71c8502b.tar.bz2
Merge 62524 - Fix a drag-and-drop bug in the bookmark manager on Chrome OS.
Before the fix, drag-and-drop in the bookmark manager on Chrome OS resulted in a copy rather than move. The drag-and-drop logic is shared with GTK and Views, but there was a subtle difference between the two toolkits, that caused the bug. BUG=chromium-os:7533 TEST=confirmed that dnd in the bookmark manager worked on Linux and Chrome OS Review URL: http://codereview.chromium.org/3743002 TBR=satorux@chromium.org Review URL: http://codereview.chromium.org/3747004 git-svn-id: svn://svn.chromium.org/chrome/branches/552/src@62712 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/tab_contents/web_drag_dest_gtk.cc30
1 files changed, 27 insertions, 3 deletions
diff --git a/chrome/browser/tab_contents/web_drag_dest_gtk.cc b/chrome/browser/tab_contents/web_drag_dest_gtk.cc
index 2ef66d11..b0de54f 100644
--- a/chrome/browser/tab_contents/web_drag_dest_gtk.cc
+++ b/chrome/browser/tab_contents/web_drag_dest_gtk.cc
@@ -9,6 +9,7 @@
#include "app/gtk_dnd_util.h"
#include "base/file_path.h"
#include "base/utf_string_conversions.h"
+#include "chrome/browser/bookmarks/bookmark_drag_data.h"
#include "chrome/browser/gtk/bookmark_utils_gtk.h"
#include "chrome/browser/gtk/gtk_util.h"
#include "chrome/browser/renderer_host/render_view_host.h"
@@ -18,6 +19,26 @@
using WebKit::WebDragOperation;
using WebKit::WebDragOperationNone;
+namespace {
+
+// Returns the bookmark target atom, based on the underlying toolkit.
+//
+// For GTK, bookmark drag data is encoded as pickle and associated with
+// gtk_dnd_util::CHROME_BOOKMARK_ITEM. See
+// bookmark_utils::WriteBookmarksToSelection() for details.
+// For Views, bookmark drag data is encoded in the same format, and
+// associated with a custom format. See BookmarkDragData::Write() for
+// details.
+GdkAtom GetBookmarkTargetAtom() {
+#if defined(TOOLKIT_VIEWS)
+ return BookmarkDragData::GetBookmarkCustomFormat();
+#else
+ return gtk_dnd_util::GetAtomForTarget(gtk_dnd_util::CHROME_BOOKMARK_ITEM);
+#endif
+}
+
+} // namespace
+
WebDragDestGtk::WebDragDestGtk(TabContents* tab_contents, GtkWidget* widget)
: tab_contents_(tab_contents),
widget_(widget),
@@ -87,7 +108,6 @@ gboolean WebDragDestGtk::OnDragMotion(GtkWidget* sender,
gtk_dnd_util::TEXT_HTML,
gtk_dnd_util::NETSCAPE_URL,
gtk_dnd_util::CHROME_NAMED_URL,
- gtk_dnd_util::CHROME_BOOKMARK_ITEM,
// TODO(estade): support image drags?
};
@@ -97,6 +117,9 @@ gboolean WebDragDestGtk::OnDragMotion(GtkWidget* sender,
gtk_dnd_util::GetAtomForTarget(supported_targets[i]),
time);
}
+ // Add the bookmark target as well.
+ ++data_requests_;
+ gtk_drag_get_data(widget_, context, GetBookmarkTargetAtom(), time);
} else if (data_requests_ == 0) {
tab_contents_->render_view_host()->
DragTargetDragOver(
@@ -187,8 +210,9 @@ void WebDragDestGtk::OnDragDataReceived(
// For CHROME_BOOKMARK_ITEM, we have to handle the case where the drag source
// doesn't have any data available for us. In this case we try to synthesize a
// URL bookmark.
- if (data->target ==
- gtk_dnd_util::GetAtomForTarget(gtk_dnd_util::CHROME_BOOKMARK_ITEM)) {
+ // Note that bookmark drag data is encoded in the same format for both
+ // GTK and Views, hence we can share the same logic here.
+ if (data->target == GetBookmarkTargetAtom()) {
if (data->data && data->length > 0) {
bookmark_drag_data_.ReadFromVector(
bookmark_utils::GetNodesFromSelection(