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_model.h" | 5 #include "components/bookmarks/browser/bookmark_model.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/i18n/string_compare.h" | 13 #include "base/i18n/string_compare.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
17 #include "base/metrics/histogram_macros.h" | 17 #include "base/metrics/histogram_macros.h" |
18 #include "base/profiler/scoped_tracker.h" | 18 #include "base/profiler/scoped_tracker.h" |
19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
20 #include "components/bookmarks/browser/bookmark_expanded_state_tracker.h" | 20 #include "components/bookmarks/browser/bookmark_expanded_state_tracker.h" |
21 #include "components/bookmarks/browser/bookmark_index.h" | |
22 #include "components/bookmarks/browser/bookmark_match.h" | |
23 #include "components/bookmarks/browser/bookmark_model_observer.h" | 21 #include "components/bookmarks/browser/bookmark_model_observer.h" |
24 #include "components/bookmarks/browser/bookmark_node_data.h" | 22 #include "components/bookmarks/browser/bookmark_node_data.h" |
25 #include "components/bookmarks/browser/bookmark_storage.h" | 23 #include "components/bookmarks/browser/bookmark_storage.h" |
26 #include "components/bookmarks/browser/bookmark_undo_delegate.h" | 24 #include "components/bookmarks/browser/bookmark_undo_delegate.h" |
27 #include "components/bookmarks/browser/bookmark_utils.h" | 25 #include "components/bookmarks/browser/bookmark_utils.h" |
| 26 #include "components/bookmarks/browser/titled_url_index.h" |
| 27 #include "components/bookmarks/browser/titled_url_match.h" |
28 #include "components/bookmarks/browser/typed_count_sorter.h" | 28 #include "components/bookmarks/browser/typed_count_sorter.h" |
29 #include "components/favicon_base/favicon_types.h" | 29 #include "components/favicon_base/favicon_types.h" |
30 #include "grit/components_strings.h" | 30 #include "grit/components_strings.h" |
31 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
32 #include "ui/gfx/favicon_size.h" | 32 #include "ui/gfx/favicon_size.h" |
33 | 33 |
34 using base::Time; | 34 using base::Time; |
35 | 35 |
36 namespace bookmarks { | 36 namespace bookmarks { |
37 | 37 |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 if (store_.get()) | 711 if (store_.get()) |
712 store_->ScheduleSave(); | 712 store_->ScheduleSave(); |
713 } | 713 } |
714 | 714 |
715 void BookmarkModel::ResetDateFolderModified(const BookmarkNode* node) { | 715 void BookmarkModel::ResetDateFolderModified(const BookmarkNode* node) { |
716 SetDateFolderModified(node, Time()); | 716 SetDateFolderModified(node, Time()); |
717 } | 717 } |
718 | 718 |
719 void BookmarkModel::GetBookmarksMatching(const base::string16& text, | 719 void BookmarkModel::GetBookmarksMatching(const base::string16& text, |
720 size_t max_count, | 720 size_t max_count, |
721 std::vector<BookmarkMatch>* matches) { | 721 std::vector<TitledUrlMatch>* matches) { |
722 GetBookmarksMatching(text, max_count, | 722 GetBookmarksMatching(text, max_count, |
723 query_parser::MatchingAlgorithm::DEFAULT, matches); | 723 query_parser::MatchingAlgorithm::DEFAULT, matches); |
724 } | 724 } |
725 | 725 |
726 void BookmarkModel::GetBookmarksMatching( | 726 void BookmarkModel::GetBookmarksMatching( |
727 const base::string16& text, | 727 const base::string16& text, |
728 size_t max_count, | 728 size_t max_count, |
729 query_parser::MatchingAlgorithm matching_algorithm, | 729 query_parser::MatchingAlgorithm matching_algorithm, |
730 std::vector<BookmarkMatch>* matches) { | 730 std::vector<TitledUrlMatch>* matches) { |
731 if (!loaded_) | 731 if (!loaded_) |
732 return; | 732 return; |
733 | 733 |
734 index_->GetResultsMatching(text, max_count, matching_algorithm, matches); | 734 index_->GetResultsMatching(text, max_count, matching_algorithm, matches); |
735 } | 735 } |
736 | 736 |
737 void BookmarkModel::ClearStore() { | 737 void BookmarkModel::ClearStore() { |
738 store_.reset(); | 738 store_.reset(); |
739 } | 739 } |
740 | 740 |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1109 BookmarkPermanentNode* bb_node = | 1109 BookmarkPermanentNode* bb_node = |
1110 CreatePermanentNode(BookmarkNode::BOOKMARK_BAR); | 1110 CreatePermanentNode(BookmarkNode::BOOKMARK_BAR); |
1111 BookmarkPermanentNode* other_node = | 1111 BookmarkPermanentNode* other_node = |
1112 CreatePermanentNode(BookmarkNode::OTHER_NODE); | 1112 CreatePermanentNode(BookmarkNode::OTHER_NODE); |
1113 BookmarkPermanentNode* mobile_node = | 1113 BookmarkPermanentNode* mobile_node = |
1114 CreatePermanentNode(BookmarkNode::MOBILE); | 1114 CreatePermanentNode(BookmarkNode::MOBILE); |
1115 std::unique_ptr<TitledUrlNodeSorter> node_sorter = | 1115 std::unique_ptr<TitledUrlNodeSorter> node_sorter = |
1116 base::MakeUnique<TypedCountSorter>(client_.get()); | 1116 base::MakeUnique<TypedCountSorter>(client_.get()); |
1117 return std::unique_ptr<BookmarkLoadDetails>(new BookmarkLoadDetails( | 1117 return std::unique_ptr<BookmarkLoadDetails>(new BookmarkLoadDetails( |
1118 bb_node, other_node, mobile_node, client_->GetLoadExtraNodesCallback(), | 1118 bb_node, other_node, mobile_node, client_->GetLoadExtraNodesCallback(), |
1119 new BookmarkIndex(std::move(node_sorter)), next_node_id_)); | 1119 new TitledUrlIndex(std::move(node_sorter)), next_node_id_)); |
1120 } | 1120 } |
1121 | 1121 |
1122 void BookmarkModel::SetUndoDelegate(BookmarkUndoDelegate* undo_delegate) { | 1122 void BookmarkModel::SetUndoDelegate(BookmarkUndoDelegate* undo_delegate) { |
1123 undo_delegate_ = undo_delegate; | 1123 undo_delegate_ = undo_delegate; |
1124 if (undo_delegate_) | 1124 if (undo_delegate_) |
1125 undo_delegate_->SetUndoProvider(this); | 1125 undo_delegate_->SetUndoProvider(this); |
1126 } | 1126 } |
1127 | 1127 |
1128 BookmarkUndoDelegate* BookmarkModel::undo_delegate() const { | 1128 BookmarkUndoDelegate* BookmarkModel::undo_delegate() const { |
1129 return undo_delegate_ ? undo_delegate_ : empty_undo_delegate_.get(); | 1129 return undo_delegate_ ? undo_delegate_ : empty_undo_delegate_.get(); |
1130 } | 1130 } |
1131 | 1131 |
1132 } // namespace bookmarks | 1132 } // namespace bookmarks |
OLD | NEW |