| 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/enhanced_bookmarks/enhanced_bookmark_utils.h" | 5 #include "components/enhanced_bookmarks/enhanced_bookmark_utils.h" |
| 6 | 6 |
| 7 #include "base/i18n/string_compare.h" | 7 #include "base/i18n/string_compare.h" |
| 8 #include "base/i18n/string_search.h" | 8 #include "base/i18n/string_search.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "components/bookmarks/browser/bookmark_model.h" | 10 #include "components/bookmarks/browser/bookmark_model.h" |
| 11 #include "ui/base/models/tree_node_iterator.h" | 11 #include "ui/base/models/tree_node_iterator.h" |
| 12 | 12 |
| 13 namespace enhanced_bookmark_utils { | 13 namespace enhanced_bookmark { |
| 14 | 14 |
| 15 std::vector<const BookmarkNode*> FindBookmarksWithQuery( | 15 std::vector<const BookmarkNode*> FindBookmarksWithQuery( |
| 16 BookmarkModel* bookmark_model, | 16 BookmarkModel* bookmark_model, |
| 17 const std::string& query) { | 17 const std::string& query) { |
| 18 std::vector<const BookmarkNode*> results; | 18 std::vector<const BookmarkNode*> results; |
| 19 base::string16 query16 = base::UTF8ToUTF16(query); | 19 base::string16 query16 = base::UTF8ToUTF16(query); |
| 20 base::i18n::FixedPatternStringSearchIgnoringCaseAndAccents pattern16(query16); | 20 base::i18n::FixedPatternStringSearchIgnoringCaseAndAccents pattern16(query16); |
| 21 | 21 |
| 22 ui::TreeNodeIterator<const BookmarkNode> iterator( | 22 ui::TreeNodeIterator<const BookmarkNode> iterator( |
| 23 bookmark_model->root_node()); | 23 bookmark_model->root_node()); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 const std::vector<const BookmarkNode*> root_folders(RootLevelFolders(model)); | 117 const std::vector<const BookmarkNode*> root_folders(RootLevelFolders(model)); |
| 118 const BookmarkNode* top = node; | 118 const BookmarkNode* top = node; |
| 119 while (top && | 119 while (top && |
| 120 std::find(root_folders.begin(), root_folders.end(), top) == | 120 std::find(root_folders.begin(), root_folders.end(), top) == |
| 121 root_folders.end()) { | 121 root_folders.end()) { |
| 122 top = top->parent(); | 122 top = top->parent(); |
| 123 } | 123 } |
| 124 return top; | 124 return top; |
| 125 } | 125 } |
| 126 | 126 |
| 127 } // namespace enhanced_bookmark_utils | 127 } // namespace enhanced_bookmark |
| OLD | NEW |