bookmark_utils.h revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
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. 4 5#ifndef CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_UTILS_H_ 6#define CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_UTILS_H_ 7 8#include <vector> 9 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" 14 15class BookmarkNode; 16class Browser; 17class GURL; 18class PrefService; 19class Profile; 20 21namespace content { 22class BrowserContext; 23class PageNavigator; 24class WebContents; 25} 26 27namespace chrome { 28 29// Number of bookmarks we'll open before prompting the user to see if they 30// really want to open all. 31// 32// NOTE: treat this as a const. It is not const so unit tests can change the 33// value. 34extern int num_bookmark_urls_before_prompting; 35 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. 40void OpenAll(gfx::NativeWindow parent, 41 content::PageNavigator* navigator, 42 const std::vector<const BookmarkNode*>& nodes, 43 WindowOpenDisposition initial_disposition, 44 content::BrowserContext* browser_context); 45 46// Convenience for OpenAll() with a single BookmarkNode. 47void OpenAll(gfx::NativeWindow parent, 48 content::PageNavigator* navigator, 49 const BookmarkNode* node, 50 WindowOpenDisposition initial_disposition, 51 content::BrowserContext* browser_context); 52 53// Asks the user before deleting a non-empty bookmark folder. 54bool ConfirmDeleteBookmarkNode(const BookmarkNode* node, 55 gfx::NativeWindow window); 56 57// Shows the bookmark all tabs dialog. 58void ShowBookmarkAllTabsDialog(Browser* browser); 59 60// Returns true if OpenAll() can open at least one bookmark of type url 61// in |selection|. 62bool HasBookmarkURLs(const std::vector<const BookmarkNode*>& selection); 63 64// Returns true if OpenAll() can open at least one bookmark of type url 65// in |selection| with incognito mode. 66bool HasBookmarkURLsAllowedInIncognitoMode( 67 const std::vector<const BookmarkNode*>& selection, 68 content::BrowserContext* browser_context); 69 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. 76GURL GetURLToBookmark(content::WebContents* web_contents); 77 78// Fills in the URL and title for a bookmark of |web_contents|. 79void GetURLAndTitleToBookmark(content::WebContents* web_contents, 80 GURL* url, 81 base::string16* title); 82 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. 85void ToggleBookmarkBarWhenVisible(content::BrowserContext* browser_context); 86 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(). 90base::string16 FormatBookmarkURLForDisplay(const GURL& url, 91 const PrefService* prefs); 92 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 95// context menu. 96bool IsAppsShortcutEnabled(Profile* profile, 97 chrome::HostDesktopType host_desktop_type); 98 99// Returns true if the Apps shortcut should be displayed in the bookmark bar. 100bool ShouldShowAppsShortcutInBookmarkBar( 101 Profile* profile, 102 chrome::HostDesktopType host_desktop_type); 103 104} // namespace chrome 105 106#endif // CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_UTILS_H_ 107