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

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

Issue 2256643002: Add a fallback to creation date for Recent bookmarks on NTP (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Marc's comments Created 4 years, 4 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 #ifndef COMPONENTS_NTP_SNIPPETS_BOOKMARKS_BOOKMARK_LAST_VISIT_UTILS_H_ 5 #ifndef COMPONENTS_NTP_SNIPPETS_BOOKMARKS_BOOKMARK_LAST_VISIT_UTILS_H_
6 #define COMPONENTS_NTP_SNIPPETS_BOOKMARKS_BOOKMARK_LAST_VISIT_UTILS_H_ 6 #define COMPONENTS_NTP_SNIPPETS_BOOKMARKS_BOOKMARK_LAST_VISIT_UTILS_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 class GURL; 10 class GURL;
(...skipping 10 matching lines...) Expand all
21 namespace ntp_snippets { 21 namespace ntp_snippets {
22 22
23 // If there is a bookmark for |url|, this function updates its last visit date 23 // If there is a bookmark for |url|, this function updates its last visit date
24 // to now. If there are multiple bookmarks for a given URL, it updates all of 24 // to now. If there are multiple bookmarks for a given URL, it updates all of
25 // them. 25 // them.
26 void UpdateBookmarkOnURLVisitedInMainFrame( 26 void UpdateBookmarkOnURLVisitedInMainFrame(
27 bookmarks::BookmarkModel* bookmark_model, 27 bookmarks::BookmarkModel* bookmark_model,
28 const GURL& url); 28 const GURL& url);
29 29
30 // Gets the last visit date for a given bookmark |node|. The visit when the 30 // Gets the last visit date for a given bookmark |node|. The visit when the
31 // bookmark is created also counts. 31 // bookmark is created also counts. If no info about last visit date is present
32 base::Time GetLastVisitDateForBookmark(const bookmarks::BookmarkNode* node); 32 // and |creation_date_fallback| is true, creation date is used.
33 base::Time GetLastVisitDateForBookmark(const bookmarks::BookmarkNode* node,
34 bool creation_date_fallback = true);
Marc Treib 2016/08/18 09:31:44 nit: Default parameters are kinda discouraged, I'd
Philipp Keck 2016/08/19 11:20:54 Done.
33 35
34 // Like GetLastVisitDateForBookmark, but it returns the unix epoch if the 36 // Like GetLastVisitDateForBookmark, but it returns the unix epoch if the
35 // bookmark is dismissed from NTP. 37 // bookmark is dismissed from NTP.
36 base::Time GetLastVisitDateForBookmarkIfNotDismissed( 38 base::Time GetLastVisitDateForBookmarkIfNotDismissed(
37 const bookmarks::BookmarkNode* node); 39 const bookmarks::BookmarkNode* node,
40 bool creation_date_fallback = true);
38 41
39 // Marks all bookmarks with the given URL as dismissed. 42 // Marks all bookmarks with the given URL as dismissed.
40 void MarkBookmarksDismissed(bookmarks::BookmarkModel* bookmark_model, 43 void MarkBookmarksDismissed(bookmarks::BookmarkModel* bookmark_model,
41 const GURL& url); 44 const GURL& url);
42 45
43 // Gets the dismissed flag for a given bookmark |node|. Defaults to false. 46 // Gets the dismissed flag for a given bookmark |node|. Defaults to false.
44 bool IsDismissedFromNTPForBookmark(const bookmarks::BookmarkNode* node); 47 bool IsDismissedFromNTPForBookmark(const bookmarks::BookmarkNode* node);
45 48
46 // Removes the dismissed flag from all bookmarks (only for debugging). 49 // Removes the dismissed flag from all bookmarks (only for debugging).
47 void MarkAllBookmarksUndismissed(bookmarks::BookmarkModel* bookmark_model); 50 void MarkAllBookmarksUndismissed(bookmarks::BookmarkModel* bookmark_model);
48 51
49 // Returns the list of most recently visited, non-dismissed bookmarks. 52 // Returns the list of most recently visited, non-dismissed bookmarks.
50 // For each bookmarked URL, it returns the most recently created bookmark. 53 // For each bookmarked URL, it returns the most recently created bookmark.
51 // The result is ordered by visit time (the most recent first). Only bookmarks 54 // The result is ordered by visit time (the most recent first). Only bookmarks
52 // visited after |min_visit_time| are considered, at most |max_count| bookmarks 55 // visited after |min_visit_time| are considered, at most |max_count| bookmarks
53 // are returned. 56 // are returned. If this results into less than |min_count| bookmarks, the list
57 // is filled up with older bookmarks sorted by their last visit / creation date.
54 std::vector<const bookmarks::BookmarkNode*> GetRecentlyVisitedBookmarks( 58 std::vector<const bookmarks::BookmarkNode*> GetRecentlyVisitedBookmarks(
55 bookmarks::BookmarkModel* bookmark_model, 59 bookmarks::BookmarkModel* bookmark_model,
60 int min_count,
56 int max_count, 61 int max_count,
57 const base::Time& min_visit_time); 62 const base::Time& min_visit_time);
58 63
59 // Returns the list of all dismissed bookmarks. Only used for debugging. 64 // Returns the list of all dismissed bookmarks. Only used for debugging.
60 std::vector<const bookmarks::BookmarkNode*> GetDismissedBookmarksForDebugging( 65 std::vector<const bookmarks::BookmarkNode*> GetDismissedBookmarksForDebugging(
61 bookmarks::BookmarkModel* bookmark_model); 66 bookmarks::BookmarkModel* bookmark_model);
62 67
63 } // namespace ntp_snippets 68 } // namespace ntp_snippets
64 69
65 #endif // COMPONENTS_NTP_SNIPPETS_BOOKMARKS_BOOKMARK_LAST_VISIT_UTILS_H_ 70 #endif // COMPONENTS_NTP_SNIPPETS_BOOKMARKS_BOOKMARK_LAST_VISIT_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698