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/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 Loading... |
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( | 120 return CategoryInfo(l10n_util::GetStringUTF16( |
121 l10n_util::GetStringUTF16( | 121 IDS_NTP_FOREIGN_SESSIONS_SUGGESTIONS_SECTION_HEADER), |
122 IDS_NTP_FOREIGN_SESSIONS_SUGGESTIONS_SECTION_HEADER), | 122 ContentSuggestionsCardLayout::MINIMAL_CARD, |
123 ContentSuggestionsCardLayout::MINIMAL_CARD, | 123 /*has_more_action=*/false, |
124 /*has_more_action=*/false, | 124 /*has_reload_action=*/false, |
125 /*has_reload_action=*/false, | 125 /*has_view_all_action=*/true, |
126 /*has_view_all_action=*/true, | 126 /*show_if_empty=*/false, |
127 /*show_if_empty=*/false, | 127 l10n_util::GetStringUTF16( |
128 l10n_util::GetStringUTF16(IDS_NTP_SUGGESTIONS_SECTION_EMPTY)); | 128 IDS_NTP_FOREIGN_SESSIONS_SUGGESTIONS_SECTION_EMPTY)); |
129 // TODO(skym): Replace IDS_NTP_SUGGESTIONS_SECTION_EMPTY with a | |
130 // category-specific string. | |
131 } | 129 } |
132 | 130 |
133 void ForeignSessionsSuggestionsProvider::DismissSuggestion( | 131 void ForeignSessionsSuggestionsProvider::DismissSuggestion( |
134 const ContentSuggestion::ID& suggestion_id) { | 132 const ContentSuggestion::ID& suggestion_id) { |
135 // 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 |
136 // irrelevant entries. Could either use a timestamp and expire after a | 134 // irrelevant entries. Could either use a timestamp and expire after a |
137 // threshold, or compare with current foreign tabs and remove anything that | 135 // threshold, or compare with current foreign tabs and remove anything that |
138 // isn't actively blockign a foreign_sessions tab. | 136 // isn't actively blockign a foreign_sessions tab. |
139 std::set<std::string> dismissed_ids = prefs::ReadDismissedIDsFromPrefs( | 137 std::set<std::string> dismissed_ids = prefs::ReadDismissedIDsFromPrefs( |
140 *pref_service_, prefs::kDismissedForeignSessionsSuggestions); | 138 *pref_service_, prefs::kDismissedForeignSessionsSuggestions); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 data.navigation->virtual_url().spec(), | 317 data.navigation->virtual_url().spec(), |
320 data.navigation->virtual_url()); | 318 data.navigation->virtual_url()); |
321 suggestion.set_title(data.navigation->title()); | 319 suggestion.set_title(data.navigation->title()); |
322 suggestion.set_publish_date(data.tab->timestamp); | 320 suggestion.set_publish_date(data.tab->timestamp); |
323 suggestion.set_publisher_name( | 321 suggestion.set_publisher_name( |
324 base::UTF8ToUTF16(data.navigation->virtual_url().host())); | 322 base::UTF8ToUTF16(data.navigation->virtual_url().host())); |
325 return suggestion; | 323 return suggestion; |
326 } | 324 } |
327 | 325 |
328 } // namespace ntp_snippets | 326 } // namespace ntp_snippets |
OLD | NEW |