| 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 #ifndef COMPONENTS_NTP_SNIPPETS_NTP_SNIPPET_H_ | 5 #ifndef COMPONENTS_NTP_SNIPPETS_NTP_SNIPPET_H_ |
| 6 #define COMPONENTS_NTP_SNIPPETS_NTP_SNIPPET_H_ | 6 #define COMPONENTS_NTP_SNIPPETS_NTP_SNIPPET_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 void add_source(const SnippetSource& source) { sources_.push_back(source); } | 93 void add_source(const SnippetSource& source) { sources_.push_back(source); } |
| 94 | 94 |
| 95 // If this snippet has all the data we need to show a full card to the user | 95 // If this snippet has all the data we need to show a full card to the user |
| 96 bool is_complete() const { | 96 bool is_complete() const { |
| 97 return url().is_valid() && !sources().empty() && !title().empty() && | 97 return url().is_valid() && !sources().empty() && !title().empty() && |
| 98 !snippet().empty() && salient_image_url().is_valid() && | 98 !snippet().empty() && salient_image_url().is_valid() && |
| 99 !publish_date().is_null() && !expiry_date().is_null() && | 99 !publish_date().is_null() && !expiry_date().is_null() && |
| 100 !best_source().publisher_name.empty(); | 100 !best_source().publisher_name.empty(); |
| 101 } | 101 } |
| 102 | 102 |
| 103 float score() const { return score_; } |
| 104 void set_score(float score) { score_ = score; } |
| 105 |
| 103 // Public for testing. | 106 // Public for testing. |
| 104 static base::Time TimeFromJsonString(const std::string& timestamp_str); | 107 static base::Time TimeFromJsonString(const std::string& timestamp_str); |
| 105 static std::string TimeToJsonString(const base::Time& time); | 108 static std::string TimeToJsonString(const base::Time& time); |
| 106 | 109 |
| 107 private: | 110 private: |
| 108 GURL url_; | 111 GURL url_; |
| 109 std::string title_; | 112 std::string title_; |
| 110 GURL salient_image_url_; | 113 GURL salient_image_url_; |
| 111 std::string snippet_; | 114 std::string snippet_; |
| 112 base::Time publish_date_; | 115 base::Time publish_date_; |
| 113 base::Time expiry_date_; | 116 base::Time expiry_date_; |
| 114 GURL amp_url_; | 117 GURL amp_url_; |
| 115 size_t best_source_index_; | 118 float score_; |
| 116 | |
| 117 std::vector<SnippetSource> sources_; | |
| 118 | 119 |
| 119 DISALLOW_COPY_AND_ASSIGN(NTPSnippet); | 120 DISALLOW_COPY_AND_ASSIGN(NTPSnippet); |
| 120 }; | 121 }; |
| 121 | 122 |
| 122 } // namespace ntp_snippets | 123 } // namespace ntp_snippets |
| 123 | 124 |
| 124 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPET_H_ | 125 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPET_H_ |
| OLD | NEW |