OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "components/bookmarks/browser/bookmark_utils.h" | 5 #include "components/bookmarks/browser/bookmark_utils.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 return true; | 503 return true; |
504 } | 504 } |
505 return false; | 505 return false; |
506 } | 506 } |
507 | 507 |
508 const BookmarkNode* GetBookmarkNodeByID(const BookmarkModel* model, int64 id) { | 508 const BookmarkNode* GetBookmarkNodeByID(const BookmarkModel* model, int64 id) { |
509 // TODO(sky): TreeNode needs a method that visits all nodes using a predicate. | 509 // TODO(sky): TreeNode needs a method that visits all nodes using a predicate. |
510 return GetNodeByID(model->root_node(), id); | 510 return GetNodeByID(model->root_node(), id); |
511 } | 511 } |
512 | 512 |
| 513 bool IsDescendantOf(const bookmarks::BookmarkNode* node, |
| 514 const bookmarks::BookmarkNode* root) { |
| 515 return node && node->HasAncestor(root); |
| 516 } |
| 517 |
| 518 bool HasDescendantsOf(const std::vector<const bookmarks::BookmarkNode*>& list, |
| 519 const bookmarks::BookmarkNode* root) { |
| 520 for (const BookmarkNode* node : list) { |
| 521 if (IsDescendantOf(node, root)) |
| 522 return true; |
| 523 } |
| 524 return false; |
| 525 } |
| 526 |
513 } // namespace bookmarks | 527 } // namespace bookmarks |
OLD | NEW |