From 84eb368957b9ae951894bc97673384d317addcfc Mon Sep 17 00:00:00 2001
From: "estade@chromium.org"
 <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Date: Wed, 28 Apr 2010 02:27:48 +0000
Subject: GTK: make tabbed bookmark manager compatible with more types of
 drops.

BUG=42466
TEST=see bug. Also, drags from firefox bookmark bar to tabbed bookmark manager should work.

Review URL: http://codereview.chromium.org/1691018

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45778 0039d316-1c4b-4281-b951-d872f2087c98
---
 chrome/browser/bookmarks/bookmark_drag_data.cc | 27 +++++++++++++++++++-------
 chrome/browser/bookmarks/bookmark_drag_data.h  |  3 +++
 2 files changed, 23 insertions(+), 7 deletions(-)

(limited to 'chrome/browser/bookmarks')

diff --git a/chrome/browser/bookmarks/bookmark_drag_data.cc b/chrome/browser/bookmarks/bookmark_drag_data.cc
index d722659..f8a2ed4 100644
--- a/chrome/browser/bookmarks/bookmark_drag_data.cc
+++ b/chrome/browser/bookmarks/bookmark_drag_data.cc
@@ -105,6 +105,22 @@ bool BookmarkDragData::ReadFromVector(
   return true;
 }
 
+bool BookmarkDragData::ReadFromTuple(const GURL& url, const string16& title) {
+  Clear();
+
+  if (!url.is_valid())
+    return false;
+
+  Element element;
+  element.title = title;
+  element.url = url;
+  element.is_url = true;
+
+  elements.push_back(element);
+
+  return true;
+}
+
 #if !defined(OS_MACOSX)
 void BookmarkDragData::WriteToClipboard(Profile* profile) const {
   ScopedClipboardWriter scw(g_browser_process->clipboard());
@@ -214,14 +230,11 @@ bool BookmarkDragData::Read(const OSExchangeData& data) {
   } else {
     // See if there is a URL on the clipboard.
     Element element;
+    GURL url;
     std::wstring title;
-    if (data.GetURLAndTitle(&element.url, &title) &&
-        element.url.is_valid()) {
-      element.title = WideToUTF16(title);
-      element.is_url = true;
-      elements.push_back(element);
-    }
-  }
+    if (data.GetURLAndTitle(&url, &title))
+      ReadFromTuple(url, WideToUTF16(title));
+ }
 
   return is_valid();
 }
diff --git a/chrome/browser/bookmarks/bookmark_drag_data.h b/chrome/browser/bookmarks/bookmark_drag_data.h
index 7f007a2..b4b65da 100644
--- a/chrome/browser/bookmarks/bookmark_drag_data.h
+++ b/chrome/browser/bookmarks/bookmark_drag_data.h
@@ -89,6 +89,9 @@ struct BookmarkDragData {
   // Reads bookmarks from the given vector.
   bool ReadFromVector(const std::vector<const BookmarkNode*>& nodes);
 
+  // Creates a single-bookmark DragData from url/title pair.
+  bool ReadFromTuple(const GURL& url, const string16& title);
+
   // Writes elements to the clipboard.
   void WriteToClipboard(Profile* profile) const;
 
-- 
cgit v1.1