Home | History | Annotate | Download | only in bookmarks
      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 
     15 class BookmarkNode;
     16 class Browser;
     17 class GURL;
     18 class PrefService;
     19 class Profile;
     20 
     21 namespace content {
     22 class BrowserContext;
     23 class PageNavigator;
     24 class WebContents;
     25 }
     26 
     27 namespace extensions {
     28 class CommandService;
     29 class Extension;
     30 }
     31 
     32 namespace chrome {
     33 
     34 // Number of bookmarks we'll open before prompting the user to see if they
     35 // really want to open all.
     36 //
     37 // NOTE: treat this as a const. It is not const so unit tests can change the
     38 // value.
     39 extern int num_bookmark_urls_before_prompting;
     40 
     41 // Opens all the bookmarks in |nodes| that are of type url and all the child
     42 // bookmarks that are of type url for folders in |nodes|. |initial_disposition|
     43 // dictates how the first URL is opened, all subsequent URLs are opened as
     44 // background tabs. |navigator| is used to open the URLs.
     45 void OpenAll(gfx::NativeWindow parent,
     46              content::PageNavigator* navigator,
     47              const std::vector<const BookmarkNode*>& nodes,
     48              WindowOpenDisposition initial_disposition,
     49              content::BrowserContext* browser_context);
     50 
     51 // Convenience for OpenAll() with a single BookmarkNode.
     52 void OpenAll(gfx::NativeWindow parent,
     53              content::PageNavigator* navigator,
     54              const BookmarkNode* node,
     55              WindowOpenDisposition initial_disposition,
     56              content::BrowserContext* browser_context);
     57 
     58 // Asks the user before deleting a non-empty bookmark folder.
     59 bool ConfirmDeleteBookmarkNode(const BookmarkNode* node,
     60                                gfx::NativeWindow window);
     61 
     62 // Shows the bookmark all tabs dialog.
     63 void ShowBookmarkAllTabsDialog(Browser* browser);
     64 
     65 // Returns true if OpenAll() can open at least one bookmark of type url
     66 // in |selection|.
     67 bool HasBookmarkURLs(const std::vector<const BookmarkNode*>& selection);
     68 
     69 // Returns true if OpenAll() can open at least one bookmark of type url
     70 // in |selection| with incognito mode.
     71 bool HasBookmarkURLsAllowedInIncognitoMode(
     72     const std::vector<const BookmarkNode*>& selection,
     73     content::BrowserContext* browser_context);
     74 
     75 // Returns the bookmarkable URL for |web_contents|.
     76 // This is normally the current URL, but when the page is the Instant Extended
     77 // New Tab Page, the precise current URL may reflect various flags or other
     78 // implementation details that don't represent data we should store
     79 // in the bookmark.  In this case we instead return a URL that always
     80 // means "NTP" instead of the current URL.
     81 GURL GetURLToBookmark(content::WebContents* web_contents);
     82 
     83 // Fills in the URL and title for a bookmark of |web_contents|.
     84 void GetURLAndTitleToBookmark(content::WebContents* web_contents,
     85                               GURL* url,
     86                               base::string16* title);
     87 
     88 // Toggles whether the bookmark bar is shown only on the new tab page or on
     89 // all tabs. This is a preference modifier, not a visual modifier.
     90 void ToggleBookmarkBarWhenVisible(content::BrowserContext* browser_context);
     91 
     92 // Returns a formatted version of |url| appropriate to display to a user with
     93 // the given |prefs|, which may be NULL.  When re-parsing this URL, clients
     94 // should call url_fixer::FixupURL().
     95 base::string16 FormatBookmarkURLForDisplay(const GURL& url,
     96                                            const PrefService* prefs);
     97 
     98 // Returns whether the Apps shortcut is enabled. If true, then the visibility
     99 // of the Apps shortcut should be controllable via an item in the bookmark
    100 // context menu.
    101 bool IsAppsShortcutEnabled(Profile* profile,
    102                            chrome::HostDesktopType host_desktop_type);
    103 
    104 // Returns true if the Apps shortcut should be displayed in the bookmark bar.
    105 bool ShouldShowAppsShortcutInBookmarkBar(
    106     Profile* profile,
    107     chrome::HostDesktopType host_desktop_type);
    108 
    109 // Whether the menu item and shortcut to bookmark a page should be removed from
    110 // the user interface.
    111 bool ShouldRemoveBookmarkThisPageUI(Profile* profile);
    112 
    113 // Whether the menu item and shortcut to bookmark open pages should be removed
    114 // from the user interface.
    115 bool ShouldRemoveBookmarkOpenPagesUI(Profile* profile);
    116 
    117 }  // namespace chrome
    118 
    119 #endif  // CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_UTILS_H_
    120