Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 |use_creation_date| is true, creation |
| 32 base::Time GetLastVisitDateForBookmark(const bookmarks::BookmarkNode* node); | 32 // date of the bookmark is considered instead of its last visit date (useful for |
| 33 // the transition phase M53 -> M54 when no last visit data is available). | |
|
Marc Treib
2016/08/17 11:29:05
Hm, so even in the "fallback mode", wouldn't we st
| |
| 34 base::Time GetLastVisitDateForBookmark(const bookmarks::BookmarkNode* node, | |
| 35 bool use_creation_date); | |
| 33 | 36 |
| 34 // Like GetLastVisitDateForBookmark, but it returns the unix epoch if the | 37 // Like GetLastVisitDateForBookmark, but it returns the unix epoch if the |
| 35 // bookmark is dismissed from NTP. | 38 // bookmark is dismissed from NTP. If |use_creation_date| is true, creation |
| 39 // date of the bookmark is considered instead of its last visit date (useful for | |
| 40 // the transition phase M53 -> M54 when no last visit data is available). | |
| 36 base::Time GetLastVisitDateForBookmarkIfNotDismissed( | 41 base::Time GetLastVisitDateForBookmarkIfNotDismissed( |
| 37 const bookmarks::BookmarkNode* node); | 42 const bookmarks::BookmarkNode* node, bool use_creation_date); |
| 38 | 43 |
| 39 // Marks all bookmarks with the given URL as dismissed. | 44 // Marks all bookmarks with the given URL as dismissed. |
| 40 void MarkBookmarksDismissed(bookmarks::BookmarkModel* bookmark_model, | 45 void MarkBookmarksDismissed(bookmarks::BookmarkModel* bookmark_model, |
| 41 const GURL& url); | 46 const GURL& url); |
| 42 | 47 |
| 43 // Gets the dismissed flag for a given bookmark |node|. Defaults to false. | 48 // Gets the dismissed flag for a given bookmark |node|. Defaults to false. |
| 44 bool IsDismissedFromNTPForBookmark(const bookmarks::BookmarkNode* node); | 49 bool IsDismissedFromNTPForBookmark(const bookmarks::BookmarkNode* node); |
| 45 | 50 |
| 46 // Removes the dismissed flag from all bookmarks (only for debugging). | 51 // Removes the dismissed flag from all bookmarks (only for debugging). |
| 47 void MarkAllBookmarksUndismissed(bookmarks::BookmarkModel* bookmark_model); | 52 void MarkAllBookmarksUndismissed(bookmarks::BookmarkModel* bookmark_model); |
| 48 | 53 |
| 54 // Returns true if and only if there is at least one bookmark in | |
| 55 // |bookmark_model| that has information about its last visit associated. | |
| 56 bool IsLastVisitDataAvailable(bookmarks::BookmarkModel* bookmark_model); | |
| 57 | |
| 49 // Returns the list of most recently visited, non-dismissed bookmarks. | 58 // Returns the list of most recently visited, non-dismissed bookmarks. |
| 50 // For each bookmarked URL, it returns the most recently created bookmark. | 59 // 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 | 60 // 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 | 61 // visited after |min_visit_time| are considered, at most |max_count| bookmarks |
| 53 // are returned. | 62 // are returned. If |use_creation_date| is true, the creation date of a bookmark |
| 63 // is used instead of the last visit date. | |
| 54 std::vector<const bookmarks::BookmarkNode*> GetRecentlyVisitedBookmarks( | 64 std::vector<const bookmarks::BookmarkNode*> GetRecentlyVisitedBookmarks( |
| 55 bookmarks::BookmarkModel* bookmark_model, | 65 bookmarks::BookmarkModel* bookmark_model, |
| 66 bool use_creation_date, | |
| 56 int max_count, | 67 int max_count, |
| 57 const base::Time& min_visit_time); | 68 const base::Time& min_visit_time); |
| 58 | 69 |
| 59 // Returns the list of all dismissed bookmarks. Only used for debugging. | 70 // Returns the list of all dismissed bookmarks. Only used for debugging. |
| 60 std::vector<const bookmarks::BookmarkNode*> GetDismissedBookmarksForDebugging( | 71 std::vector<const bookmarks::BookmarkNode*> GetDismissedBookmarksForDebugging( |
| 61 bookmarks::BookmarkModel* bookmark_model); | 72 bookmarks::BookmarkModel* bookmark_model); |
| 62 | 73 |
| 63 } // namespace ntp_snippets | 74 } // namespace ntp_snippets |
| 64 | 75 |
| 65 #endif // COMPONENTS_NTP_SNIPPETS_BOOKMARKS_BOOKMARK_LAST_VISIT_UTILS_H_ | 76 #endif // COMPONENTS_NTP_SNIPPETS_BOOKMARKS_BOOKMARK_LAST_VISIT_UTILS_H_ |
| OLD | NEW |