| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_UTILS_H_ | 5 #ifndef CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_UTILS_H_ |
| 6 #define CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_UTILS_H_ | 6 #define CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_UTILS_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| 11 #include "chrome/browser/ui/host_desktop.h" | 11 #include "chrome/browser/ui/host_desktop.h" |
| 12 #include "ui/base/window_open_disposition.h" | 12 #include "ui/base/window_open_disposition.h" |
| 13 #include "ui/gfx/native_widget_types.h" | 13 #include "ui/gfx/native_widget_types.h" |
| 14 | 14 |
| 15 class BookmarkNode; | |
| 16 class Browser; | 15 class Browser; |
| 17 class GURL; | 16 class GURL; |
| 18 class PrefService; | 17 class PrefService; |
| 19 class Profile; | 18 class Profile; |
| 20 | 19 |
| 21 namespace bookmarks { | 20 namespace bookmarks { |
| 21 class BookmarkNode; |
| 22 struct BookmarkNodeData; | 22 struct BookmarkNodeData; |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace content { | 25 namespace content { |
| 26 class BrowserContext; | 26 class BrowserContext; |
| 27 class PageNavigator; | 27 class PageNavigator; |
| 28 class WebContents; | 28 class WebContents; |
| 29 } | 29 } |
| 30 | 30 |
| 31 namespace extensions { | |
| 32 class CommandService; | |
| 33 class Extension; | |
| 34 } | |
| 35 | |
| 36 namespace ui { | 31 namespace ui { |
| 37 class DropTargetEvent; | 32 class DropTargetEvent; |
| 38 } | 33 } |
| 39 | 34 |
| 40 namespace chrome { | 35 namespace chrome { |
| 41 | 36 |
| 42 // Number of bookmarks we'll open before prompting the user to see if they | 37 // Number of bookmarks we'll open before prompting the user to see if they |
| 43 // really want to open all. | 38 // really want to open all. |
| 44 // | 39 // |
| 45 // NOTE: treat this as a const. It is not const so unit tests can change the | 40 // NOTE: treat this as a const. It is not const so unit tests can change the |
| 46 // value. | 41 // value. |
| 47 extern int num_bookmark_urls_before_prompting; | 42 extern int num_bookmark_urls_before_prompting; |
| 48 | 43 |
| 49 // Opens all the bookmarks in |nodes| that are of type url and all the child | 44 // Opens all the bookmarks in |nodes| that are of type url and all the child |
| 50 // bookmarks that are of type url for folders in |nodes|. |initial_disposition| | 45 // bookmarks that are of type url for folders in |nodes|. |initial_disposition| |
| 51 // dictates how the first URL is opened, all subsequent URLs are opened as | 46 // dictates how the first URL is opened, all subsequent URLs are opened as |
| 52 // background tabs. |navigator| is used to open the URLs. | 47 // background tabs. |navigator| is used to open the URLs. |
| 53 void OpenAll(gfx::NativeWindow parent, | 48 void OpenAll(gfx::NativeWindow parent, |
| 54 content::PageNavigator* navigator, | 49 content::PageNavigator* navigator, |
| 55 const std::vector<const BookmarkNode*>& nodes, | 50 const std::vector<const bookmarks::BookmarkNode*>& nodes, |
| 56 WindowOpenDisposition initial_disposition, | 51 WindowOpenDisposition initial_disposition, |
| 57 content::BrowserContext* browser_context); | 52 content::BrowserContext* browser_context); |
| 58 | 53 |
| 59 // Convenience for OpenAll() with a single BookmarkNode. | 54 // Convenience for OpenAll() with a single BookmarkNode. |
| 60 void OpenAll(gfx::NativeWindow parent, | 55 void OpenAll(gfx::NativeWindow parent, |
| 61 content::PageNavigator* navigator, | 56 content::PageNavigator* navigator, |
| 62 const BookmarkNode* node, | 57 const bookmarks::BookmarkNode* node, |
| 63 WindowOpenDisposition initial_disposition, | 58 WindowOpenDisposition initial_disposition, |
| 64 content::BrowserContext* browser_context); | 59 content::BrowserContext* browser_context); |
| 65 | 60 |
| 66 // Asks the user before deleting a non-empty bookmark folder. | 61 // Asks the user before deleting a non-empty bookmark folder. |
| 67 bool ConfirmDeleteBookmarkNode(const BookmarkNode* node, | 62 bool ConfirmDeleteBookmarkNode(const bookmarks::BookmarkNode* node, |
| 68 gfx::NativeWindow window); | 63 gfx::NativeWindow window); |
| 69 | 64 |
| 70 // Shows the bookmark all tabs dialog. | 65 // Shows the bookmark all tabs dialog. |
| 71 void ShowBookmarkAllTabsDialog(Browser* browser); | 66 void ShowBookmarkAllTabsDialog(Browser* browser); |
| 72 | 67 |
| 73 // Returns true if OpenAll() can open at least one bookmark of type url | 68 // Returns true if OpenAll() can open at least one bookmark of type url |
| 74 // in |selection|. | 69 // in |selection|. |
| 75 bool HasBookmarkURLs(const std::vector<const BookmarkNode*>& selection); | 70 bool HasBookmarkURLs( |
| 71 const std::vector<const bookmarks::BookmarkNode*>& selection); |
| 76 | 72 |
| 77 // Returns true if OpenAll() can open at least one bookmark of type url | 73 // Returns true if OpenAll() can open at least one bookmark of type url |
| 78 // in |selection| with incognito mode. | 74 // in |selection| with incognito mode. |
| 79 bool HasBookmarkURLsAllowedInIncognitoMode( | 75 bool HasBookmarkURLsAllowedInIncognitoMode( |
| 80 const std::vector<const BookmarkNode*>& selection, | 76 const std::vector<const bookmarks::BookmarkNode*>& selection, |
| 81 content::BrowserContext* browser_context); | 77 content::BrowserContext* browser_context); |
| 82 | 78 |
| 83 // Returns the bookmarkable URL for |web_contents|. | 79 // Returns the bookmarkable URL for |web_contents|. |
| 84 // This is normally the current URL, but when the page is the Instant Extended | 80 // This is normally the current URL, but when the page is the Instant Extended |
| 85 // New Tab Page, the precise current URL may reflect various flags or other | 81 // New Tab Page, the precise current URL may reflect various flags or other |
| 86 // implementation details that don't represent data we should store | 82 // implementation details that don't represent data we should store |
| 87 // in the bookmark. In this case we instead return a URL that always | 83 // in the bookmark. In this case we instead return a URL that always |
| 88 // means "NTP" instead of the current URL. | 84 // means "NTP" instead of the current URL. |
| 89 GURL GetURLToBookmark(content::WebContents* web_contents); | 85 GURL GetURLToBookmark(content::WebContents* web_contents); |
| 90 | 86 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 117 // Whether the menu item and shortcut to bookmark a page should be removed from | 113 // Whether the menu item and shortcut to bookmark a page should be removed from |
| 118 // the user interface. | 114 // the user interface. |
| 119 bool ShouldRemoveBookmarkThisPageUI(Profile* profile); | 115 bool ShouldRemoveBookmarkThisPageUI(Profile* profile); |
| 120 | 116 |
| 121 // Whether the menu item and shortcut to bookmark open pages should be removed | 117 // Whether the menu item and shortcut to bookmark open pages should be removed |
| 122 // from the user interface. | 118 // from the user interface. |
| 123 bool ShouldRemoveBookmarkOpenPagesUI(Profile* profile); | 119 bool ShouldRemoveBookmarkOpenPagesUI(Profile* profile); |
| 124 | 120 |
| 125 // Returns the drag operations for the specified node. | 121 // Returns the drag operations for the specified node. |
| 126 int GetBookmarkDragOperation(content::BrowserContext* browser_context, | 122 int GetBookmarkDragOperation(content::BrowserContext* browser_context, |
| 127 const BookmarkNode* node); | 123 const bookmarks::BookmarkNode* node); |
| 128 | 124 |
| 129 // Calculates the drop operation given |source_operations| and the ideal | 125 // Calculates the drop operation given |source_operations| and the ideal |
| 130 // set of drop operations (|operations|). This prefers the following ordering: | 126 // set of drop operations (|operations|). This prefers the following ordering: |
| 131 // COPY, LINK then MOVE. | 127 // COPY, LINK then MOVE. |
| 132 int GetPreferredBookmarkDropOperation(int source_operations, int operations); | 128 int GetPreferredBookmarkDropOperation(int source_operations, int operations); |
| 133 | 129 |
| 134 // Returns the preferred drop operation on a bookmark menu/bar. | 130 // Returns the preferred drop operation on a bookmark menu/bar. |
| 135 // |parent| is the parent node the drop is to occur on and |index| the index the | 131 // |parent| is the parent node the drop is to occur on and |index| the index the |
| 136 // drop is over. | 132 // drop is over. |
| 137 int GetBookmarkDropOperation(Profile* profile, | 133 int GetBookmarkDropOperation(Profile* profile, |
| 138 const ui::DropTargetEvent& event, | 134 const ui::DropTargetEvent& event, |
| 139 const bookmarks::BookmarkNodeData& data, | 135 const bookmarks::BookmarkNodeData& data, |
| 140 const BookmarkNode* parent, | 136 const bookmarks::BookmarkNode* parent, |
| 141 int index); | 137 int index); |
| 142 | 138 |
| 143 // Returns true if the bookmark data can be dropped on |drop_parent| at | 139 // Returns true if the bookmark data can be dropped on |drop_parent| at |
| 144 // |index|. A drop from a separate profile is always allowed, where as | 140 // |index|. A drop from a separate profile is always allowed, where as |
| 145 // a drop from the same profile is only allowed if none of the nodes in | 141 // a drop from the same profile is only allowed if none of the nodes in |
| 146 // |data| are an ancestor of |drop_parent| and one of the nodes isn't already | 142 // |data| are an ancestor of |drop_parent| and one of the nodes isn't already |
| 147 // a child of |drop_parent| at |index|. | 143 // a child of |drop_parent| at |index|. |
| 148 bool IsValidBookmarkDropLocation(Profile* profile, | 144 bool IsValidBookmarkDropLocation(Profile* profile, |
| 149 const bookmarks::BookmarkNodeData& data, | 145 const bookmarks::BookmarkNodeData& data, |
| 150 const BookmarkNode* drop_parent, | 146 const bookmarks::BookmarkNode* drop_parent, |
| 151 int index); | 147 int index); |
| 152 | 148 |
| 153 } // namespace chrome | 149 } // namespace chrome |
| 154 | 150 |
| 155 #endif // CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_UTILS_H_ | 151 #endif // CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_UTILS_H_ |
| OLD | NEW |