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

Unified Diff: components/ntp_snippets/bookmarks/bookmark_last_visit_utils.cc

Issue 2241463002: Update bookmark suggestions also after undismiss/delete. (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 side-by-side diff with in-line comments
Download patch
Index: components/ntp_snippets/bookmarks/bookmark_last_visit_utils.cc
diff --git a/components/ntp_snippets/bookmarks/bookmark_last_visit_utils.cc b/components/ntp_snippets/bookmarks/bookmark_last_visit_utils.cc
index 77f659d17d4ca7628d42ed3eb3d931dbd504dc1a..bf6bbd8c97348c68d59906e9796e7ce09a71f922 100644
--- a/components/ntp_snippets/bookmarks/bookmark_last_visit_utils.cc
+++ b/components/ntp_snippets/bookmarks/bookmark_last_visit_utils.cc
@@ -69,6 +69,13 @@ base::Time GetLastVisitDateForBookmark(const BookmarkNode* node) {
return ParseLastVisitDate(last_visit_date_string);
}
+base::Time GetLastVisitDateForBookmarkIfNotDismissed(const BookmarkNode* node) {
+ if (IsDismissedFromNTPForBookmark(node))
+ return base::Time::UnixEpoch();
+
+ return GetLastVisitDateForBookmark(node);
+}
+
void MarkBookmarksDismissed(BookmarkModel* bookmark_model, const GURL& url) {
std::vector<const BookmarkNode*> nodes;
bookmark_model->GetNodesByURL(url, &nodes);
@@ -109,8 +116,8 @@ std::vector<const BookmarkNode*> GetRecentlyVisitedBookmarks(
std::vector<BookmarkModel::URLAndTitle> bookmarks;
bookmark_model->GetBookmarks(&bookmarks);
- // Remove the bookmark URLs whose bookmarks are all dismissed or whose most
- // recent visit is older than |min_visit_time|.
+ // Remove the URLs for that no bookmark has a recent visit (more recent than
+ // |min_visit_time|). Recent visits to dismissed bookmarks are not considered.
bookmarks.erase(
std::remove_if(bookmarks.begin(), bookmarks.end(),
[&bookmark_model, &min_visit_time](
@@ -120,17 +127,15 @@ std::vector<const BookmarkNode*> GetRecentlyVisitedBookmarks(
bookmark_model->GetNodesByURL(bookmark.url,
&bookmarks_for_url);
- // Check if there is a recently visited bookmark and not
- // all bookmarks are dismissed.
- bool has_recent_visit = false;
- bool all_dismissed = true;
+ // Keep if at least one (non-dismissed) bookmark has been
+ // recently visited.
for (const BookmarkNode* node : bookmarks_for_url) {
- if (GetLastVisitDateForBookmark(node) > min_visit_time)
- has_recent_visit = true;
- if (!IsDismissedFromNTPForBookmark(node))
- all_dismissed = false;
+ if (GetLastVisitDateForBookmarkIfNotDismissed(node) >
+ min_visit_time)
+ return false;
}
- return all_dismissed || !has_recent_visit;
+ // Otherwise erase this URL.
+ return true;
}),
bookmarks.end());

Powered by Google App Engine
This is Rietveld 408576698