summaryrefslogtreecommitdiffstats
path: root/chrome/browser/bookmarks
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-18 17:10:18 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-18 17:10:18 +0000
commit2ca8a064a206fba910dc0f50f8a2f2509828d8f1 (patch)
tree9e128f90d2392b901aca101baabe12dd36621943 /chrome/browser/bookmarks
parent911f815112d8d11778c771467fbef2c2b1f8e160 (diff)
downloadchromium_src-2ca8a064a206fba910dc0f50f8a2f2509828d8f1.zip
chromium_src-2ca8a064a206fba910dc0f50f8a2f2509828d8f1.tar.gz
chromium_src-2ca8a064a206fba910dc0f50f8a2f2509828d8f1.tar.bz2
GTK: implement extension bookmark manager drag api.
Also, cross-platform: eschew RenderViewHostDelegate:BookmarkDrag::DragData type in favor of BookmarkDragData. BUG=37702 TEST=manual Review URL: http://codereview.chromium.org/1029004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41959 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/bookmarks')
-rw-r--r--chrome/browser/bookmarks/bookmark_drag_data.cc26
-rw-r--r--chrome/browser/bookmarks/bookmark_drag_data.h8
-rw-r--r--chrome/browser/bookmarks/bookmark_utils.cc7
3 files changed, 32 insertions, 9 deletions
diff --git a/chrome/browser/bookmarks/bookmark_drag_data.cc b/chrome/browser/bookmarks/bookmark_drag_data.cc
index 3491d06..d722659 100644
--- a/chrome/browser/bookmarks/bookmark_drag_data.cc
+++ b/chrome/browser/bookmarks/bookmark_drag_data.cc
@@ -89,8 +89,20 @@ BookmarkDragData::BookmarkDragData(const BookmarkNode* node) {
BookmarkDragData::BookmarkDragData(
const std::vector<const BookmarkNode*>& nodes) {
+ ReadFromVector(nodes);
+}
+
+bool BookmarkDragData::ReadFromVector(
+ const std::vector<const BookmarkNode*>& nodes) {
+ Clear();
+
+ if (nodes.empty())
+ return false;
+
for (size_t i = 0; i < nodes.size(); ++i)
elements.push_back(Element(nodes[i]));
+
+ return true;
}
#if !defined(OS_MACOSX)
@@ -272,12 +284,14 @@ void BookmarkDragData::Clear() {
elements.clear();
}
+void BookmarkDragData::SetOriginatingProfile(Profile* profile) {
+ DCHECK(profile_path_.empty());
+
+ if (profile)
+ profile_path_ = profile->GetPath().value();
+}
+
bool BookmarkDragData::IsFromProfile(Profile* profile) const {
// An empty path means the data is not associated with any profile.
- return (!profile_path_.empty() &&
-#if defined(WCHAR_T_IS_UTF16)
- profile->GetPath().ToWStringHack() == profile_path_);
-#elif defined(WCHAR_T_IS_UTF32)
- profile->GetPath().value() == profile_path_);
-#endif
+ return !profile_path_.empty() && profile_path_ == profile->GetPath().value();
}
diff --git a/chrome/browser/bookmarks/bookmark_drag_data.h b/chrome/browser/bookmarks/bookmark_drag_data.h
index e26c362..7f007a2 100644
--- a/chrome/browser/bookmarks/bookmark_drag_data.h
+++ b/chrome/browser/bookmarks/bookmark_drag_data.h
@@ -86,6 +86,9 @@ struct BookmarkDragData {
explicit BookmarkDragData(const BookmarkNode* node);
explicit BookmarkDragData(const std::vector<const BookmarkNode*>& nodes);
+ // Reads bookmarks from the given vector.
+ bool ReadFromVector(const std::vector<const BookmarkNode*>& nodes);
+
// Writes elements to the clipboard.
void WriteToClipboard(Profile* profile) const;
@@ -138,6 +141,11 @@ struct BookmarkDragData {
// Clears the data.
void Clear();
+ // Sets |profile_path_| to that of |profile|. This is useful for the
+ // constructors/readers that don't set it. This should only be called if the
+ // profile path is not already set.
+ void SetOriginatingProfile(Profile* profile);
+
// Returns true if this data is from the specified profile.
bool IsFromProfile(Profile* profile) const;
diff --git a/chrome/browser/bookmarks/bookmark_utils.cc b/chrome/browser/bookmarks/bookmark_utils.cc
index c31b821..cda4ef0 100644
--- a/chrome/browser/bookmarks/bookmark_utils.cc
+++ b/chrome/browser/bookmarks/bookmark_utils.cc
@@ -40,6 +40,8 @@
#include "views/drag_utils.h"
#include "views/widget/root_view.h"
#include "views/widget/widget.h"
+#elif defined(TOOLKIT_GTK)
+#include "chrome/browser/gtk/custom_drag.h"
#endif
using base::Time;
@@ -352,9 +354,8 @@ void DragBookmarks(Profile* profile,
MessageLoop::current()->SetNestableTasksAllowed(true);
bookmark_pasteboard_helper_mac::StartDrag(profile, nodes, view);
MessageLoop::current()->SetNestableTasksAllowed(was_nested);
-#else
- // TODO(arv): Implement for GTK.
- NOTIMPLEMENTED();
+#elif defined(TOOLKIT_GTK)
+ BookmarkDrag::BeginDrag(profile, nodes);
#endif
}