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_suggestions_provider.h" | 5 #include "components/ntp_snippets/bookmarks/bookmark_suggestions_provider.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 callback, | 142 callback, |
143 Status(StatusCode::PERMANENT_ERROR, | 143 Status(StatusCode::PERMANENT_ERROR, |
144 "BookmarkSuggestionsProvider has no |Fetch| functionality!"), | 144 "BookmarkSuggestionsProvider has no |Fetch| functionality!"), |
145 base::Passed(std::vector<ContentSuggestion>()))); | 145 base::Passed(std::vector<ContentSuggestion>()))); |
146 } | 146 } |
147 | 147 |
148 void BookmarkSuggestionsProvider::ClearHistory( | 148 void BookmarkSuggestionsProvider::ClearHistory( |
149 base::Time begin, | 149 base::Time begin, |
150 base::Time end, | 150 base::Time end, |
151 const base::Callback<bool(const GURL& url)>& filter) { | 151 const base::Callback<bool(const GURL& url)>& filter) { |
152 // The last visit dates are not "owned" by the bookmark suggestion provider so | 152 // To avoid race conditions with the history-removal of the last-visited |
153 // it is cleared directly from browsing_data_remover.cc. | 153 // timestamps we also trigger a deletion here. The problem is that we need to |
| 154 // update the bookmarks data here and otherwise (depending on the order in |
| 155 // which the code runs) could pick up to-be-deleted data again. |
| 156 if (bookmark_model_->loaded()) { |
| 157 RemoveLastVisitedDatesBetween(begin, end, filter, bookmark_model_); |
| 158 } |
154 ClearDismissedSuggestionsForDebugging(provided_category_); | 159 ClearDismissedSuggestionsForDebugging(provided_category_); |
155 // TODO(tschumann): Before re-fetching bookmarks we need to trigger a clean-up | |
156 // of the last-visit dates -- otherwise we depend on the order in which the | |
157 // ClearHistory events are done and might just pick-up to-be-deleted data | |
158 // again. | |
159 FetchBookmarks(); | 160 FetchBookmarks(); |
160 } | 161 } |
161 | 162 |
162 void BookmarkSuggestionsProvider::ClearCachedSuggestions(Category category) { | 163 void BookmarkSuggestionsProvider::ClearCachedSuggestions(Category category) { |
163 DCHECK_EQ(category, provided_category_); | 164 DCHECK_EQ(category, provided_category_); |
164 // Ignored. | 165 // Ignored. |
165 } | 166 } |
166 | 167 |
167 void BookmarkSuggestionsProvider::GetDismissedSuggestionsForDebugging( | 168 void BookmarkSuggestionsProvider::GetDismissedSuggestionsForDebugging( |
168 Category category, | 169 Category category, |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 void BookmarkSuggestionsProvider::NotifyStatusChanged( | 321 void BookmarkSuggestionsProvider::NotifyStatusChanged( |
321 CategoryStatus new_status) { | 322 CategoryStatus new_status) { |
322 if (category_status_ == new_status) { | 323 if (category_status_ == new_status) { |
323 return; | 324 return; |
324 } | 325 } |
325 category_status_ = new_status; | 326 category_status_ = new_status; |
326 observer()->OnCategoryStatusChanged(this, provided_category_, new_status); | 327 observer()->OnCategoryStatusChanged(this, provided_category_, new_status); |
327 } | 328 } |
328 | 329 |
329 } // namespace ntp_snippets | 330 } // namespace ntp_snippets |
OLD | NEW |