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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 std::vector<ContentSuggestion> suggestions; | 210 std::vector<ContentSuggestion> suggestions; |
211 for (const BookmarkNode* bookmark : bookmarks) { | 211 for (const BookmarkNode* bookmark : bookmarks) { |
212 ConvertBookmark(bookmark, &suggestions); | 212 ConvertBookmark(bookmark, &suggestions); |
213 } | 213 } |
214 callback.Run(std::move(suggestions)); | 214 callback.Run(std::move(suggestions)); |
215 } | 215 } |
216 | 216 |
217 void BookmarkSuggestionsProvider::ClearDismissedSuggestionsForDebugging( | 217 void BookmarkSuggestionsProvider::ClearDismissedSuggestionsForDebugging( |
218 Category category) { | 218 Category category) { |
219 DCHECK_EQ(category, provided_category_); | 219 DCHECK_EQ(category, provided_category_); |
220 if (!bookmark_model_->loaded()) | 220 if (!bookmark_model_->loaded()) { |
221 return; | 221 return; |
| 222 } |
222 MarkAllBookmarksUndismissed(bookmark_model_); | 223 MarkAllBookmarksUndismissed(bookmark_model_); |
223 } | 224 } |
224 | 225 |
225 void BookmarkSuggestionsProvider::BookmarkModelLoaded( | 226 void BookmarkSuggestionsProvider::BookmarkModelLoaded( |
226 bookmarks::BookmarkModel* model, | 227 bookmarks::BookmarkModel* model, |
227 bool ids_reassigned) { | 228 bool ids_reassigned) { |
228 DCHECK_EQ(bookmark_model_, model); | 229 DCHECK_EQ(bookmark_model_, model); |
229 if (fetch_requested_) { | 230 if (fetch_requested_) { |
230 fetch_requested_ = false; | 231 fetch_requested_ = false; |
231 FetchBookmarksInternal(); | 232 FetchBookmarksInternal(); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 end_of_list_last_visit_date_ = threshold_time; | 342 end_of_list_last_visit_date_ = threshold_time; |
342 } else { | 343 } else { |
343 end_of_list_last_visit_date_ = suggestions.back().publish_date(); | 344 end_of_list_last_visit_date_ = suggestions.back().publish_date(); |
344 } | 345 } |
345 | 346 |
346 observer()->OnNewSuggestions(this, provided_category_, | 347 observer()->OnNewSuggestions(this, provided_category_, |
347 std::move(suggestions)); | 348 std::move(suggestions)); |
348 } | 349 } |
349 | 350 |
350 void BookmarkSuggestionsProvider::FetchBookmarks() { | 351 void BookmarkSuggestionsProvider::FetchBookmarks() { |
351 if (bookmark_model_->loaded()) | 352 if (bookmark_model_->loaded()) { |
352 FetchBookmarksInternal(); | 353 FetchBookmarksInternal(); |
353 else | 354 } else { |
354 fetch_requested_ = true; | 355 fetch_requested_ = true; |
| 356 } |
355 } | 357 } |
356 | 358 |
357 void BookmarkSuggestionsProvider::NotifyStatusChanged( | 359 void BookmarkSuggestionsProvider::NotifyStatusChanged( |
358 CategoryStatus new_status) { | 360 CategoryStatus new_status) { |
359 if (category_status_ == new_status) | 361 if (category_status_ == new_status) { |
360 return; | 362 return; |
| 363 } |
361 category_status_ = new_status; | 364 category_status_ = new_status; |
362 observer()->OnCategoryStatusChanged(this, provided_category_, new_status); | 365 observer()->OnCategoryStatusChanged(this, provided_category_, new_status); |
363 } | 366 } |
364 | 367 |
365 } // namespace ntp_snippets | 368 } // namespace ntp_snippets |
OLD | NEW |