[email protected] | 7f856be | 2008-10-29 23:38:06 | [diff] [blame] | 1 | // 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 | |
| 13 | class BookmarkNode; |
| 14 | class PageNavigator; |
| 15 | class Profile; |
| 16 | |
[email protected] | 7f856be | 2008-10-29 23:38:06 | [diff] [blame] | 17 | // A collection of bookmark utility functions used by various parts of the UI |
| 18 | // that show bookmarks: bookmark manager, bookmark bar view ... |
| 19 | namespace bookmark_utils { |
| 20 | |
[email protected] | f28cbb7 | 2008-11-04 19:29:08 | [diff] [blame] | 21 | // 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. |
| 24 | int PreferredDropOperation(int source_operations, int operations); |
[email protected] | 7f856be | 2008-10-29 23:38:06 | [diff] [blame] | 25 | |
| 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|. |
| 31 | bool 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|. |
| 38 | void 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. |
| 48 | void 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. |
| 55 | void OpenAll(HWND parent, |
| 56 | Profile* profile, |
| 57 | PageNavigator* navigator, |
| 58 | BookmarkNode* node, |
| 59 | WindowOpenDisposition initial_disposition); |
| 60 | |
[email protected] | fafc8a42 | 2008-11-07 17:53:09 | [diff] [blame^] | 61 | // 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. |
| 64 | void 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. |
| 71 | void PasteFromClipboard(BookmarkModel* model, |
| 72 | BookmarkNode* parent, |
| 73 | int index); |
| 74 | |
| 75 | // Returns true if the user can copy from the pasteboard. |
| 76 | bool CanPasteFromClipboard(BookmarkNode* node); |
| 77 | |
[email protected] | 7f856be | 2008-10-29 23:38:06 | [diff] [blame] | 78 | } // namespace bookmark_utils |
| 79 | |
| 80 | #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_UTILS_H_ |