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_suggestion.h" | 5 #include "components/ntp_snippets/remote/remote_suggestion.h" |
6 | 6 |
7 #include "base/feature_list.h" | 7 #include "base/feature_list.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
387 } | 387 } |
388 | 388 |
389 ContentSuggestion RemoteSuggestion::ToContentSuggestion( | 389 ContentSuggestion RemoteSuggestion::ToContentSuggestion( |
390 Category category) const { | 390 Category category) const { |
391 GURL url = url_; | 391 GURL url = url_; |
392 if (base::FeatureList::IsEnabled(kPreferAmpUrlsFeature) && | 392 if (base::FeatureList::IsEnabled(kPreferAmpUrlsFeature) && |
393 !amp_url_.is_empty()) { | 393 !amp_url_.is_empty()) { |
394 url = amp_url_; | 394 url = amp_url_; |
395 } | 395 } |
396 ContentSuggestion suggestion(category, id(), url); | 396 ContentSuggestion suggestion(category, id(), url); |
397 // If AMP URL is provided as the main URL, we set the non-AMP URL for favicon. | |
Marc Treib
2017/04/12 11:48:00
Please describe the "why" rather than the "what".
jkrcal
2017/04/12 12:44:19
Done.
| |
398 if (base::FeatureList::IsEnabled(kPreferAmpUrlsFeature) && | |
399 !amp_url_.is_empty()) { | |
400 suggestion.set_url_with_favicon(url_); | |
401 } | |
397 suggestion.set_title(base::UTF8ToUTF16(title_)); | 402 suggestion.set_title(base::UTF8ToUTF16(title_)); |
398 suggestion.set_snippet_text(base::UTF8ToUTF16(snippet_)); | 403 suggestion.set_snippet_text(base::UTF8ToUTF16(snippet_)); |
399 suggestion.set_publish_date(publish_date_); | 404 suggestion.set_publish_date(publish_date_); |
400 suggestion.set_publisher_name(base::UTF8ToUTF16(publisher_name_)); | 405 suggestion.set_publisher_name(base::UTF8ToUTF16(publisher_name_)); |
401 suggestion.set_score(score_); | 406 suggestion.set_score(score_); |
402 if (should_notify_) { | 407 if (should_notify_) { |
403 NotificationExtra extra; | 408 NotificationExtra extra; |
404 extra.deadline = notification_deadline_; | 409 extra.deadline = notification_deadline_; |
405 suggestion.set_notification_extra( | 410 suggestion.set_notification_extra( |
406 base::MakeUnique<NotificationExtra>(extra)); | 411 base::MakeUnique<NotificationExtra>(extra)); |
(...skipping 21 matching lines...) Expand all Loading... | |
428 } | 433 } |
429 | 434 |
430 // static | 435 // static |
431 std::unique_ptr<RemoteSuggestion> RemoteSuggestion::MakeUnique( | 436 std::unique_ptr<RemoteSuggestion> RemoteSuggestion::MakeUnique( |
432 const std::vector<std::string>& ids, | 437 const std::vector<std::string>& ids, |
433 int remote_category_id) { | 438 int remote_category_id) { |
434 return base::WrapUnique(new RemoteSuggestion(ids, remote_category_id)); | 439 return base::WrapUnique(new RemoteSuggestion(ids, remote_category_id)); |
435 } | 440 } |
436 | 441 |
437 } // namespace ntp_snippets | 442 } // namespace ntp_snippets |
OLD | NEW |