1 // Copyright 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "chrome/browser/ui/bookmarks/bookmark_drag_drop.h" 6 7 #include "chrome/browser/bookmarks/bookmark_model.h" 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 9 #include "chrome/browser/bookmarks/bookmark_node_data.h" 10 #include "chrome/browser/bookmarks/bookmark_utils.h" 11 #include "ui/base/dragdrop/drag_drop_types.h" 12 13 namespace chrome { 14 15 int DropBookmarks(Profile* profile, 16 const BookmarkNodeData& data, 17 const BookmarkNode* parent_node, 18 int index) { 19 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile); 20 if (data.IsFromProfile(profile)) { 21 const std::vector<const BookmarkNode*> dragged_nodes = 22 data.GetNodes(profile); 23 if (!dragged_nodes.empty()) { 24 // Drag from same profile. Move nodes. 25 for (size_t i = 0; i < dragged_nodes.size(); ++i) { 26 model->Move(dragged_nodes[i], parent_node, index); 27 index = parent_node->GetIndexOf(dragged_nodes[i]) + 1; 28 } 29 return ui::DragDropTypes::DRAG_MOVE; 30 } 31 return ui::DragDropTypes::DRAG_NONE; 32 } 33 // Dropping a folder from different profile. Always accept. 34 bookmark_utils::CloneBookmarkNode(model, data.elements, parent_node, 35 index, true); 36 return ui::DragDropTypes::DRAG_COPY; 37 } 38 39 } // namespace chrome 40