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

Side by Side Diff: components/ntp_snippets/bookmarks/bookmark_last_visit_utils.cc

Issue 2305583002: Do not select old bookmarks in ntp_snippets::BookmarkSuggestionsProvider (Closed)
Patch Set: Marc's comments. Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/ntp_snippets/bookmarks/bookmark_last_visit_utils.h" 5 #include "components/ntp_snippets/bookmarks/bookmark_last_visit_utils.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 std::sort(bookmarks.begin(), bookmarks.end(), 180 std::sort(bookmarks.begin(), bookmarks.end(),
181 [creation_date_fallback](const RecentBookmark& a, 181 [creation_date_fallback](const RecentBookmark& a,
182 const RecentBookmark& b) { 182 const RecentBookmark& b) {
183 return CompareBookmarksByLastVisitDate(a.node, b.node, 183 return CompareBookmarksByLastVisitDate(a.node, b.node,
184 creation_date_fallback); 184 creation_date_fallback);
185 }); 185 });
186 186
187 // Insert the first |max_count| items from |bookmarks| into |result|. 187 // Insert the first |max_count| items from |bookmarks| into |result|.
188 std::vector<const BookmarkNode*> result; 188 std::vector<const BookmarkNode*> result;
189 for (const RecentBookmark& bookmark : bookmarks) { 189 for (const RecentBookmark& bookmark : bookmarks) {
190 if (!creation_date_fallback &&
191 GetLastVisitDateForBookmark(bookmark.node, creation_date_fallback) <
192 min_visit_time) {
193 break;
194 }
195
190 result.push_back(bookmark.node); 196 result.push_back(bookmark.node);
191 if (result.size() >= static_cast<size_t>(max_count)) 197 if (result.size() >= static_cast<size_t>(max_count))
192 break; 198 break;
193 } 199 }
194 return result; 200 return result;
195 } 201 }
196 202
197 std::vector<const BookmarkNode*> GetDismissedBookmarksForDebugging( 203 std::vector<const BookmarkNode*> GetDismissedBookmarksForDebugging(
198 BookmarkModel* bookmark_model) { 204 BookmarkModel* bookmark_model) {
199 // Get all the bookmark URLs. 205 // Get all the bookmark URLs.
(...skipping 20 matching lines...) Expand all
220 // Insert into |result|. 226 // Insert into |result|.
221 std::vector<const BookmarkNode*> result; 227 std::vector<const BookmarkNode*> result;
222 for (const BookmarkModel::URLAndTitle& bookmark : bookmarks) { 228 for (const BookmarkModel::URLAndTitle& bookmark : bookmarks) {
223 result.push_back( 229 result.push_back(
224 bookmark_model->GetMostRecentlyAddedUserNodeForURL(bookmark.url)); 230 bookmark_model->GetMostRecentlyAddedUserNodeForURL(bookmark.url));
225 } 231 }
226 return result; 232 return result;
227 } 233 }
228 234
229 } // namespace ntp_snippets 235 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « components/ntp_snippets/bookmarks/DEPS ('k') | components/ntp_snippets/bookmarks/bookmark_last_visit_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698