Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(699)

Unified Diff: chrome/browser/ui/bookmarks/bookmark_drag_drop.cc

Issue 12475013: bookmarks: Extract PerformBookmarkDrop() function out of bookmark_utils.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: chromeos fixes Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/bookmarks/bookmark_drag_drop.cc
diff --git a/chrome/browser/ui/bookmarks/bookmark_drag_drop.cc b/chrome/browser/ui/bookmarks/bookmark_drag_drop.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ad72b6a3160c1faf805ea76a026f3a557034e9e8
--- /dev/null
+++ b/chrome/browser/ui/bookmarks/bookmark_drag_drop.cc
@@ -0,0 +1,38 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/bookmarks/bookmark_drag_drop.h"
+
+#include "chrome/browser/bookmarks/bookmark_model.h"
+#include "chrome/browser/bookmarks/bookmark_model_factory.h"
+#include "chrome/browser/bookmarks/bookmark_node_data.h"
+#include "chrome/browser/bookmarks/bookmark_utils.h"
+#include "ui/base/dragdrop/drag_drop_types.h"
+
+namespace chrome {
+
+int DropBookmarks(Profile* profile,
+ const BookmarkNodeData& data,
+ const BookmarkNode* parent_node,
+ int index) {
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile);
+ if (data.IsFromProfile(profile)) {
+ const std::vector<const BookmarkNode*> dragged_nodes =
+ data.GetNodes(profile);
+ if (!dragged_nodes.empty()) {
+ // Drag from same profile. Move nodes.
+ for (size_t i = 0; i < dragged_nodes.size(); ++i) {
+ model->Move(dragged_nodes[i], parent_node, index);
+ index = parent_node->GetIndexOf(dragged_nodes[i]) + 1;
+ }
+ return ui::DragDropTypes::DRAG_MOVE;
+ }
+ return ui::DragDropTypes::DRAG_NONE;
+ }
+ // Dropping a folder from different profile. Always accept.
+ bookmark_utils::CloneBookmarkNode(model, data.elements, parent_node, index);
+ return ui::DragDropTypes::DRAG_COPY;
+}
+
+} // namespace chrome
« no previous file with comments | « chrome/browser/ui/bookmarks/bookmark_drag_drop.h ('k') | chrome/browser/ui/cocoa/bookmarks/bookmark_drag_drop.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698