Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTION_H_ | |
| 6 #define COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTION_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <string> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/macros.h" | |
| 13 #include "base/time/time.h" | |
| 14 #include "components/ntp_snippets/content_suggestion_category.h" | |
| 15 #include "components/ntp_snippets/content_suggestion_provider_type.h" | |
| 16 #include "url/gurl.h" | |
| 17 | |
| 18 namespace ntp_snippets { | |
| 19 | |
| 20 // A content suggestion for the new tab page, which can be an article or an | |
| 21 // offline page, for example. | |
| 22 // NOTE: This class is not yet in use, please use NTPSnippet for now | |
| 23 // (see ntp_snippet.h). | |
| 24 class ContentSuggestion { | |
| 25 public: | |
| 26 using PtrVector = std::vector<std::unique_ptr<ContentSuggestion>>; | |
|
Marc Treib
2016/06/27 11:35:30
Hm, we could consider passing around vectors of in
Philipp Keck
2016/06/27 12:05:04
Done.
| |
| 27 | |
| 28 ContentSuggestion(const std::string& id, | |
| 29 const ContentSuggestionProviderType provider, | |
| 30 const ContentSuggestionCategory category, | |
| 31 const GURL& url); | |
| 32 | |
| 33 ~ContentSuggestion(); | |
| 34 | |
| 35 // An ID for identifying the suggestion. The ID is unique among all | |
| 36 // suggestions from the same provider, so to determine a globally unique | |
| 37 // identifier, combine this ID with the provider type. | |
| 38 const std::string& id() const { return id_; } | |
| 39 | |
| 40 // The provider that created this suggestion. | |
| 41 ContentSuggestionProviderType provider() const { return provider_; } | |
| 42 | |
| 43 // The category that this suggestion belongs to. | |
| 44 ContentSuggestionCategory category() const { return category_; } | |
| 45 | |
| 46 // The normal content URL where the content referenced by the suggestion can | |
| 47 // be accessed. | |
| 48 const GURL& url() const { return url_; } | |
| 49 | |
| 50 // If available, this contains an URL to an AMP version of the same content. | |
| 51 // Otherwise, this is an empty GURL(). | |
| 52 const GURL& amp_url() const { return amp_url_; } | |
| 53 void set_amp_url(const GURL& amp_url) { amp_url_ = amp_url; } | |
| 54 | |
| 55 // Title of the suggestion. | |
| 56 const std::string& title() const { return title_; } | |
| 57 void set_title(const std::string& title) { title_ = title; } | |
| 58 | |
| 59 // Summary or relevant textual extract from the content. | |
| 60 const std::string& snippet_text() const { return snippet_text_; } | |
| 61 void set_snippet_text(const std::string& snippet_text) { | |
| 62 snippet_text_ = snippet_text; | |
| 63 } | |
| 64 | |
| 65 // The time when the content represented by this suggestion was published. | |
| 66 const base::Time& publish_date() const { return publish_date_; } | |
| 67 void set_publish_date(const base::Time& publish_date) { | |
| 68 publish_date_ = publish_date; | |
| 69 } | |
| 70 | |
| 71 // The name of the source/publisher of this suggestion. | |
| 72 const std::string& publisher_name() const { return publisher_name_; } | |
| 73 void set_publisher_name(const std::string& publisher_name) { | |
| 74 publisher_name_ = publisher_name; | |
| 75 } | |
| 76 | |
| 77 // TODO(pke) Remove the score from the ContentSuggestion class. The UI only | |
| 78 // uses it to track user clicks (histogram data). Instead, the providers | |
| 79 // should be informed about clicks and do appropriate logging themselves. | |
| 80 // IMPORTANT: The score may simply be 0 for suggestions from providers which | |
| 81 // cannot provide score values. | |
| 82 float score() const { return score_; } | |
| 83 void set_score(float score) { score_ = score; } | |
| 84 | |
| 85 private: | |
| 86 std::string id_; | |
| 87 ContentSuggestionProviderType provider_; | |
| 88 ContentSuggestionCategory category_; | |
| 89 GURL url_; | |
| 90 GURL amp_url_; | |
| 91 std::string title_; | |
| 92 std::string snippet_text_; | |
| 93 GURL salient_image_url_; | |
| 94 base::Time publish_date_; | |
| 95 std::string publisher_name_; | |
| 96 float score_; | |
| 97 | |
| 98 DISALLOW_COPY_AND_ASSIGN(ContentSuggestion); | |
| 99 }; | |
| 100 | |
| 101 } // namespace ntp_snippets | |
| 102 | |
| 103 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTION_H_ | |
| OLD | NEW |