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_
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"
29 // Number of bookmarks we'll open before prompting the user to see if they
30 // really want to open all.
32 // NOTE: treat this as a const. It is not const so unit tests can change the
34 extern int num_bookmark_urls_before_prompting
;
36 // Opens all the bookmarks in |nodes| that are of type url and all the child
37 // bookmarks that are of type url for folders in |nodes|. |initial_disposition|
38 // dictates how the first URL is opened, all subsequent URLs are opened as
39 // background tabs. |navigator| is used to open the URLs.
40 void OpenAll(gfx::NativeWindow parent
,
41 content::PageNavigator
* navigator
,
42 const std::vector
<const BookmarkNode
*>& nodes
,
43 WindowOpenDisposition initial_disposition
,
44 content::BrowserContext
* browser_context
);
46 // Convenience for OpenAll() with a single BookmarkNode.
47 void OpenAll(gfx::NativeWindow parent
,
48 content::PageNavigator
* navigator
,
49 const BookmarkNode
* node
,
50 WindowOpenDisposition initial_disposition
,
51 content::BrowserContext
* browser_context
);
53 // Asks the user before deleting a non-empty bookmark folder.
54 bool ConfirmDeleteBookmarkNode(const BookmarkNode
* node
,
55 gfx::NativeWindow window
);
57 // Shows the bookmark all tabs dialog.
58 void ShowBookmarkAllTabsDialog(Browser
* browser
);
60 // Returns true if OpenAll() can open at least one bookmark of type url
62 bool HasBookmarkURLs(const std::vector
<const BookmarkNode
*>& selection
);
64 // Returns true if OpenAll() can open at least one bookmark of type url
65 // in |selection| with incognito mode.
66 bool HasBookmarkURLsAllowedInIncognitoMode(
67 const std::vector
<const BookmarkNode
*>& selection
,
68 content::BrowserContext
* browser_context
);
70 // Returns the bookmarkable URL for |web_contents|.
71 // This is normally the current URL, but when the page is the Instant Extended
72 // New Tab Page, the precise current URL may reflect various flags or other
73 // implementation details that don't represent data we should store
74 // in the bookmark. In this case we instead return a URL that always
75 // means "NTP" instead of the current URL.
76 GURL
GetURLToBookmark(content::WebContents
* web_contents
);
78 // Fills in the URL and title for a bookmark of |web_contents|.
79 void GetURLAndTitleToBookmark(content::WebContents
* web_contents
,
81 base::string16
* title
);
83 // Toggles whether the bookmark bar is shown only on the new tab page or on
84 // all tabs. This is a preference modifier, not a visual modifier.
85 void ToggleBookmarkBarWhenVisible(content::BrowserContext
* browser_context
);
87 // Returns a formatted version of |url| appropriate to display to a user with
88 // the given |prefs|, which may be NULL. When re-parsing this URL, clients
89 // should call URLFixerUpper::FixupURL().
90 base::string16
FormatBookmarkURLForDisplay(const GURL
& url
,
91 const PrefService
* prefs
);
93 // Returns whether the Apps shortcut is enabled. If true, then the visibility
94 // of the Apps shortcut should be controllable via an item in the bookmark
96 bool IsAppsShortcutEnabled(Profile
* profile
,
97 chrome::HostDesktopType host_desktop_type
);
99 // Returns true if the Apps shortcut should be displayed in the bookmark bar.
100 bool ShouldShowAppsShortcutInBookmarkBar(
102 chrome::HostDesktopType host_desktop_type
);
104 } // namespace chrome
106 #endif // CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_UTILS_H_