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

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

Issue 2616543002: Expose notification info in ContentSuggestion (Closed)
Patch Set: Address comments Created 3 years, 11 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_REMOTE_NTP_SNIPPET_H_ 5 #ifndef COMPONENTS_NTP_SNIPPETS_REMOTE_NTP_SNIPPET_H_
6 #define COMPONENTS_NTP_SNIPPETS_REMOTE_NTP_SNIPPET_H_ 6 #define COMPONENTS_NTP_SNIPPETS_REMOTE_NTP_SNIPPET_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "components/ntp_snippets/content_suggestion.h"
15 #include "url/gurl.h" 16 #include "url/gurl.h"
16 17
17 namespace base { 18 namespace base {
18 class DictionaryValue; 19 class DictionaryValue;
19 } // namespace base 20 } // namespace base
20 21
21 namespace ntp_snippets { 22 namespace ntp_snippets {
22 23
23 // Exposed for tests. 24 // Exposed for tests.
24 extern const int kArticlesRemoteId; 25 extern const int kArticlesRemoteId;
(...skipping 29 matching lines...) Expand all
54 static std::unique_ptr<NTPSnippet> CreateForTesting( 55 static std::unique_ptr<NTPSnippet> CreateForTesting(
55 const std::string& id, 56 const std::string& id,
56 int remote_category_id, 57 int remote_category_id,
57 const GURL& url, 58 const GURL& url,
58 const std::string& publisher_name, 59 const std::string& publisher_name,
59 const GURL& amp_url); 60 const GURL& amp_url);
60 61
61 // Creates a protocol buffer corresponding to this snippet, for persisting. 62 // Creates a protocol buffer corresponding to this snippet, for persisting.
62 SnippetProto ToProto() const; 63 SnippetProto ToProto() const;
63 64
65 // Coverts to general content suggestion form
66 ContentSuggestion ToContentSuggestion(Category category) const;
67
64 // Returns all ids of the snippet. 68 // Returns all ids of the snippet.
65 const std::vector<std::string>& GetAllIDs() const { return ids_; } 69 const std::vector<std::string>& GetAllIDs() const { return ids_; }
66 70
67 // The unique, primary ID for identifying the snippet. 71 // The unique, primary ID for identifying the snippet.
68 const std::string& id() const { return ids_.front(); } 72 const std::string& id() const { return ids_.front(); }
69 73
70 // Title of the snippet. 74 // Title of the snippet.
71 const std::string& title() const { return title_; } 75 const std::string& title() const { return title_; }
72 76
73 // The main URL pointing to the content web page. 77 // The main URL pointing to the content web page.
(...skipping 24 matching lines...) Expand all
98 102
99 // 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
100 bool is_complete() const { 104 bool is_complete() const {
101 return !id().empty() && !title().empty() && !snippet().empty() && 105 return !id().empty() && !title().empty() && !snippet().empty() &&
102 salient_image_url().is_valid() && !publish_date().is_null() && 106 salient_image_url().is_valid() && !publish_date().is_null() &&
103 !expiry_date().is_null() && !publisher_name().empty(); 107 !expiry_date().is_null() && !publisher_name().empty();
104 } 108 }
105 109
106 float score() const { return score_; } 110 float score() const { return score_; }
107 111
112 bool should_notify() const { return should_notify_; }
113 base::Time notification_deadline() const { return notification_deadline_; }
114
108 bool is_dismissed() const { return is_dismissed_; } 115 bool is_dismissed() const { return is_dismissed_; }
109 void set_dismissed(bool dismissed) { is_dismissed_ = dismissed; } 116 void set_dismissed(bool dismissed) { is_dismissed_ = dismissed; }
110 117
111 // The ID of the remote category this snippet belongs to, for use with 118 // The ID of the remote category this snippet belongs to, for use with
112 // CategoryFactory::FromRemoteCategory. 119 // CategoryFactory::FromRemoteCategory.
113 int remote_category_id() const { return remote_category_id_; } 120 int remote_category_id() const { return remote_category_id_; }
114 121
115 // Public for testing. 122 // Public for testing.
116 static base::Time TimeFromJsonString(const std::string& timestamp_str); 123 static base::Time TimeFromJsonString(const std::string& timestamp_str);
117 static std::string TimeToJsonString(const base::Time& time); 124 static std::string TimeToJsonString(const base::Time& time);
(...skipping 15 matching lines...) Expand all
133 GURL amp_url_; 140 GURL amp_url_;
134 141
135 GURL salient_image_url_; 142 GURL salient_image_url_;
136 std::string snippet_; 143 std::string snippet_;
137 base::Time publish_date_; 144 base::Time publish_date_;
138 base::Time expiry_date_; 145 base::Time expiry_date_;
139 float score_; 146 float score_;
140 bool is_dismissed_; 147 bool is_dismissed_;
141 int remote_category_id_; 148 int remote_category_id_;
142 149
150 bool should_notify_;
151 base::Time notification_deadline_;
152
143 DISALLOW_COPY_AND_ASSIGN(NTPSnippet); 153 DISALLOW_COPY_AND_ASSIGN(NTPSnippet);
144 }; 154 };
145 155
146 } // namespace ntp_snippets 156 } // namespace ntp_snippets
147 157
148 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_NTP_SNIPPET_H_ 158 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_NTP_SNIPPET_H_
OLDNEW
« no previous file with comments | « components/ntp_snippets/content_suggestion.cc ('k') | components/ntp_snippets/remote/ntp_snippet.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698