Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Unified Diff: chrome/browser/ui/bookmarks/bookmark_utils_desktop.cc

Issue 2809003002: Making bookmark folder context menu display the number of bookmarks that will be opened by Open All (Closed)
Patch Set: All changes to add count to context menu Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/bookmarks/bookmark_utils_desktop.cc
diff --git a/chrome/browser/ui/bookmarks/bookmark_utils_desktop.cc b/chrome/browser/ui/bookmarks/bookmark_utils_desktop.cc
index e80f31904d26a0f5088d37c087fe9d0875d19f63..a86888519a107f86ee9da76daee8ea32fdcbbf45 100644
--- a/chrome/browser/ui/bookmarks/bookmark_utils_desktop.cc
+++ b/chrome/browser/ui/bookmarks/bookmark_utils_desktop.cc
@@ -227,6 +227,38 @@ void OpenAll(gfx::NativeWindow parent,
OpenAll(parent, navigator, nodes, initial_disposition, browser_context);
}
+int OpenCount(gfx::NativeWindow parent,
+ const std::vector<const bookmarks::BookmarkNode*>& nodes,
+ bool offTheRecord,
+ content::BrowserContext* browser_context) {
+ int count = 0;
+ if (!ShouldOpenAll(parent, nodes))
+ return count;
+ // Counts all |nodes| of type URL and any children of |nodes| that are of type
+ // URL.
+ OpenURLIterator iterator(nodes);
+ while (iterator.has_next()) {
Peter Kasting 2017/04/13 04:52:09 This feels very copy-and-pasted from OpenAll(). I
Paezagon 2017/04/14 01:00:29 I have added a second get vector function that ret
+ const GURL* url = iterator.NextURL();
+ // When |initial_disposition| is OFF_THE_RECORD, a node which can't be
+ // opened in incognito window, it is detected using |browser_context|, is
+ // not opened.
Peter Kasting 2017/04/13 04:52:09 This comment doesn't make much sense. I realize y
Paezagon 2017/04/14 01:00:29 Done.
+ if (offTheRecord && !IsURLAllowedInIncognito(*url, browser_context))
+ continue;
+
+ count++;
+ }
+ return count;
+}
+
+int OpenCount(gfx::NativeWindow parent,
+ const BookmarkNode* node,
+ bool offTheRecord,
+ content::BrowserContext* browser_context) {
+ std::vector<const BookmarkNode*> nodes;
+ nodes.push_back(node);
+ return OpenCount(parent, nodes, offTheRecord, browser_context);
Peter Kasting 2017/04/13 04:52:09 Nit: Simpler: return OpenCount(parent, {node},
Paezagon 2017/04/14 01:00:29 When I make the change, the compiler complains tha
Peter Kasting 2017/04/14 08:17:14 Might need to do something like: return OpenCou
Paezagon 2017/04/14 18:47:24 Done.
+}
+
bool ConfirmDeleteBookmarkNode(const BookmarkNode* node,
gfx::NativeWindow window) {
DCHECK(node && node->is_folder() && !node->empty());

Powered by Google App Engine
This is Rietveld 408576698