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

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

Issue 2234393002: Marking last_visited date for bookmarks created from an open tab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/ntp_snippets/bookmark_last_visit_updater.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 for (const BookmarkNode* node : bookmarks_for_url) 54 for (const BookmarkNode* node : bookmarks_for_url)
55 bookmark_model->SetNodeMetaInfo(node, kBookmarkLastVisitDateKey, now); 55 bookmark_model->SetNodeMetaInfo(node, kBookmarkLastVisitDateKey, now);
56 } 56 }
57 57
58 base::Time GetLastVisitDateForBookmark(const BookmarkNode* node) { 58 base::Time GetLastVisitDateForBookmark(const BookmarkNode* node) {
59 if (!node) 59 if (!node)
60 return base::Time::UnixEpoch(); 60 return base::Time::UnixEpoch();
61 61
62 std::string last_visit_date_string; 62 std::string last_visit_date_string;
63 node->GetMetaInfo(kBookmarkLastVisitDateKey, &last_visit_date_string); 63 node->GetMetaInfo(kBookmarkLastVisitDateKey, &last_visit_date_string);
64
65 // Use creation date if no last visit info present.
Marc Treib 2016/08/11 13:03:43 I think the header has a comment that mentions the
jkrcal 2016/08/11 13:59:26 Done.
66 if (last_visit_date_string.empty())
67 return node->date_added();
68
69 return ParseLastVisitDate(last_visit_date_string); 64 return ParseLastVisitDate(last_visit_date_string);
70 } 65 }
71 66
72 void MarkBookmarksDismissed(BookmarkModel* bookmark_model, const GURL& url) { 67 void MarkBookmarksDismissed(BookmarkModel* bookmark_model, const GURL& url) {
73 std::vector<const BookmarkNode*> nodes; 68 std::vector<const BookmarkNode*> nodes;
74 bookmark_model->GetNodesByURL(url, &nodes); 69 bookmark_model->GetNodesByURL(url, &nodes);
75 for (const BookmarkNode* node : nodes) 70 for (const BookmarkNode* node : nodes)
76 bookmark_model->SetNodeMetaInfo(node, kBookmarkDismissedFromNTP, "1"); 71 bookmark_model->SetNodeMetaInfo(node, kBookmarkDismissedFromNTP, "1");
77 } 72 }
78 73
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 // Insert into |result|. 174 // Insert into |result|.
180 std::vector<const BookmarkNode*> result; 175 std::vector<const BookmarkNode*> result;
181 for (const BookmarkModel::URLAndTitle& bookmark : bookmarks) { 176 for (const BookmarkModel::URLAndTitle& bookmark : bookmarks) {
182 result.push_back( 177 result.push_back(
183 bookmark_model->GetMostRecentlyAddedUserNodeForURL(bookmark.url)); 178 bookmark_model->GetMostRecentlyAddedUserNodeForURL(bookmark.url));
184 } 179 }
185 return result; 180 return result;
186 } 181 }
187 182
188 } // namespace ntp_snippets 183 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « chrome/browser/ntp_snippets/bookmark_last_visit_updater.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698