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

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

Issue 2741133003: ntp_snippets: Use base::EraseIf() (Closed)
Patch Set: Add #include Created 3 years, 9 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
« no previous file with comments | « no previous file | components/ntp_snippets/remote/remote_suggestions_provider_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 21ecd8112fc6740a18f7c7aedaeb17cb46f68efe..c26887102cb55bbad40a4d15f2864d0a776e57cc 100644
--- a/components/ntp_snippets/bookmarks/bookmark_last_visit_utils.cc
+++ b/components/ntp_snippets/bookmarks/bookmark_last_visit_utils.cc
@@ -11,6 +11,7 @@
#include <utility>
#include "base/bind.h"
+#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/time/time.h"
#include "components/bookmarks/browser/bookmark_model.h"
@@ -29,9 +30,8 @@ struct RecentBookmark {
base::Time last_visited;
};
-const char* kBookmarksURLBlacklist[] = {"chrome://newtab/",
- "chrome-native://newtab/",
- "chrome://bookmarks/"};
+const char* kBookmarksURLBlacklist[] = {
+ "chrome://newtab/", "chrome-native://newtab/", "chrome://bookmarks/"};
const char kBookmarkLastVisitDateOnMobileKey[] = "last_visited";
const char kBookmarkLastVisitDateOnDesktopKey[] = "last_visited_desktop";
@@ -106,10 +106,11 @@ void UpdateBookmarkOnURLVisitedInMainFrame(BookmarkModel* bookmark_model,
// If there are bookmarks for |url|, set their last visit date to now.
std::string now = FormatLastVisitDate(base::Time::Now());
for (const BookmarkNode* node : bookmarks_for_url) {
- bookmark_model->SetNodeMetaInfo(
- node, is_mobile_platform ? kBookmarkLastVisitDateOnMobileKey
- : kBookmarkLastVisitDateOnDesktopKey,
- now);
+ bookmark_model->SetNodeMetaInfo(node,
+ is_mobile_platform
+ ? kBookmarkLastVisitDateOnMobileKey
+ : kBookmarkLastVisitDateOnDesktopKey,
+ now);
// If the bookmark has been dismissed from NTP before, a new visit overrides
// such a dismissal.
bookmark_model->DeleteNodeMetaInfo(node, kBookmarkDismissedFromNTP);
@@ -243,22 +244,19 @@ std::vector<const BookmarkNode*> GetDismissedBookmarksForDebugging(
bookmark_model->GetBookmarks(&bookmarks);
// Remove the bookmark URLs which have at least one non-dismissed bookmark.
- bookmarks.erase(
- std::remove_if(
- bookmarks.begin(), bookmarks.end(),
- [&bookmark_model](const BookmarkModel::URLAndTitle& bookmark) {
- std::vector<const BookmarkNode*> bookmarks_for_url;
- bookmark_model->GetNodesByURL(bookmark.url, &bookmarks_for_url);
- DCHECK(!bookmarks_for_url.empty());
+ base::EraseIf(
+ bookmarks, [&bookmark_model](const BookmarkModel::URLAndTitle& bookmark) {
+ std::vector<const BookmarkNode*> bookmarks_for_url;
+ bookmark_model->GetNodesByURL(bookmark.url, &bookmarks_for_url);
+ DCHECK(!bookmarks_for_url.empty());
- for (const BookmarkNode* node : bookmarks_for_url) {
- if (!IsDismissedFromNTPForBookmark(*node)) {
- return true;
- }
- }
- return false;
- }),
- bookmarks.end());
+ for (const BookmarkNode* node : bookmarks_for_url) {
+ if (!IsDismissedFromNTPForBookmark(*node)) {
+ return true;
+ }
+ }
+ return false;
+ });
// Insert into |result|.
std::vector<const BookmarkNode*> result;
@@ -306,7 +304,7 @@ void RemoveLastVisitedDatesBetween(const base::Time& begin,
ClearLastVisitedMetadataIfBetween(bookmark_model, *bookmark, begin, end,
kBookmarkLastVisitDateOnMobileKey);
ClearLastVisitedMetadataIfBetween(bookmark_model, *bookmark, begin, end,
- kBookmarkLastVisitDateOnDesktopKey);
+ kBookmarkLastVisitDateOnDesktopKey);
}
}
}
« no previous file with comments | « no previous file | components/ntp_snippets/remote/remote_suggestions_provider_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698