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

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: DCHECK against empty base::Optional<CategoryInfo> in SnippetsInternals 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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
277 CategoryStatus NTPSnippetsService::GetCategoryStatus(Category category) { 279 CategoryStatus NTPSnippetsService::GetCategoryStatus(Category category) {
278 DCHECK(category.IsKnownCategory(KnownCategories::ARTICLES)); 280 DCHECK(category.IsKnownCategory(KnownCategories::ARTICLES));
279 return category_status_; 281 return category_status_;
280 } 282 }
281 283
284 CategoryInfo NTPSnippetsService::GetCategoryInfo(Category category) {
285 return CategoryInfo(
286 l10n_util::GetStringUTF16(IDS_NTP_ARTICLE_SUGGESTIONS_SECTION_HEADER),
287 ContentSuggestionsCardLayout::FULL_CARD);
288 }
289
282 void NTPSnippetsService::DismissSuggestion(const std::string& suggestion_id) { 290 void NTPSnippetsService::DismissSuggestion(const std::string& suggestion_id) {
283 if (!ready()) 291 if (!ready())
284 return; 292 return;
285 293
286 std::string snippet_id = GetWithinCategoryIDFromUniqueID(suggestion_id); 294 std::string snippet_id = GetWithinCategoryIDFromUniqueID(suggestion_id);
287 295
288 auto it = 296 auto it =
289 std::find_if(snippets_.begin(), snippets_.end(), 297 std::find_if(snippets_.begin(), snippets_.end(),
290 [&snippet_id](const std::unique_ptr<NTPSnippet>& snippet) { 298 [&snippet_id](const std::unique_ptr<NTPSnippet>& snippet) {
291 return snippet->id() == snippet_id; 299 return snippet->id() == snippet_id;
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 void NTPSnippetsService::UpdateCategoryStatus(CategoryStatus status) { 813 void NTPSnippetsService::UpdateCategoryStatus(CategoryStatus status) {
806 if (status == category_status_) 814 if (status == category_status_)
807 return; 815 return;
808 816
809 category_status_ = status; 817 category_status_ = status;
810 observer()->OnCategoryStatusChanged(this, provided_category_, 818 observer()->OnCategoryStatusChanged(this, provided_category_,
811 category_status_); 819 category_status_);
812 } 820 }
813 821
814 } // namespace ntp_snippets 822 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698