Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/reading_list/reading_list_suggestions_provider .h" | 5 #include "components/ntp_snippets/reading_list/reading_list_suggestions_provider .h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 const DismissedSuggestionsCallback& callback) { | 109 const DismissedSuggestionsCallback& callback) { |
| 110 // TODO(crbug.com/702241): Implement this method. | 110 // TODO(crbug.com/702241): Implement this method. |
| 111 } | 111 } |
| 112 void ReadingListSuggestionsProvider::ClearDismissedSuggestionsForDebugging( | 112 void ReadingListSuggestionsProvider::ClearDismissedSuggestionsForDebugging( |
| 113 Category category) { | 113 Category category) { |
| 114 // TODO(crbug.com/702241): Implement this method. | 114 // TODO(crbug.com/702241): Implement this method. |
| 115 } | 115 } |
| 116 | 116 |
| 117 void ReadingListSuggestionsProvider::ReadingListModelLoaded( | 117 void ReadingListSuggestionsProvider::ReadingListModelLoaded( |
| 118 const ReadingListModel* model) { | 118 const ReadingListModel* model) { |
| 119 DCHECK(model == reading_list_model_); | 119 DCHECK(model == reading_list_model_); |
|
Olivier
2017/04/03 11:18:07
if (model->IsPerformingBatchUpdates())
return
gambard
2017/04/03 11:25:07
Done.
| |
| 120 FetchReadingListInternal(); | 120 FetchReadingListInternal(); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void ReadingListSuggestionsProvider::ReadingListModelBeingDeleted( | 123 void ReadingListSuggestionsProvider::ReadingListModelBeingDeleted( |
| 124 const ReadingListModel* model) { | 124 const ReadingListModel* model) { |
| 125 DCHECK(model == reading_list_model_); | 125 DCHECK(model == reading_list_model_); |
| 126 scoped_observer_.Remove(reading_list_model_); | 126 scoped_observer_.Remove(reading_list_model_); |
| 127 reading_list_model_ = nullptr; | 127 reading_list_model_ = nullptr; |
| 128 } | 128 } |
| 129 | 129 |
| 130 void ReadingListSuggestionsProvider::ReadingListDidApplyChanges( | |
| 131 ReadingListModel* model) { | |
| 132 DCHECK(model == reading_list_model_); | |
| 133 | |
| 134 if (model->IsPerformingBatchUpdates()) | |
| 135 return; | |
| 136 | |
| 137 FetchReadingListInternal(); | |
| 138 } | |
| 139 | |
| 140 void ReadingListSuggestionsProvider::ReadingListModelCompletedBatchUpdates( | |
| 141 const ReadingListModel* model) { | |
| 142 DCHECK(model == reading_list_model_); | |
| 143 | |
| 144 FetchReadingListInternal(); | |
| 145 } | |
| 146 | |
| 130 void ReadingListSuggestionsProvider::FetchReadingListInternal() { | 147 void ReadingListSuggestionsProvider::FetchReadingListInternal() { |
| 131 if (!reading_list_model_) | 148 if (!reading_list_model_) |
| 132 return; | 149 return; |
| 133 | 150 |
| 134 DCHECK(reading_list_model_->loaded()); | 151 DCHECK(reading_list_model_->loaded()); |
| 135 std::vector<const ReadingListEntry*> entries; | 152 std::vector<const ReadingListEntry*> entries; |
| 136 for (const GURL& url : reading_list_model_->Keys()) { | 153 for (const GURL& url : reading_list_model_->Keys()) { |
| 137 const ReadingListEntry* entry = reading_list_model_->GetEntryByURL(url); | 154 const ReadingListEntry* entry = reading_list_model_->GetEntryByURL(url); |
| 138 if (!entry->IsRead()) { | 155 if (!entry->IsRead()) { |
| 139 entries.emplace_back(entry); | 156 entries.emplace_back(entry); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 void ReadingListSuggestionsProvider::NotifyStatusChanged( | 202 void ReadingListSuggestionsProvider::NotifyStatusChanged( |
| 186 CategoryStatus new_status) { | 203 CategoryStatus new_status) { |
| 187 if (category_status_ == new_status) { | 204 if (category_status_ == new_status) { |
| 188 return; | 205 return; |
| 189 } | 206 } |
| 190 category_status_ = new_status; | 207 category_status_ = new_status; |
| 191 observer()->OnCategoryStatusChanged(this, provided_category_, new_status); | 208 observer()->OnCategoryStatusChanged(this, provided_category_, new_status); |
| 192 } | 209 } |
| 193 | 210 |
| 194 } // namespace ntp_snippets | 211 } // namespace ntp_snippets |
| OLD | NEW |