blob: 3a72fbb3e283dc8986c9eaaf39f13a152ada68dd [file] [log] [blame]
[email protected]7f856be2008-10-29 23:38:061// Copyright (c) 2006-2008 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#ifndef CHROME_BROWSER_BOOKMARKS_BOOKMARK_UTILS_H_
6#define CHROME_BROWSER_BOOKMARKS_BOOKMARK_UTILS_H_
7
8#include <vector>
9
10#include "chrome/browser/bookmarks/bookmark_drag_data.h"
11#include "webkit/glue/window_open_disposition.h"
12
13class BookmarkNode;
14class PageNavigator;
15class Profile;
16
[email protected]7f856be2008-10-29 23:38:0617// A collection of bookmark utility functions used by various parts of the UI
18// that show bookmarks: bookmark manager, bookmark bar view ...
19namespace bookmark_utils {
20
[email protected]f28cbb72008-11-04 19:29:0821// Calculates the drop operation given |source_operations| and the ideal
22// set of drop operations (|operations|). This prefers the following ordering:
23// COPY, LINK then MOVE.
24int PreferredDropOperation(int source_operations, int operations);
[email protected]7f856be2008-10-29 23:38:0625
26// Returns true if the bookmark data can be dropped on |drop_parent| at
27// |index|. A drop from a separate profile is always allowed, where as
28// a drop from the same profile is only allowed if none of the nodes in
29// |data| are an ancestor of |drop_parent| and one of the nodes isn't already
30// a child of |drop_parent| at |index|.
31bool IsValidDropLocation(Profile* profile,
32 const BookmarkDragData& data,
33 BookmarkNode* drop_parent,
34 int index);
35
36// Clones drag data, adding newly created nodes to |parent| starting at
37// |index_to_add_at|.
38void CloneDragData(BookmarkModel* model,
39 const std::vector<BookmarkDragData::Element>& elements,
40 BookmarkNode* parent,
41 int index_to_add_at);
42
43// Recursively opens all bookmarks. |initial_disposition| dictates how the
44// first URL is opened, all subsequent URLs are opened as background tabs.
45// |navigator| is used to open the URLs. If |navigator| is NULL the last
46// tabbed browser with the profile |profile| is used. If there is no browser
47// with the specified profile a new one is created.
48void OpenAll(HWND parent,
49 Profile* profile,
50 PageNavigator* navigator,
51 const std::vector<BookmarkNode*>& nodes,
52 WindowOpenDisposition initial_disposition);
53
54// Convenience for opening a single BookmarkNode.
55void OpenAll(HWND parent,
56 Profile* profile,
57 PageNavigator* navigator,
58 BookmarkNode* node,
59 WindowOpenDisposition initial_disposition);
60
[email protected]fafc8a422008-11-07 17:53:0961// Copies nodes onto the clipboard. If |remove_nodes| is true the nodes are
62// removed after copied to the clipboard. The nodes are copied in such a way
63// that if pasted again copies are made.
64void CopyToClipboard(BookmarkModel* model,
65 const std::vector<BookmarkNode*>& nodes,
66 bool remove_nodes);
67
68// Pastes from the clipboard. The new nodes are added to |parent|, unless
69// |parent| is null in which case this does nothing. The nodes are inserted
70// at |index|. If |index| is -1 the nodes are added to the end.
71void PasteFromClipboard(BookmarkModel* model,
72 BookmarkNode* parent,
73 int index);
74
75// Returns true if the user can copy from the pasteboard.
76bool CanPasteFromClipboard(BookmarkNode* node);
77
[email protected]7f856be2008-10-29 23:38:0678} // namespace bookmark_utils
79
80#endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_UTILS_H_