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

Side by Side Diff: components/ntp_snippets/sessions/foreign_sessions_suggestions_provider.cc

Issue 2447163004: [NTP Snippets] Pass "no suggestions" message from the backend to the UI (Closed)
Patch Set: review 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/sessions/foreign_sessions_suggestions_provider .h" 5 #include "components/ntp_snippets/sessions/foreign_sessions_suggestions_provider .h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <tuple> 9 #include <tuple>
10 #include <utility> 10 #include <utility>
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 110
111 CategoryStatus ForeignSessionsSuggestionsProvider::GetCategoryStatus( 111 CategoryStatus ForeignSessionsSuggestionsProvider::GetCategoryStatus(
112 Category category) { 112 Category category) {
113 DCHECK_EQ(category, provided_category_); 113 DCHECK_EQ(category, provided_category_);
114 return category_status_; 114 return category_status_;
115 } 115 }
116 116
117 CategoryInfo ForeignSessionsSuggestionsProvider::GetCategoryInfo( 117 CategoryInfo ForeignSessionsSuggestionsProvider::GetCategoryInfo(
118 Category category) { 118 Category category) {
119 DCHECK_EQ(category, provided_category_); 119 DCHECK_EQ(category, provided_category_);
120 return CategoryInfo(l10n_util::GetStringUTF16( 120 return CategoryInfo(
121 IDS_NTP_FOREIGN_SESSIONS_SUGGESTIONS_SECTION_HEADER), 121 l10n_util::GetStringUTF16(
122 ContentSuggestionsCardLayout::MINIMAL_CARD, 122 IDS_NTP_FOREIGN_SESSIONS_SUGGESTIONS_SECTION_HEADER),
123 /*has_more_button=*/true, 123 ContentSuggestionsCardLayout::MINIMAL_CARD,
124 /*show_if_empty=*/false); 124 /*has_more_button=*/true,
125 /*show_if_empty=*/false,
126 l10n_util::GetStringUTF16(IDS_NTP_SUGGESTIONS_SECTION_EMPTY));
127 // TODO(skym): Replace IDS_NTP_SUGGESTIONS_SECTION_EMPTY with a
128 // category-specific string.
125 } 129 }
126 130
127 void ForeignSessionsSuggestionsProvider::DismissSuggestion( 131 void ForeignSessionsSuggestionsProvider::DismissSuggestion(
128 const ContentSuggestion::ID& suggestion_id) { 132 const ContentSuggestion::ID& suggestion_id) {
129 // TODO(skym): Right now this continuously grows, without clearing out old and 133 // TODO(skym): Right now this continuously grows, without clearing out old and
130 // irrelevant entries. Could either use a timestamp and expire after a 134 // irrelevant entries. Could either use a timestamp and expire after a
131 // threshold, or compare with current foreign tabs and remove anything that 135 // threshold, or compare with current foreign tabs and remove anything that
132 // isn't actively blockign a foreign_sessions tab. 136 // isn't actively blockign a foreign_sessions tab.
133 std::set<std::string> dismissed_ids = prefs::ReadDismissedIDsFromPrefs( 137 std::set<std::string> dismissed_ids = prefs::ReadDismissedIDsFromPrefs(
134 *pref_service_, prefs::kDismissedForeignSessionsSuggestions); 138 *pref_service_, prefs::kDismissedForeignSessionsSuggestions);
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 // This field is sandwiched between the url's favicon, which is on the left, 309 // This field is sandwiched between the url's favicon, which is on the left,
306 // and the |publish_date|, which is to the right. The domain should always 310 // and the |publish_date|, which is to the right. The domain should always
307 // appear next to the favicon. 311 // appear next to the favicon.
308 suggestion.set_publisher_name( 312 suggestion.set_publisher_name(
309 base::UTF8ToUTF16(data.navigation->virtual_url().host() + " - " + 313 base::UTF8ToUTF16(data.navigation->virtual_url().host() + " - " +
310 data.session->session_name)); 314 data.session->session_name));
311 return suggestion; 315 return suggestion;
312 } 316 }
313 317
314 } // namespace ntp_snippets 318 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698