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

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

Issue 2303713002: Implement ClearHistory for all ntp_snippets providers (Closed)
Patch Set: Marc's nits. Created 4 years, 3 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 #include "components/ntp_snippets/bookmarks/bookmark_last_visit_utils.h" 5 #include "components/ntp_snippets/bookmarks/bookmark_last_visit_utils.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 225
226 // Insert into |result|. 226 // Insert into |result|.
227 std::vector<const BookmarkNode*> result; 227 std::vector<const BookmarkNode*> result;
228 for (const BookmarkModel::URLAndTitle& bookmark : bookmarks) { 228 for (const BookmarkModel::URLAndTitle& bookmark : bookmarks) {
229 result.push_back( 229 result.push_back(
230 bookmark_model->GetMostRecentlyAddedUserNodeForURL(bookmark.url)); 230 bookmark_model->GetMostRecentlyAddedUserNodeForURL(bookmark.url));
231 } 231 }
232 return result; 232 return result;
233 } 233 }
234 234
235 void RemoveAllLastVisitDates(bookmarks::BookmarkModel* bookmark_model) {
236 // Get all the bookmark URLs.
237 std::vector<BookmarkModel::URLAndTitle> bookmark_urls;
238 bookmark_model->GetBookmarks(&bookmark_urls);
239
240 for (const BookmarkModel::URLAndTitle& url_and_title : bookmark_urls) {
241 // Get all bookmarks for the given URL.
242 std::vector<const BookmarkNode*> bookmarks_for_url;
243 bookmark_model->GetNodesByURL(url_and_title.url, &bookmarks_for_url);
244
245 for (const BookmarkNode* bookmark : bookmarks_for_url) {
246 bookmark_model->DeleteNodeMetaInfo(bookmark, kBookmarkLastVisitDateKey);
247 }
248 }
249 }
250
235 } // namespace ntp_snippets 251 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698