Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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_CONTENT_SUGGESTION_H_ | 5 #ifndef COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTION_H_ |
| 6 #define COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTION_H_ | 6 #define COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTION_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_category.h" | |
| 15 #include "components/ntp_snippets/content_suggestions_provider_type.h" | |
| 16 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 17 | 15 |
| 18 namespace ntp_snippets { | 16 namespace ntp_snippets { |
| 19 | 17 |
| 20 // A content suggestion for the new tab page, which can be an article or an | 18 // A content suggestion for the new tab page, which can be an article or an |
| 21 // offline page, for example. | 19 // offline page, for example. |
| 22 // NOTE: This class is not yet in use, please use NTPSnippet for now | 20 // NOTE: This class is not yet in use, please use NTPSnippet for now |
| 23 // (see ntp_snippet.h). | 21 // (see ntp_snippet.h). |
| 24 class ContentSuggestion { | 22 class ContentSuggestion { |
| 25 public: | 23 public: |
| 24 // This is the constructor that should be used by providers. | |
| 25 // The caller must ensure that the |id| passed in here is unique | |
| 26 // application-wide. Note: The provider should use its ::MakeUniqueID() | |
|
tschumann
2016/07/06 06:36:12
i'd drop the Note:.
That might be something to add
Philipp Keck
2016/07/06 08:34:23
Done.
| |
| 27 // function to create the ID. | |
| 26 ContentSuggestion(const std::string& id, | 28 ContentSuggestion(const std::string& id, |
| 27 const ContentSuggestionsProviderType provider, | |
| 28 const ContentSuggestionCategory category, | |
| 29 const GURL& url); | 29 const GURL& url); |
| 30 ContentSuggestion(ContentSuggestion&&); | |
| 31 ContentSuggestion& operator=(ContentSuggestion&&); | |
| 30 | 32 |
| 31 ~ContentSuggestion(); | 33 ~ContentSuggestion(); |
| 32 | 34 |
| 33 // An ID for identifying the suggestion. The ID is unique among all | 35 // An ID for identifying the suggestion. The ID is unique among all |
| 34 // suggestions from the same provider, so to determine a globally unique | 36 // suggestions of all providers. |
|
tschumann
2016/07/06 06:36:12
i wouldn't mention providers at all in this class.
Philipp Keck
2016/07/06 08:34:23
Done.
| |
| 35 // identifier, combine this ID with the provider type. | |
| 36 const std::string& id() const { return id_; } | 37 const std::string& id() const { return id_; } |
| 37 | 38 |
| 38 // The provider that created this suggestion. | |
| 39 ContentSuggestionsProviderType provider() const { return provider_; } | |
| 40 | |
| 41 // The category that this suggestion belongs to. | |
| 42 ContentSuggestionCategory category() const { return category_; } | |
| 43 | |
| 44 // The normal content URL where the content referenced by the suggestion can | 39 // The normal content URL where the content referenced by the suggestion can |
| 45 // be accessed. | 40 // be accessed. |
| 46 const GURL& url() const { return url_; } | 41 const GURL& url() const { return url_; } |
| 47 | 42 |
| 48 // If available, this contains an URL to an AMP version of the same content. | 43 // If available, this contains an URL to an AMP version of the same content. |
| 49 // Otherwise, this is an empty GURL(). | 44 // Otherwise, this is an empty GURL(). |
| 50 const GURL& amp_url() const { return amp_url_; } | 45 const GURL& amp_url() const { return amp_url_; } |
| 51 void set_amp_url(const GURL& amp_url) { amp_url_ = amp_url; } | 46 void set_amp_url(const GURL& amp_url) { amp_url_ = amp_url; } |
| 52 | 47 |
| 53 // Title of the suggestion. | 48 // Title of the suggestion. |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 75 // TODO(pke) Remove the score from the ContentSuggestion class. The UI only | 70 // TODO(pke) Remove the score from the ContentSuggestion class. The UI only |
| 76 // uses it to track user clicks (histogram data). Instead, the providers | 71 // uses it to track user clicks (histogram data). Instead, the providers |
| 77 // should be informed about clicks and do appropriate logging themselves. | 72 // should be informed about clicks and do appropriate logging themselves. |
| 78 // IMPORTANT: The score may simply be 0 for suggestions from providers which | 73 // IMPORTANT: The score may simply be 0 for suggestions from providers which |
| 79 // cannot provide score values. | 74 // cannot provide score values. |
| 80 float score() const { return score_; } | 75 float score() const { return score_; } |
| 81 void set_score(float score) { score_ = score; } | 76 void set_score(float score) { score_ = score; } |
| 82 | 77 |
| 83 private: | 78 private: |
| 84 std::string id_; | 79 std::string id_; |
| 85 ContentSuggestionsProviderType provider_; | |
| 86 ContentSuggestionCategory category_; | |
| 87 GURL url_; | 80 GURL url_; |
| 88 GURL amp_url_; | 81 GURL amp_url_; |
| 89 std::string title_; | 82 std::string title_; |
| 90 std::string snippet_text_; | 83 std::string snippet_text_; |
| 91 GURL salient_image_url_; | 84 GURL salient_image_url_; |
| 92 base::Time publish_date_; | 85 base::Time publish_date_; |
| 93 std::string publisher_name_; | 86 std::string publisher_name_; |
| 94 float score_; | 87 float score_; |
| 95 | 88 |
| 96 DISALLOW_COPY_AND_ASSIGN(ContentSuggestion); | 89 DISALLOW_COPY_AND_ASSIGN(ContentSuggestion); |
| 97 }; | 90 }; |
| 98 | 91 |
| 99 } // namespace ntp_snippets | 92 } // namespace ntp_snippets |
| 100 | 93 |
| 101 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTION_H_ | 94 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTION_H_ |
| OLD | NEW |