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

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

Issue 2102023002: Add ContentSuggestionsService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add explicit cast from ContentSuggestionsCategory to int Created 4 years, 5 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
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>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "components/ntp_snippets/content_suggestion.h"
15 #include "url/gurl.h" 14 #include "url/gurl.h"
16 15
17 namespace base { 16 namespace base {
18 class DictionaryValue; 17 class DictionaryValue;
19 } 18 }
20 19
21 namespace ntp_snippets { 20 namespace ntp_snippets {
22 21
23 class SnippetProto; 22 class SnippetProto;
24 23
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 !publish_date().is_null() && !expiry_date().is_null() && 118 !publish_date().is_null() && !expiry_date().is_null() &&
120 !best_source().publisher_name.empty(); 119 !best_source().publisher_name.empty();
121 } 120 }
122 121
123 float score() const { return score_; } 122 float score() const { return score_; }
124 void set_score(float score) { score_ = score; } 123 void set_score(float score) { score_ = score; }
125 124
126 bool is_discarded() const { return is_discarded_; } 125 bool is_discarded() const { return is_discarded_; }
127 void set_discarded(bool discarded) { is_discarded_ = discarded; } 126 void set_discarded(bool discarded) { is_discarded_ = discarded; }
128 127
129 std::unique_ptr<ContentSuggestion> ToContentSuggestion() const;
130
131 // Public for testing. 128 // Public for testing.
132 static base::Time TimeFromJsonString(const std::string& timestamp_str); 129 static base::Time TimeFromJsonString(const std::string& timestamp_str);
133 static std::string TimeToJsonString(const base::Time& time); 130 static std::string TimeToJsonString(const base::Time& time);
134 131
135 private: 132 private:
136 void FindBestSource(); 133 void FindBestSource();
137 134
138 std::string id_; 135 std::string id_;
139 std::string title_; 136 std::string title_;
140 GURL salient_image_url_; 137 GURL salient_image_url_;
141 std::string snippet_; 138 std::string snippet_;
142 base::Time publish_date_; 139 base::Time publish_date_;
143 base::Time expiry_date_; 140 base::Time expiry_date_;
144 float score_; 141 float score_;
145 bool is_discarded_; 142 bool is_discarded_;
146 143
147 size_t best_source_index_; 144 size_t best_source_index_;
148 145
149 std::vector<SnippetSource> sources_; 146 std::vector<SnippetSource> sources_;
150 147
151 DISALLOW_COPY_AND_ASSIGN(NTPSnippet); 148 DISALLOW_COPY_AND_ASSIGN(NTPSnippet);
152 }; 149 };
153 150
154 } // namespace ntp_snippets 151 } // namespace ntp_snippets
155 152
156 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPET_H_ 153 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPET_H_
OLDNEW
« no previous file with comments | « components/ntp_snippets/content_suggestions_service.cc ('k') | components/ntp_snippets/ntp_snippet.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698