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/remote/remote_suggestions_fetcher.h" | 5 #include "components/ntp_snippets/remote/remote_suggestions_fetcher.h" |
6 | 6 |
7 #include <cstdlib> | 7 #include <cstdlib> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 return GURL{kContentSuggestionsStagingServer}; | 209 return GURL{kContentSuggestionsStagingServer}; |
210 } | 210 } |
211 | 211 |
212 CategoryInfo BuildArticleCategoryInfo( | 212 CategoryInfo BuildArticleCategoryInfo( |
213 const base::Optional<base::string16>& title) { | 213 const base::Optional<base::string16>& title) { |
214 return CategoryInfo( | 214 return CategoryInfo( |
215 title.has_value() ? title.value() | 215 title.has_value() ? title.value() |
216 : l10n_util::GetStringUTF16( | 216 : l10n_util::GetStringUTF16( |
217 IDS_NTP_ARTICLE_SUGGESTIONS_SECTION_HEADER), | 217 IDS_NTP_ARTICLE_SUGGESTIONS_SECTION_HEADER), |
218 ContentSuggestionsCardLayout::FULL_CARD, | 218 ContentSuggestionsCardLayout::FULL_CARD, |
219 /*has_fetch_action=*/true, | 219 ContentSuggestionsAdditionalAction::FETCH, |
220 /*has_view_all_action=*/false, | |
221 /*show_if_empty=*/true, | 220 /*show_if_empty=*/true, |
222 l10n_util::GetStringUTF16(IDS_NTP_ARTICLE_SUGGESTIONS_SECTION_EMPTY)); | 221 l10n_util::GetStringUTF16(IDS_NTP_ARTICLE_SUGGESTIONS_SECTION_EMPTY)); |
223 } | 222 } |
224 | 223 |
225 CategoryInfo BuildRemoteCategoryInfo(const base::string16& title, | 224 CategoryInfo BuildRemoteCategoryInfo(const base::string16& title, |
226 bool allow_fetching_more_results) { | 225 bool allow_fetching_more_results) { |
| 226 ContentSuggestionsAdditionalAction action = |
| 227 ContentSuggestionsAdditionalAction::NONE; |
| 228 if (allow_fetching_more_results) { |
| 229 action = ContentSuggestionsAdditionalAction::FETCH; |
| 230 } |
227 return CategoryInfo( | 231 return CategoryInfo( |
228 title, ContentSuggestionsCardLayout::FULL_CARD, | 232 title, ContentSuggestionsCardLayout::FULL_CARD, action, |
229 /*has_fetch_action=*/allow_fetching_more_results, | |
230 /*has_view_all_action=*/false, | |
231 /*show_if_empty=*/false, | 233 /*show_if_empty=*/false, |
232 // TODO(tschumann): The message for no-articles is likely wrong | 234 // TODO(tschumann): The message for no-articles is likely wrong |
233 // and needs to be added to the stubby protocol if we want to | 235 // and needs to be added to the stubby protocol if we want to |
234 // support it. | 236 // support it. |
235 l10n_util::GetStringUTF16(IDS_NTP_ARTICLE_SUGGESTIONS_SECTION_EMPTY)); | 237 l10n_util::GetStringUTF16(IDS_NTP_ARTICLE_SUGGESTIONS_SECTION_EMPTY)); |
236 } | 238 } |
237 | 239 |
238 RemoteSuggestionsFetcher::FetchedCategory::FetchedCategory(Category c, | 240 RemoteSuggestionsFetcher::FetchedCategory::FetchedCategory(Category c, |
239 CategoryInfo&& info) | 241 CategoryInfo&& info) |
240 : category(c), info(info) {} | 242 : category(c), info(info) {} |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 categories->back().suggestions = std::move(suggestions); | 562 categories->back().suggestions = std::move(suggestions); |
561 } | 563 } |
562 return true; | 564 return true; |
563 } | 565 } |
564 } | 566 } |
565 NOTREACHED(); | 567 NOTREACHED(); |
566 return false; | 568 return false; |
567 } | 569 } |
568 | 570 |
569 } // namespace ntp_snippets | 571 } // namespace ntp_snippets |
OLD | NEW |