Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 |
| OLD | NEW |