| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_provider.h" | 5 #include "components/ntp_snippets/remote/remote_suggestions_provider.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 const NTPSnippet::PtrVector& snippets) { | 192 const NTPSnippet::PtrVector& snippets) { |
| 193 std::vector<ContentSuggestion> result; | 193 std::vector<ContentSuggestion> result; |
| 194 for (const std::unique_ptr<NTPSnippet>& snippet : snippets) { | 194 for (const std::unique_ptr<NTPSnippet>& snippet : snippets) { |
| 195 // TODO(sfiera): if a snippet is not going to be displayed, move it | 195 // TODO(sfiera): if a snippet is not going to be displayed, move it |
| 196 // directly to content.dismissed on fetch. Otherwise, we might prune | 196 // directly to content.dismissed on fetch. Otherwise, we might prune |
| 197 // other snippets to get down to kMaxSnippetCount, only to hide one of the | 197 // other snippets to get down to kMaxSnippetCount, only to hide one of the |
| 198 // incomplete ones we kept. | 198 // incomplete ones we kept. |
| 199 if (!snippet->is_complete()) { | 199 if (!snippet->is_complete()) { |
| 200 continue; | 200 continue; |
| 201 } | 201 } |
| 202 ContentSuggestion suggestion(category, snippet->id(), snippet->url()); | 202 GURL url = snippet->url(); |
| 203 suggestion.set_amp_url(snippet->amp_url()); | 203 if (base::FeatureList::IsEnabled(kPreferAmpUrlsFeature) && |
| 204 !snippet->amp_url().is_empty()) { |
| 205 url = snippet->amp_url(); |
| 206 } |
| 207 ContentSuggestion suggestion(category, snippet->id(), url); |
| 204 suggestion.set_title(base::UTF8ToUTF16(snippet->title())); | 208 suggestion.set_title(base::UTF8ToUTF16(snippet->title())); |
| 205 suggestion.set_snippet_text(base::UTF8ToUTF16(snippet->snippet())); | 209 suggestion.set_snippet_text(base::UTF8ToUTF16(snippet->snippet())); |
| 206 suggestion.set_publish_date(snippet->publish_date()); | 210 suggestion.set_publish_date(snippet->publish_date()); |
| 207 suggestion.set_publisher_name(base::UTF8ToUTF16(snippet->publisher_name())); | 211 suggestion.set_publisher_name(base::UTF8ToUTF16(snippet->publisher_name())); |
| 208 suggestion.set_score(snippet->score()); | 212 suggestion.set_score(snippet->score()); |
| 209 result.emplace_back(std::move(suggestion)); | 213 result.emplace_back(std::move(suggestion)); |
| 210 } | 214 } |
| 211 return result; | 215 return result; |
| 212 } | 216 } |
| 213 | 217 |
| (...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1338 RemoteSuggestionsProvider::CategoryContent::CategoryContent(CategoryContent&&) = | 1342 RemoteSuggestionsProvider::CategoryContent::CategoryContent(CategoryContent&&) = |
| 1339 default; | 1343 default; |
| 1340 | 1344 |
| 1341 RemoteSuggestionsProvider::CategoryContent::~CategoryContent() = default; | 1345 RemoteSuggestionsProvider::CategoryContent::~CategoryContent() = default; |
| 1342 | 1346 |
| 1343 RemoteSuggestionsProvider::CategoryContent& | 1347 RemoteSuggestionsProvider::CategoryContent& |
| 1344 RemoteSuggestionsProvider::CategoryContent::operator=(CategoryContent&&) = | 1348 RemoteSuggestionsProvider::CategoryContent::operator=(CategoryContent&&) = |
| 1345 default; | 1349 default; |
| 1346 | 1350 |
| 1347 } // namespace ntp_snippets | 1351 } // namespace ntp_snippets |
| OLD | NEW |