blob: 0711638f996f6034166663034bc2d6c693f4a1a0 [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
17namespace views {
18class DropTargetEvent;
19}
20
21// A collection of bookmark utility functions used by various parts of the UI
22// that show bookmarks: bookmark manager, bookmark bar view ...
23namespace bookmark_utils {
24
25// Calculates the drop operation given the event and supported set of
26// operations. This prefers the following ordering: COPY, LINK then MOVE.
27int PreferredDropOperation(const views::DropTargetEvent& event,
28 int operation);
29
30// Returns true if the bookmark data can be dropped on |drop_parent| at
31// |index|. A drop from a separate profile is always allowed, where as
32// a drop from the same profile is only allowed if none of the nodes in
33// |data| are an ancestor of |drop_parent| and one of the nodes isn't already
34// a child of |drop_parent| at |index|.
35bool IsValidDropLocation(Profile* profile,
36 const BookmarkDragData& data,
37 BookmarkNode* drop_parent,
38 int index);
39
40// Clones drag data, adding newly created nodes to |parent| starting at
41// |index_to_add_at|.
42void CloneDragData(BookmarkModel* model,
43 const std::vector<BookmarkDragData::Element>& elements,
44 BookmarkNode* parent,
45 int index_to_add_at);
46
47// Recursively opens all bookmarks. |initial_disposition| dictates how the
48// first URL is opened, all subsequent URLs are opened as background tabs.
49// |navigator| is used to open the URLs. If |navigator| is NULL the last
50// tabbed browser with the profile |profile| is used. If there is no browser
51// with the specified profile a new one is created.
52void OpenAll(HWND parent,
53 Profile* profile,
54 PageNavigator* navigator,
55 const std::vector<BookmarkNode*>& nodes,
56 WindowOpenDisposition initial_disposition);
57
58// Convenience for opening a single BookmarkNode.
59void OpenAll(HWND parent,
60 Profile* profile,
61 PageNavigator* navigator,
62 BookmarkNode* node,
63 WindowOpenDisposition initial_disposition);
64
65} // namespace bookmark_utils
66
67#endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_UTILS_H_