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

Side by Side Diff: components/ntp_snippets/offline_pages/recent_tab_suggestions_provider.cc

Issue 2447163004: [NTP Snippets] Pass "no suggestions" message from the backend to the UI (Closed)
Patch Set: tests Created 4 years, 1 month 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/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
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 if (category == provided_category_) {
dgn 2016/10/26 14:05:40 why not a DCHECK here like the others?
Marc Treib 2016/10/26 14:29:09 No reason :) Done.
77 return CategoryInfo(l10n_util::GetStringUTF16( 77 return CategoryInfo(
78 IDS_NTP_RECENT_TAB_SUGGESTIONS_SECTION_HEADER), 78 l10n_util::GetStringUTF16(
79 ContentSuggestionsCardLayout::MINIMAL_CARD, 79 IDS_NTP_RECENT_TAB_SUGGESTIONS_SECTION_HEADER),
80 /*has_more_button=*/false, 80 ContentSuggestionsCardLayout::MINIMAL_CARD,
81 /*show_if_empty=*/false); 81 /*has_more_button=*/false,
82 /*show_if_empty=*/false,
83 l10n_util::GetStringUTF16(IDS_NTP_SUGGESTIONS_SECTION_EMPTY));
84 // TODO(vitaliii): Replace IDS_NTP_SUGGESTIONS_SECTION_EMPTY with a
85 // category-specific string.
82 } 86 }
83 NOTREACHED() << "Unknown category " << category.id(); 87 NOTREACHED() << "Unknown category " << category.id();
84 return CategoryInfo(base::string16(), 88 return CategoryInfo(base::string16(),
85 ContentSuggestionsCardLayout::MINIMAL_CARD, 89 ContentSuggestionsCardLayout::MINIMAL_CARD,
86 /*has_more_button=*/false, 90 /*has_more_button=*/false,
87 /*show_if_empty=*/false); 91 /*show_if_empty=*/false, base::string16());
88 } 92 }
89 93
90 void RecentTabSuggestionsProvider::DismissSuggestion( 94 void RecentTabSuggestionsProvider::DismissSuggestion(
91 const ContentSuggestion::ID& suggestion_id) { 95 const ContentSuggestion::ID& suggestion_id) {
92 DCHECK_EQ(provided_category_, suggestion_id.category()); 96 DCHECK_EQ(provided_category_, suggestion_id.category());
93 std::set<std::string> dismissed_ids = ReadDismissedIDsFromPrefs(); 97 std::set<std::string> dismissed_ids = ReadDismissedIDsFromPrefs();
94 dismissed_ids.insert(suggestion_id.id_within_category()); 98 dismissed_ids.insert(suggestion_id.id_within_category());
95 StoreDismissedIDsToPrefs(dismissed_ids); 99 StoreDismissedIDsToPrefs(dismissed_ids);
96 } 100 }
97 101
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 } 269 }
266 270
267 void RecentTabSuggestionsProvider::StoreDismissedIDsToPrefs( 271 void RecentTabSuggestionsProvider::StoreDismissedIDsToPrefs(
268 const std::set<std::string>& dismissed_ids) { 272 const std::set<std::string>& dismissed_ids) {
269 prefs::StoreDismissedIDsToPrefs(pref_service_, 273 prefs::StoreDismissedIDsToPrefs(pref_service_,
270 prefs::kDismissedRecentOfflineTabSuggestions, 274 prefs::kDismissedRecentOfflineTabSuggestions,
271 dismissed_ids); 275 dismissed_ids);
272 } 276 }
273 277
274 } // namespace ntp_snippets 278 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698