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

Unified Diff: chrome/browser/bookmarks/bookmark_utils.cc

Issue 242823002: Extract GetNodeByID() method from BookmarkModel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: revert a change in bookmarks_helper.cc that colides with a wstring and cq does not like that Created 6 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/bookmarks/bookmark_utils.cc
diff --git a/chrome/browser/bookmarks/bookmark_utils.cc b/chrome/browser/bookmarks/bookmark_utils.cc
index 01c00475b8983905cd1996c005f417eb3f488dc5..c41a933e8c23f17c0b18e56319b44343b92a473a 100644
--- a/chrome/browser/bookmarks/bookmark_utils.cc
+++ b/chrome/browser/bookmarks/bookmark_utils.cc
@@ -111,6 +111,18 @@ bool HasSelectedAncestor(BookmarkModel* model,
return HasSelectedAncestor(model, selected_nodes, node->parent());
}
+const BookmarkNode* GetNodeByID(const BookmarkNode* node, int64 id) {
+ if (node->id() == id)
+ return node;
+
+ for (int i = 0, child_count = node->child_count(); i < child_count; ++i) {
+ const BookmarkNode* result = GetNodeByID(node->GetChild(i), id);
+ if (result)
+ return result;
+ }
+ return NULL;
+}
+
} // namespace
namespace bookmark_utils {
@@ -340,7 +352,7 @@ void DeleteBookmarkFolders(BookmarkModel* model,
for (std::vector<int64>::const_iterator iter = ids.begin();
iter != ids.end();
++iter) {
- const BookmarkNode* node = model->GetNodeByID(*iter);
+ const BookmarkNode* node = GetBookmarkNodeByID(model, *iter);
if (!node)
continue;
const BookmarkNode* parent = node->parent();
@@ -375,3 +387,8 @@ void RemoveAllBookmarks(BookmarkModel* model, const GURL& url) {
}
} // namespace bookmark_utils
+
+const BookmarkNode* GetBookmarkNodeByID(const BookmarkModel* model, int64 id) {
+ // TODO(sky): TreeNode needs a method that visits all nodes using a predicate.
+ return GetNodeByID(model->root_node(), id);
+}

Powered by Google App Engine
This is Rietveld 408576698