blob: d4f88e9c4da43225c9ebc7050af162a764e0fe87 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
// 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 "chrome/browser/bookmarks/scoped_group_bookmark_actions.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/undo/bookmark_undo_service.h"
#include "chrome/browser/undo/bookmark_undo_service_factory.h"
#include "ui/base/dragdrop/drag_drop_types.h"
namespace chrome {
int DropBookmarks(Profile* profile,
const BookmarkNodeData& data,
const BookmarkNode* parent_node,
int index) {
#if !defined(OS_ANDROID)
ScopedGroupBookmarkActions group_drops(profile);
#endif
BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile);
if (data.IsFromProfilePath(profile->GetPath())) {
const std::vector<const BookmarkNode*> dragged_nodes =
data.GetNodes(model, profile->GetPath());
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, true);
return ui::DragDropTypes::DRAG_COPY;
}
} // namespace chrome
|