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

Side by Side Diff: components/ntp_snippets/ntp_snippets_service.cc

Issue 2260703004: Remove ContentSuggestionsProvider::GetProvidedCategories(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Philipp's comments and rebase. Created 4 years, 3 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/ntp_snippets_service.h" 5 #include "components/ntp_snippets/ntp_snippets_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 image_fetcher_(std::move(image_fetcher)), 209 image_fetcher_(std::move(image_fetcher)),
210 image_decoder_(std::move(image_decoder)), 210 image_decoder_(std::move(image_decoder)),
211 database_(std::move(database)), 211 database_(std::move(database)),
212 snippets_status_service_(std::move(status_service)), 212 snippets_status_service_(std::move(status_service)),
213 fetch_after_load_(false), 213 fetch_after_load_(false),
214 provided_category_( 214 provided_category_(
215 category_factory->FromKnownCategory(KnownCategories::ARTICLES)), 215 category_factory->FromKnownCategory(KnownCategories::ARTICLES)),
216 thumbnail_requests_throttler_( 216 thumbnail_requests_throttler_(
217 pref_service, 217 pref_service,
218 RequestThrottler::RequestType::CONTENT_SUGGESTION_THUMBNAIL) { 218 RequestThrottler::RequestType::CONTENT_SUGGESTION_THUMBNAIL) {
219 observer->OnCategoryStatusChanged(this, provided_category_, category_status_);
219 if (database_->IsErrorState()) { 220 if (database_->IsErrorState()) {
220 EnterState(State::ERROR_OCCURRED, CategoryStatus::LOADING_ERROR); 221 EnterState(State::ERROR_OCCURRED, CategoryStatus::LOADING_ERROR);
221 return; 222 return;
222 } 223 }
223 224
224 database_->SetErrorCallback(base::Bind(&NTPSnippetsService::OnDatabaseError, 225 database_->SetErrorCallback(base::Bind(&NTPSnippetsService::OnDatabaseError,
225 base::Unretained(this))); 226 base::Unretained(this)));
226 227
227 // We transition to other states while finalizing the initialization, when the 228 // We transition to other states while finalizing the initialization, when the
228 // database is done loading. 229 // database is done loading.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 if (ready()) { 269 if (ready()) {
269 base::Time now = base::Time::Now(); 270 base::Time now = base::Time::Now();
270 scheduler_->Schedule( 271 scheduler_->Schedule(
271 GetFetchingIntervalWifiCharging(), GetFetchingIntervalWifi(now), 272 GetFetchingIntervalWifiCharging(), GetFetchingIntervalWifi(now),
272 GetFetchingIntervalFallback(), GetRescheduleTime(now)); 273 GetFetchingIntervalFallback(), GetRescheduleTime(now));
273 } else { 274 } else {
274 scheduler_->Unschedule(); 275 scheduler_->Unschedule();
275 } 276 }
276 } 277 }
277 278
278 std::vector<Category> NTPSnippetsService::GetProvidedCategories() {
279 return std::vector<Category>({provided_category_});
280 }
281
282 CategoryStatus NTPSnippetsService::GetCategoryStatus(Category category) { 279 CategoryStatus NTPSnippetsService::GetCategoryStatus(Category category) {
283 DCHECK(category.IsKnownCategory(KnownCategories::ARTICLES)); 280 DCHECK(category.IsKnownCategory(KnownCategories::ARTICLES));
284 return category_status_; 281 return category_status_;
285 } 282 }
286 283
287 CategoryInfo NTPSnippetsService::GetCategoryInfo(Category category) { 284 CategoryInfo NTPSnippetsService::GetCategoryInfo(Category category) {
288 return CategoryInfo( 285 return CategoryInfo(
289 l10n_util::GetStringUTF16(IDS_NTP_ARTICLE_SUGGESTIONS_SECTION_HEADER), 286 l10n_util::GetStringUTF16(IDS_NTP_ARTICLE_SUGGESTIONS_SECTION_HEADER),
290 ContentSuggestionsCardLayout::FULL_CARD, 287 ContentSuggestionsCardLayout::FULL_CARD,
291 /* has_more_button */ false, 288 /* has_more_button */ false,
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 void NTPSnippetsService::UpdateCategoryStatus(CategoryStatus status) { 838 void NTPSnippetsService::UpdateCategoryStatus(CategoryStatus status) {
842 if (status == category_status_) 839 if (status == category_status_)
843 return; 840 return;
844 841
845 category_status_ = status; 842 category_status_ = status;
846 observer()->OnCategoryStatusChanged(this, provided_category_, 843 observer()->OnCategoryStatusChanged(this, provided_category_,
847 category_status_); 844 category_status_);
848 } 845 }
849 846
850 } // namespace ntp_snippets 847 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698