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

Side by Side Diff: components/ntp_snippets/content_suggestions_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 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/content_suggestions_service.h" 5 #include "components/ntp_snippets/content_suggestions_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 return CategoryStatus::ALL_SUGGESTIONS_EXPLICITLY_DISABLED; 43 return CategoryStatus::ALL_SUGGESTIONS_EXPLICITLY_DISABLED;
44 } 44 }
45 45
46 auto iterator = providers_by_category_.find(category); 46 auto iterator = providers_by_category_.find(category);
47 if (iterator == providers_by_category_.end()) 47 if (iterator == providers_by_category_.end())
48 return CategoryStatus::NOT_PROVIDED; 48 return CategoryStatus::NOT_PROVIDED;
49 49
50 return iterator->second->GetCategoryStatus(category); 50 return iterator->second->GetCategoryStatus(category);
51 } 51 }
52 52
53 base::Optional<CategoryInfo> ContentSuggestionsService::GetCategoryInfo(
54 Category category) const {
55 auto iterator = providers_by_category_.find(category);
56 if (iterator == providers_by_category_.end())
57 return base::Optional<CategoryInfo>();
58 return iterator->second->GetCategoryInfo(category);
59 }
60
53 const std::vector<ContentSuggestion>& 61 const std::vector<ContentSuggestion>&
54 ContentSuggestionsService::GetSuggestionsForCategory(Category category) const { 62 ContentSuggestionsService::GetSuggestionsForCategory(Category category) const {
55 auto iterator = suggestions_by_category_.find(category); 63 auto iterator = suggestions_by_category_.find(category);
56 if (iterator == suggestions_by_category_.end()) 64 if (iterator == suggestions_by_category_.end())
57 return no_suggestions_; 65 return no_suggestions_;
58 return iterator->second; 66 return iterator->second;
59 } 67 }
60 68
61 void ContentSuggestionsService::FetchSuggestionImage( 69 void ContentSuggestionsService::FetchSuggestionImage(
62 const std::string& suggestion_id, 70 const std::string& suggestion_id,
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 return true; 247 return true;
240 } 248 }
241 249
242 void ContentSuggestionsService::NotifyCategoryStatusChanged(Category category) { 250 void ContentSuggestionsService::NotifyCategoryStatusChanged(Category category) {
243 FOR_EACH_OBSERVER( 251 FOR_EACH_OBSERVER(
244 Observer, observers_, 252 Observer, observers_,
245 OnCategoryStatusChanged(category, GetCategoryStatus(category))); 253 OnCategoryStatusChanged(category, GetCategoryStatus(category)));
246 } 254 }
247 255
248 } // namespace ntp_snippets 256 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « components/ntp_snippets/content_suggestions_service.h ('k') | components/ntp_snippets/content_suggestions_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698