OLD | NEW |
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/offline_pages/recent_tab_suggestions_provider.
h" | 5 #include "components/ntp_snippets/offline_pages/recent_tab_suggestions_provider.
h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 | 66 |
67 CategoryStatus RecentTabSuggestionsProvider::GetCategoryStatus( | 67 CategoryStatus RecentTabSuggestionsProvider::GetCategoryStatus( |
68 Category category) { | 68 Category category) { |
69 if (category == provided_category_) | 69 if (category == provided_category_) |
70 return category_status_; | 70 return category_status_; |
71 NOTREACHED() << "Unknown category " << category.id(); | 71 NOTREACHED() << "Unknown category " << category.id(); |
72 return CategoryStatus::NOT_PROVIDED; | 72 return CategoryStatus::NOT_PROVIDED; |
73 } | 73 } |
74 | 74 |
75 CategoryInfo RecentTabSuggestionsProvider::GetCategoryInfo(Category category) { | 75 CategoryInfo RecentTabSuggestionsProvider::GetCategoryInfo(Category category) { |
76 if (category == provided_category_) { | 76 DCHECK_EQ(provided_category_, category); |
77 return CategoryInfo(l10n_util::GetStringUTF16( | 77 return CategoryInfo( |
78 IDS_NTP_RECENT_TAB_SUGGESTIONS_SECTION_HEADER), | 78 l10n_util::GetStringUTF16(IDS_NTP_RECENT_TAB_SUGGESTIONS_SECTION_HEADER), |
79 ContentSuggestionsCardLayout::MINIMAL_CARD, | 79 ContentSuggestionsCardLayout::MINIMAL_CARD, |
80 /*has_more_button=*/false, | 80 /*has_more_button=*/false, |
81 /*show_if_empty=*/false); | 81 /*show_if_empty=*/false, |
82 } | 82 l10n_util::GetStringUTF16(IDS_NTP_SUGGESTIONS_SECTION_EMPTY)); |
83 NOTREACHED() << "Unknown category " << category.id(); | 83 // TODO(vitaliii): Replace IDS_NTP_SUGGESTIONS_SECTION_EMPTY with a |
84 return CategoryInfo(base::string16(), | 84 // category-specific string. |
85 ContentSuggestionsCardLayout::MINIMAL_CARD, | |
86 /*has_more_button=*/false, | |
87 /*show_if_empty=*/false); | |
88 } | 85 } |
89 | 86 |
90 void RecentTabSuggestionsProvider::DismissSuggestion( | 87 void RecentTabSuggestionsProvider::DismissSuggestion( |
91 const ContentSuggestion::ID& suggestion_id) { | 88 const ContentSuggestion::ID& suggestion_id) { |
92 DCHECK_EQ(provided_category_, suggestion_id.category()); | 89 DCHECK_EQ(provided_category_, suggestion_id.category()); |
93 std::set<std::string> dismissed_ids = ReadDismissedIDsFromPrefs(); | 90 std::set<std::string> dismissed_ids = ReadDismissedIDsFromPrefs(); |
94 dismissed_ids.insert(suggestion_id.id_within_category()); | 91 dismissed_ids.insert(suggestion_id.id_within_category()); |
95 StoreDismissedIDsToPrefs(dismissed_ids); | 92 StoreDismissedIDsToPrefs(dismissed_ids); |
96 } | 93 } |
97 | 94 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 } | 262 } |
266 | 263 |
267 void RecentTabSuggestionsProvider::StoreDismissedIDsToPrefs( | 264 void RecentTabSuggestionsProvider::StoreDismissedIDsToPrefs( |
268 const std::set<std::string>& dismissed_ids) { | 265 const std::set<std::string>& dismissed_ids) { |
269 prefs::StoreDismissedIDsToPrefs(pref_service_, | 266 prefs::StoreDismissedIDsToPrefs(pref_service_, |
270 prefs::kDismissedRecentOfflineTabSuggestions, | 267 prefs::kDismissedRecentOfflineTabSuggestions, |
271 dismissed_ids); | 268 dismissed_ids); |
272 } | 269 } |
273 | 270 |
274 } // namespace ntp_snippets | 271 } // namespace ntp_snippets |
OLD | NEW |