Add ENABLE_MEDIA_ROUTER define to builds other than Android and iOS.
[chromium-blink-merge.git] / chrome / browser / ui / bookmarks / bookmark_utils.h
blobdbd7d0f732c9e478b609c6ed7a20ffaf7905d2d3
1 // Copyright (c) 2012 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.
5 #ifndef CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_UTILS_H_
6 #define CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_UTILS_H_
8 #include <vector>
10 #include "base/strings/string16.h"
11 #include "chrome/browser/ui/host_desktop.h"
12 #include "ui/base/window_open_disposition.h"
13 #include "ui/gfx/native_widget_types.h"
15 class Browser;
16 class GURL;
17 class PrefService;
18 class Profile;
20 namespace bookmarks {
21 class BookmarkNode;
22 struct BookmarkNodeData;
25 namespace content {
26 class BrowserContext;
27 class PageNavigator;
28 class WebContents;
31 namespace ui {
32 class DropTargetEvent;
35 namespace chrome {
37 // Number of bookmarks we'll open before prompting the user to see if they
38 // really want to open all.
40 // NOTE: treat this as a const. It is not const so unit tests can change the
41 // value.
42 extern int num_bookmark_urls_before_prompting;
44 // Opens all the bookmarks in |nodes| that are of type url and all the child
45 // bookmarks that are of type url for folders in |nodes|. |initial_disposition|
46 // dictates how the first URL is opened, all subsequent URLs are opened as
47 // background tabs. |navigator| is used to open the URLs.
48 void OpenAll(gfx::NativeWindow parent,
49 content::PageNavigator* navigator,
50 const std::vector<const bookmarks::BookmarkNode*>& nodes,
51 WindowOpenDisposition initial_disposition,
52 content::BrowserContext* browser_context);
54 // Convenience for OpenAll() with a single BookmarkNode.
55 void OpenAll(gfx::NativeWindow parent,
56 content::PageNavigator* navigator,
57 const bookmarks::BookmarkNode* node,
58 WindowOpenDisposition initial_disposition,
59 content::BrowserContext* browser_context);
61 // Asks the user before deleting a non-empty bookmark folder.
62 bool ConfirmDeleteBookmarkNode(const bookmarks::BookmarkNode* node,
63 gfx::NativeWindow window);
65 // Shows the bookmark all tabs dialog.
66 void ShowBookmarkAllTabsDialog(Browser* browser);
68 // Returns true if OpenAll() can open at least one bookmark of type url
69 // in |selection|.
70 bool HasBookmarkURLs(
71 const std::vector<const bookmarks::BookmarkNode*>& selection);
73 // Returns true if OpenAll() can open at least one bookmark of type url
74 // in |selection| with incognito mode.
75 bool HasBookmarkURLsAllowedInIncognitoMode(
76 const std::vector<const bookmarks::BookmarkNode*>& selection,
77 content::BrowserContext* browser_context);
79 // Returns the bookmarkable URL for |web_contents|.
80 // This is normally the current URL, but when the page is the Instant Extended
81 // New Tab Page, the precise current URL may reflect various flags or other
82 // implementation details that don't represent data we should store
83 // in the bookmark. In this case we instead return a URL that always
84 // means "NTP" instead of the current URL.
85 GURL GetURLToBookmark(content::WebContents* web_contents);
87 // Fills in the URL and title for a bookmark of |web_contents|.
88 void GetURLAndTitleToBookmark(content::WebContents* web_contents,
89 GURL* url,
90 base::string16* title);
92 // Toggles whether the bookmark bar is shown only on the new tab page or on
93 // all tabs. This is a preference modifier, not a visual modifier.
94 void ToggleBookmarkBarWhenVisible(content::BrowserContext* browser_context);
96 // Returns a formatted version of |url| appropriate to display to a user with
97 // the given |prefs|, which may be NULL. When re-parsing this URL, clients
98 // should call url_fixer::FixupURL().
99 base::string16 FormatBookmarkURLForDisplay(const GURL& url,
100 const PrefService* prefs);
102 // Returns whether the Apps shortcut is enabled. If true, then the visibility
103 // of the Apps shortcut should be controllable via an item in the bookmark
104 // context menu.
105 bool IsAppsShortcutEnabled(Profile* profile,
106 chrome::HostDesktopType host_desktop_type);
108 // Returns true if the Apps shortcut should be displayed in the bookmark bar.
109 bool ShouldShowAppsShortcutInBookmarkBar(
110 Profile* profile,
111 chrome::HostDesktopType host_desktop_type);
113 // Whether the menu item and shortcut to bookmark a page should be removed from
114 // the user interface.
115 bool ShouldRemoveBookmarkThisPageUI(Profile* profile);
117 // Whether the menu item and shortcut to bookmark open pages should be removed
118 // from the user interface.
119 bool ShouldRemoveBookmarkOpenPagesUI(Profile* profile);
121 // Returns the drag operations for the specified node.
122 int GetBookmarkDragOperation(content::BrowserContext* browser_context,
123 const bookmarks::BookmarkNode* node);
125 // Calculates the drop operation given |source_operations| and the ideal
126 // set of drop operations (|operations|). This prefers the following ordering:
127 // COPY, LINK then MOVE.
128 int GetPreferredBookmarkDropOperation(int source_operations, int operations);
130 // Returns the preferred drop operation on a bookmark menu/bar.
131 // |parent| is the parent node the drop is to occur on and |index| the index the
132 // drop is over.
133 int GetBookmarkDropOperation(Profile* profile,
134 const ui::DropTargetEvent& event,
135 const bookmarks::BookmarkNodeData& data,
136 const bookmarks::BookmarkNode* parent,
137 int index);
139 // Returns true if the bookmark data can be dropped on |drop_parent| at
140 // |index|. A drop from a separate profile is always allowed, where as
141 // a drop from the same profile is only allowed if none of the nodes in
142 // |data| are an ancestor of |drop_parent| and one of the nodes isn't already
143 // a child of |drop_parent| at |index|.
144 bool IsValidBookmarkDropLocation(Profile* profile,
145 const bookmarks::BookmarkNodeData& data,
146 const bookmarks::BookmarkNode* drop_parent,
147 int index);
149 } // namespace chrome
151 #endif // CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_UTILS_H_