Chromium Code Reviews| 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 63be8ad9b54fc9af227915dc6566f586d30ddb79..4867bf1300fef7d6f795501188980cf7228b5c5c 100644 |
| --- a/components/ntp_snippets/bookmarks/bookmark_last_visit_utils.cc |
| +++ b/components/ntp_snippets/bookmarks/bookmark_last_visit_utils.cc |
| @@ -42,8 +42,8 @@ std::string FormatLastVisitDate(const base::Time& date) { |
| } |
| bool ExtractLastVisitDate(const BookmarkNode& node, |
| - const std::string& meta_info_key, |
| - base::Time* out) { |
| + const std::string& meta_info_key, |
| + base::Time* out) { |
| std::string last_visit_date_string; |
| if (!node.GetMetaInfo(meta_info_key, &last_visit_date_string)) { |
| return false; |
| @@ -269,21 +269,44 @@ std::vector<const BookmarkNode*> GetDismissedBookmarksForDebugging( |
| return result; |
| } |
| -void RemoveAllLastVisitDates(bookmarks::BookmarkModel* bookmark_model) { |
| +namespace { |
| + |
| +void ClearNTPMetadataIfBetween(bookmarks::BookmarkModel* model, |
| + const BookmarkNode& node, |
| + const base::Time& begin, |
| + const base::Time& end, |
| + const std::string& meta_key) { |
| + base::Time last_visit_time; |
| + if (ExtractLastVisitDate(node, meta_key, &last_visit_time) && |
| + begin <= last_visit_time && last_visit_time <= end) { |
| + model->DeleteNodeMetaInfo(&node, meta_key); |
| + model->DeleteNodeMetaInfo(&node, kBookmarkDismissedFromNTP); |
|
jkrcal
2017/01/05 13:28:55
Can you please remove the dismissed bit only if th
tschumann
2017/01/05 19:25:17
let's not remove this here at all -- the content s
jkrcal
2017/01/05 20:01:50
Acknowledged.
|
| + } |
| +} |
| + |
| +} // namespace |
| + |
| +void RemoveLastVisitedDatesBetween(const base::Time& begin, |
| + const base::Time& end, |
| + base::Callback<bool(const GURL& url)> filter, |
| + bookmarks::BookmarkModel* bookmark_model) { |
| // Get all the bookmark URLs. |
| std::vector<BookmarkModel::URLAndTitle> bookmark_urls; |
| bookmark_model->GetBookmarks(&bookmark_urls); |
| for (const BookmarkModel::URLAndTitle& url_and_title : bookmark_urls) { |
| + if (!filter.Run(url_and_title.url)) { |
| + continue; |
| + } |
| // Get all bookmarks for the given URL. |
| std::vector<const BookmarkNode*> bookmarks_for_url; |
| bookmark_model->GetNodesByURL(url_and_title.url, &bookmarks_for_url); |
| for (const BookmarkNode* bookmark : bookmarks_for_url) { |
| - bookmark_model->DeleteNodeMetaInfo(bookmark, |
| - kBookmarkLastVisitDateOnMobileKey); |
| - bookmark_model->DeleteNodeMetaInfo(bookmark, |
| - kBookmarkLastVisitDateOnDesktopKey); |
| + ClearNTPMetadataIfBetween(bookmark_model, *bookmark, begin, end, |
| + kBookmarkLastVisitDateOnMobileKey); |
| + ClearNTPMetadataIfBetween(bookmark_model, *bookmark, begin, end, |
| + kBookmarkLastVisitDateOnDesktopKey); |
| } |
| } |
| } |