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

Side by Side Diff: chrome/browser/ui/bookmarks/bookmark_drag_drop.cc

Issue 155913004: Eliminate Bookmarks dependence to bookmark_undo_utils.h. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/bookmarks/bookmark_drag_drop.h" 5 #include "chrome/browser/ui/bookmarks/bookmark_drag_drop.h"
6 6
7 #include "chrome/browser/bookmarks/bookmark_model.h" 7 #include "chrome/browser/bookmarks/bookmark_model.h"
8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
9 #include "chrome/browser/bookmarks/bookmark_node_data.h" 9 #include "chrome/browser/bookmarks/bookmark_node_data.h"
10 #include "chrome/browser/bookmarks/bookmark_utils.h" 10 #include "chrome/browser/bookmarks/bookmark_utils.h"
11 #include "chrome/browser/undo/bookmark_undo_service.h" 11 #include "chrome/browser/undo/bookmark_undo_service.h"
12 #include "chrome/browser/undo/bookmark_undo_service_factory.h" 12 #include "chrome/browser/undo/bookmark_undo_service_factory.h"
13 #include "chrome/browser/undo/bookmark_undo_utils.h"
14 #include "ui/base/dragdrop/drag_drop_types.h" 13 #include "ui/base/dragdrop/drag_drop_types.h"
15 14
16 namespace chrome { 15 namespace chrome {
17 16
18 int DropBookmarks(Profile* profile, 17 int DropBookmarks(Profile* profile,
19 const BookmarkNodeData& data, 18 const BookmarkNodeData& data,
20 const BookmarkNode* parent_node, 19 const BookmarkNode* parent_node,
21 int index) { 20 int index) {
22 #if !defined(OS_ANDROID) 21 #if !defined(OS_ANDROID)
23 ScopedGroupBookmarkActions group_drops(profile); 22 bookmark_utils::ScopedGroupBookmarkActions group_drops(profile);
24 #endif 23 #endif
25 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile); 24 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile);
26 if (data.IsFromProfile(profile)) { 25 if (data.IsFromProfile(profile)) {
27 const std::vector<const BookmarkNode*> dragged_nodes = 26 const std::vector<const BookmarkNode*> dragged_nodes =
28 data.GetNodes(profile); 27 data.GetNodes(profile);
29 if (!dragged_nodes.empty()) { 28 if (!dragged_nodes.empty()) {
30 // Drag from same profile. Move nodes. 29 // Drag from same profile. Move nodes.
31 for (size_t i = 0; i < dragged_nodes.size(); ++i) { 30 for (size_t i = 0; i < dragged_nodes.size(); ++i) {
32 model->Move(dragged_nodes[i], parent_node, index); 31 model->Move(dragged_nodes[i], parent_node, index);
33 index = parent_node->GetIndexOf(dragged_nodes[i]) + 1; 32 index = parent_node->GetIndexOf(dragged_nodes[i]) + 1;
34 } 33 }
35 return ui::DragDropTypes::DRAG_MOVE; 34 return ui::DragDropTypes::DRAG_MOVE;
36 } 35 }
37 return ui::DragDropTypes::DRAG_NONE; 36 return ui::DragDropTypes::DRAG_NONE;
38 } 37 }
39 // Dropping a folder from different profile. Always accept. 38 // Dropping a folder from different profile. Always accept.
40 bookmark_utils::CloneBookmarkNode(model, data.elements, parent_node, 39 bookmark_utils::CloneBookmarkNode(model, data.elements, parent_node,
41 index, true); 40 index, true);
42 return ui::DragDropTypes::DRAG_COPY; 41 return ui::DragDropTypes::DRAG_COPY;
43 } 42 }
44 43
45 } // namespace chrome 44 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698