summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tab_contents
diff options
context:
space:
mode:
authorsatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-14 09:17:31 +0000
committersatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-14 09:17:31 +0000
commit2fa414b55c53ef55f2f641a00b89e0bd1896e6fd (patch)
tree1f4af0a78412d1e0658935988633b1d752ce40d1 /chrome/browser/tab_contents
parentb5112a050823b9222dfb460c451bb70e0b647188 (diff)
downloadchromium_src-2fa414b55c53ef55f2f641a00b89e0bd1896e6fd.zip
chromium_src-2fa414b55c53ef55f2f641a00b89e0bd1896e6fd.tar.gz
chromium_src-2fa414b55c53ef55f2f641a00b89e0bd1896e6fd.tar.bz2
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 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62524 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents')
-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(