| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 bool is_complete() const { | 115 bool is_complete() const { |
| 116 return !id().empty() && !sources().empty() && !title().empty() && | 116 return !id().empty() && !sources().empty() && !title().empty() && |
| 117 !snippet().empty() && salient_image_url().is_valid() && | 117 !snippet().empty() && salient_image_url().is_valid() && |
| 118 !publish_date().is_null() && !expiry_date().is_null() && | 118 !publish_date().is_null() && !expiry_date().is_null() && |
| 119 !best_source().publisher_name.empty(); | 119 !best_source().publisher_name.empty(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 float score() const { return score_; } | 122 float score() const { return score_; } |
| 123 void set_score(float score) { score_ = score; } | 123 void set_score(float score) { score_ = score; } |
| 124 | 124 |
| 125 bool is_discarded() const { return is_discarded_; } | 125 bool is_dismissed() const { return is_dismissed_; } |
| 126 void set_discarded(bool discarded) { is_discarded_ = discarded; } | 126 void set_dismissed(bool dismissed) { is_dismissed_ = dismissed; } |
| 127 | 127 |
| 128 // Public for testing. | 128 // Public for testing. |
| 129 static base::Time TimeFromJsonString(const std::string& timestamp_str); | 129 static base::Time TimeFromJsonString(const std::string& timestamp_str); |
| 130 static std::string TimeToJsonString(const base::Time& time); | 130 static std::string TimeToJsonString(const base::Time& time); |
| 131 | 131 |
| 132 private: | 132 private: |
| 133 void FindBestSource(); | 133 void FindBestSource(); |
| 134 | 134 |
| 135 std::string id_; | 135 std::string id_; |
| 136 std::string title_; | 136 std::string title_; |
| 137 GURL salient_image_url_; | 137 GURL salient_image_url_; |
| 138 std::string snippet_; | 138 std::string snippet_; |
| 139 base::Time publish_date_; | 139 base::Time publish_date_; |
| 140 base::Time expiry_date_; | 140 base::Time expiry_date_; |
| 141 float score_; | 141 float score_; |
| 142 bool is_discarded_; | 142 bool is_dismissed_; |
| 143 | 143 |
| 144 size_t best_source_index_; | 144 size_t best_source_index_; |
| 145 | 145 |
| 146 std::vector<SnippetSource> sources_; | 146 std::vector<SnippetSource> sources_; |
| 147 | 147 |
| 148 DISALLOW_COPY_AND_ASSIGN(NTPSnippet); | 148 DISALLOW_COPY_AND_ASSIGN(NTPSnippet); |
| 149 }; | 149 }; |
| 150 | 150 |
| 151 } // namespace ntp_snippets | 151 } // namespace ntp_snippets |
| 152 | 152 |
| 153 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPET_H_ | 153 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPET_H_ |
| OLD | NEW |