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" | 21 #include "components/bookmarks/browser/bookmark_index.h" |
22 #include "components/bookmarks/browser/bookmark_match.h" | 22 #include "components/bookmarks/browser/bookmark_match.h" |
23 #include "components/bookmarks/browser/bookmark_model_observer.h" | 23 #include "components/bookmarks/browser/bookmark_model_observer.h" |
24 #include "components/bookmarks/browser/bookmark_node_data.h" | 24 #include "components/bookmarks/browser/bookmark_node_data.h" |
25 #include "components/bookmarks/browser/bookmark_storage.h" | 25 #include "components/bookmarks/browser/bookmark_storage.h" |
26 #include "components/bookmarks/browser/bookmark_undo_delegate.h" | 26 #include "components/bookmarks/browser/bookmark_undo_delegate.h" |
27 #include "components/bookmarks/browser/bookmark_utils.h" | 27 #include "components/bookmarks/browser/bookmark_utils.h" |
| 28 #include "components/bookmarks/browser/typed_count_sorter.h" |
28 #include "components/favicon_base/favicon_types.h" | 29 #include "components/favicon_base/favicon_types.h" |
29 #include "grit/components_strings.h" | 30 #include "grit/components_strings.h" |
30 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
31 #include "ui/gfx/favicon_size.h" | 32 #include "ui/gfx/favicon_size.h" |
32 | 33 |
33 using base::Time; | 34 using base::Time; |
34 | 35 |
35 namespace bookmarks { | 36 namespace bookmarks { |
36 | 37 |
37 namespace { | 38 namespace { |
(...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1104 return next_node_id_++; | 1105 return next_node_id_++; |
1105 } | 1106 } |
1106 | 1107 |
1107 std::unique_ptr<BookmarkLoadDetails> BookmarkModel::CreateLoadDetails() { | 1108 std::unique_ptr<BookmarkLoadDetails> BookmarkModel::CreateLoadDetails() { |
1108 BookmarkPermanentNode* bb_node = | 1109 BookmarkPermanentNode* bb_node = |
1109 CreatePermanentNode(BookmarkNode::BOOKMARK_BAR); | 1110 CreatePermanentNode(BookmarkNode::BOOKMARK_BAR); |
1110 BookmarkPermanentNode* other_node = | 1111 BookmarkPermanentNode* other_node = |
1111 CreatePermanentNode(BookmarkNode::OTHER_NODE); | 1112 CreatePermanentNode(BookmarkNode::OTHER_NODE); |
1112 BookmarkPermanentNode* mobile_node = | 1113 BookmarkPermanentNode* mobile_node = |
1113 CreatePermanentNode(BookmarkNode::MOBILE); | 1114 CreatePermanentNode(BookmarkNode::MOBILE); |
| 1115 std::unique_ptr<TitledUrlNodeSorter> node_sorter = |
| 1116 base::MakeUnique<TypedCountSorter>(client_.get()); |
1114 return std::unique_ptr<BookmarkLoadDetails>(new BookmarkLoadDetails( | 1117 return std::unique_ptr<BookmarkLoadDetails>(new BookmarkLoadDetails( |
1115 bb_node, other_node, mobile_node, client_->GetLoadExtraNodesCallback(), | 1118 bb_node, other_node, mobile_node, client_->GetLoadExtraNodesCallback(), |
1116 new BookmarkIndex(client_.get()), next_node_id_)); | 1119 new BookmarkIndex(std::move(node_sorter)), next_node_id_)); |
1117 } | 1120 } |
1118 | 1121 |
1119 void BookmarkModel::SetUndoDelegate(BookmarkUndoDelegate* undo_delegate) { | 1122 void BookmarkModel::SetUndoDelegate(BookmarkUndoDelegate* undo_delegate) { |
1120 undo_delegate_ = undo_delegate; | 1123 undo_delegate_ = undo_delegate; |
1121 if (undo_delegate_) | 1124 if (undo_delegate_) |
1122 undo_delegate_->SetUndoProvider(this); | 1125 undo_delegate_->SetUndoProvider(this); |
1123 } | 1126 } |
1124 | 1127 |
1125 BookmarkUndoDelegate* BookmarkModel::undo_delegate() const { | 1128 BookmarkUndoDelegate* BookmarkModel::undo_delegate() const { |
1126 return undo_delegate_ ? undo_delegate_ : empty_undo_delegate_.get(); | 1129 return undo_delegate_ ? undo_delegate_ : empty_undo_delegate_.get(); |
1127 } | 1130 } |
1128 | 1131 |
1129 } // namespace bookmarks | 1132 } // namespace bookmarks |
OLD | NEW |