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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 !publish_date().is_null() && !expiry_date().is_null() && | 119 !publish_date().is_null() && !expiry_date().is_null() && |
120 !best_source().publisher_name.empty(); | 120 !best_source().publisher_name.empty(); |
121 } | 121 } |
122 | 122 |
123 float score() const { return score_; } | 123 float score() const { return score_; } |
124 void set_score(float score) { score_ = score; } | 124 void set_score(float score) { score_ = score; } |
125 | 125 |
126 bool is_discarded() const { return is_discarded_; } | 126 bool is_discarded() const { return is_discarded_; } |
127 void set_discarded(bool discarded) { is_discarded_ = discarded; } | 127 void set_discarded(bool discarded) { is_discarded_ = discarded; } |
128 | 128 |
129 std::unique_ptr<ContentSuggestion> ToContentSuggestion() const; | 129 std::unique_ptr<ContentSuggestion> ToContentSuggestion( |
130 const std::string& id) const; | |
Marc Treib
2016/07/05 13:17:12
Mh, this is ugly... so the caller has to get the I
Philipp Keck
2016/07/05 13:52:00
Done. Now that MakeUniqueID is static, that call c
| |
130 | 131 |
131 // Public for testing. | 132 // Public for testing. |
132 static base::Time TimeFromJsonString(const std::string& timestamp_str); | 133 static base::Time TimeFromJsonString(const std::string& timestamp_str); |
133 static std::string TimeToJsonString(const base::Time& time); | 134 static std::string TimeToJsonString(const base::Time& time); |
134 | 135 |
135 private: | 136 private: |
136 void FindBestSource(); | 137 void FindBestSource(); |
137 | 138 |
138 std::string id_; | 139 std::string id_; |
139 std::string title_; | 140 std::string title_; |
140 GURL salient_image_url_; | 141 GURL salient_image_url_; |
141 std::string snippet_; | 142 std::string snippet_; |
142 base::Time publish_date_; | 143 base::Time publish_date_; |
143 base::Time expiry_date_; | 144 base::Time expiry_date_; |
144 float score_; | 145 float score_; |
145 bool is_discarded_; | 146 bool is_discarded_; |
146 | 147 |
147 size_t best_source_index_; | 148 size_t best_source_index_; |
148 | 149 |
149 std::vector<SnippetSource> sources_; | 150 std::vector<SnippetSource> sources_; |
150 | 151 |
151 DISALLOW_COPY_AND_ASSIGN(NTPSnippet); | 152 DISALLOW_COPY_AND_ASSIGN(NTPSnippet); |
152 }; | 153 }; |
153 | 154 |
154 } // namespace ntp_snippets | 155 } // namespace ntp_snippets |
155 | 156 |
156 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPET_H_ | 157 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPET_H_ |
OLD | NEW |