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

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

Issue 2207493002: Add CategoryInfo for meta information of content suggestions Categories (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 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 13 matching lines...) Expand all
24 #include "components/image_fetcher/image_decoder.h" 24 #include "components/image_fetcher/image_decoder.h"
25 #include "components/image_fetcher/image_fetcher.h" 25 #include "components/image_fetcher/image_fetcher.h"
26 #include "components/ntp_snippets/ntp_snippets_constants.h" 26 #include "components/ntp_snippets/ntp_snippets_constants.h"
27 #include "components/ntp_snippets/ntp_snippets_database.h" 27 #include "components/ntp_snippets/ntp_snippets_database.h"
28 #include "components/ntp_snippets/pref_names.h" 28 #include "components/ntp_snippets/pref_names.h"
29 #include "components/ntp_snippets/switches.h" 29 #include "components/ntp_snippets/switches.h"
30 #include "components/prefs/pref_registry_simple.h" 30 #include "components/prefs/pref_registry_simple.h"
31 #include "components/prefs/pref_service.h" 31 #include "components/prefs/pref_service.h"
32 #include "components/suggestions/proto/suggestions.pb.h" 32 #include "components/suggestions/proto/suggestions.pb.h"
33 #include "components/variations/variations_associated_data.h" 33 #include "components/variations/variations_associated_data.h"
34 #include "grit/components_strings.h"
35 #include "ui/base/l10n/l10n_util.h"
34 #include "ui/gfx/image/image.h" 36 #include "ui/gfx/image/image.h"
35 37
36 using image_fetcher::ImageDecoder; 38 using image_fetcher::ImageDecoder;
37 using image_fetcher::ImageFetcher; 39 using image_fetcher::ImageFetcher;
38 using suggestions::ChromeSuggestion; 40 using suggestions::ChromeSuggestion;
39 using suggestions::SuggestionsProfile; 41 using suggestions::SuggestionsProfile;
40 using suggestions::SuggestionsService; 42 using suggestions::SuggestionsService;
41 43
42 namespace ntp_snippets { 44 namespace ntp_snippets {
43 45
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 GetFetchingIntervalFallback(), GetRescheduleTime(now)); 269 GetFetchingIntervalFallback(), GetRescheduleTime(now));
268 } else { 270 } else {
269 scheduler_->Unschedule(); 271 scheduler_->Unschedule();
270 } 272 }
271 } 273 }
272 274
273 std::vector<Category> NTPSnippetsService::GetProvidedCategories() { 275 std::vector<Category> NTPSnippetsService::GetProvidedCategories() {
274 return std::vector<Category>({provided_category_}); 276 return std::vector<Category>({provided_category_});
275 } 277 }
276 278
279 CategoryInfo NTPSnippetsService::GetCategoryInfo(Category category) {
280 return CategoryInfo(
281 l10n_util::GetStringUTF16(IDS_NTP_ARTICLE_SUGGESTIONS_SECTION_HEADER));
282 }
283
277 void NTPSnippetsService::FetchSuggestionImage( 284 void NTPSnippetsService::FetchSuggestionImage(
278 const std::string& suggestion_id, 285 const std::string& suggestion_id,
279 const ImageFetchedCallback& callback) { 286 const ImageFetchedCallback& callback) {
280 std::string snippet_id = GetWithinCategoryIDFromUniqueID(suggestion_id); 287 std::string snippet_id = GetWithinCategoryIDFromUniqueID(suggestion_id);
281 database_->LoadImage( 288 database_->LoadImage(
282 snippet_id, 289 snippet_id,
283 base::Bind(&NTPSnippetsService::OnSnippetImageFetchedFromDatabase, 290 base::Bind(&NTPSnippetsService::OnSnippetImageFetchedFromDatabase,
284 base::Unretained(this), snippet_id, callback)); 291 base::Unretained(this), snippet_id, callback));
285 } 292 }
286 293
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 void NTPSnippetsService::UpdateCategoryStatus(CategoryStatus status) { 787 void NTPSnippetsService::UpdateCategoryStatus(CategoryStatus status) {
781 if (status == category_status_) 788 if (status == category_status_)
782 return; 789 return;
783 790
784 category_status_ = status; 791 category_status_ = status;
785 observer()->OnCategoryStatusChanged(this, provided_category_, 792 observer()->OnCategoryStatusChanged(this, provided_category_,
786 category_status_); 793 category_status_);
787 } 794 }
788 795
789 } // namespace ntp_snippets 796 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698