Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: components/ntp_snippets/ntp_snippet.h

Issue 1922083004: Allow fetching personalized snippets from ChromeReader. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Yet another unittest fix Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/ntp_snippets/DEPS ('k') | components/ntp_snippets/ntp_snippet.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 void add_source(const SnippetSource& source) { sources_.push_back(source); } 101 void add_source(const SnippetSource& source) { sources_.push_back(source); }
102 102
103 // If this snippet has all the data we need to show a full card to the user 103 // If this snippet has all the data we need to show a full card to the user
104 bool is_complete() const { 104 bool is_complete() const {
105 return url().is_valid() && !sources().empty() && !title().empty() && 105 return url().is_valid() && !sources().empty() && !title().empty() &&
106 !snippet().empty() && salient_image_url().is_valid() && 106 !snippet().empty() && salient_image_url().is_valid() &&
107 !publish_date().is_null() && !expiry_date().is_null() && 107 !publish_date().is_null() && !expiry_date().is_null() &&
108 !best_source().publisher_name.empty(); 108 !best_source().publisher_name.empty();
109 } 109 }
110 110
111 float score() const { return score_; }
112 void set_score(float score) { score_ = score; }
113
111 // Public for testing. 114 // Public for testing.
112 static base::Time TimeFromJsonString(const std::string& timestamp_str); 115 static base::Time TimeFromJsonString(const std::string& timestamp_str);
113 static std::string TimeToJsonString(const base::Time& time); 116 static std::string TimeToJsonString(const base::Time& time);
114 117
115 private: 118 private:
116 GURL url_; 119 GURL url_;
117 std::string title_; 120 std::string title_;
118 GURL salient_image_url_; 121 GURL salient_image_url_;
119 std::string snippet_; 122 std::string snippet_;
120 base::Time publish_date_; 123 base::Time publish_date_;
121 base::Time expiry_date_; 124 base::Time expiry_date_;
122 GURL amp_url_; 125 GURL amp_url_;
126 float score_;
123 size_t best_source_index_; 127 size_t best_source_index_;
124 128
125 std::vector<SnippetSource> sources_; 129 std::vector<SnippetSource> sources_;
126 130
127 DISALLOW_COPY_AND_ASSIGN(NTPSnippet); 131 DISALLOW_COPY_AND_ASSIGN(NTPSnippet);
128 }; 132 };
129 133
130 } // namespace ntp_snippets 134 } // namespace ntp_snippets
131 135
132 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPET_H_ 136 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPET_H_
OLDNEW
« no previous file with comments | « components/ntp_snippets/DEPS ('k') | components/ntp_snippets/ntp_snippet.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698