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