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

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

Issue 2197223002: Use base::string16 for user-visible texts in ContentSuggestion (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 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/strings/string16.h"
13 #include "base/time/time.h" 14 #include "base/time/time.h"
14 #include "url/gurl.h" 15 #include "url/gurl.h"
15 16
16 namespace ntp_snippets { 17 namespace ntp_snippets {
17 18
18 // A content suggestion for the new tab page, which can be an article or an 19 // A content suggestion for the new tab page, which can be an article or an
19 // offline page, for example. 20 // offline page, for example.
20 class ContentSuggestion { 21 class ContentSuggestion {
21 public: 22 public:
22 // Creates a new ContentSuggestion. The caller must ensure that the |id| 23 // Creates a new ContentSuggestion. The caller must ensure that the |id|
(...skipping 11 matching lines...) Expand all
34 // The normal content URL where the content referenced by the suggestion can 35 // The normal content URL where the content referenced by the suggestion can
35 // be accessed. 36 // be accessed.
36 const GURL& url() const { return url_; } 37 const GURL& url() const { return url_; }
37 38
38 // If available, this contains an URL to an AMP version of the same content. 39 // If available, this contains an URL to an AMP version of the same content.
39 // Otherwise, this is an empty GURL(). 40 // Otherwise, this is an empty GURL().
40 const GURL& amp_url() const { return amp_url_; } 41 const GURL& amp_url() const { return amp_url_; }
41 void set_amp_url(const GURL& amp_url) { amp_url_ = amp_url; } 42 void set_amp_url(const GURL& amp_url) { amp_url_ = amp_url; }
42 43
43 // Title of the suggestion. 44 // Title of the suggestion.
44 const std::string& title() const { return title_; } 45 const base::string16& title() const { return title_; }
45 void set_title(const std::string& title) { title_ = title; } 46 void set_title(const base::string16& title) { title_ = title; }
46 47
47 // Summary or relevant textual extract from the content. 48 // Summary or relevant textual extract from the content.
48 const std::string& snippet_text() const { return snippet_text_; } 49 const base::string16& snippet_text() const { return snippet_text_; }
49 void set_snippet_text(const std::string& snippet_text) { 50 void set_snippet_text(const base::string16& snippet_text) {
50 snippet_text_ = snippet_text; 51 snippet_text_ = snippet_text;
51 } 52 }
52 53
53 // The time when the content represented by this suggestion was published. 54 // The time when the content represented by this suggestion was published.
54 const base::Time& publish_date() const { return publish_date_; } 55 const base::Time& publish_date() const { return publish_date_; }
55 void set_publish_date(const base::Time& publish_date) { 56 void set_publish_date(const base::Time& publish_date) {
56 publish_date_ = publish_date; 57 publish_date_ = publish_date;
57 } 58 }
58 59
59 // The name of the source/publisher of this suggestion. 60 // The name of the source/publisher of this suggestion.
60 const std::string& publisher_name() const { return publisher_name_; } 61 const base::string16& publisher_name() const { return publisher_name_; }
61 void set_publisher_name(const std::string& publisher_name) { 62 void set_publisher_name(const base::string16& publisher_name) {
62 publisher_name_ = publisher_name; 63 publisher_name_ = publisher_name;
63 } 64 }
64 65
65 // TODO(pke): Remove the score from the ContentSuggestion class. The UI only 66 // TODO(pke): Remove the score from the ContentSuggestion class. The UI only
66 // uses it to track user clicks (histogram data). Instead, the providers 67 // uses it to track user clicks (histogram data). Instead, the providers
67 // should be informed about clicks and do appropriate logging themselves. 68 // should be informed about clicks and do appropriate logging themselves.
68 // IMPORTANT: The score may simply be 0 for suggestions from providers which 69 // IMPORTANT: The score may simply be 0 for suggestions from providers which
69 // cannot provide score values. 70 // cannot provide score values.
70 float score() const { return score_; } 71 float score() const { return score_; }
71 void set_score(float score) { score_ = score; } 72 void set_score(float score) { score_ = score; }
72 73
73 private: 74 private:
74 std::string id_; 75 std::string id_;
75 GURL url_; 76 GURL url_;
76 GURL amp_url_; 77 GURL amp_url_;
77 std::string title_; 78 base::string16 title_;
78 std::string snippet_text_; 79 base::string16 snippet_text_;
79 GURL salient_image_url_; 80 GURL salient_image_url_;
80 base::Time publish_date_; 81 base::Time publish_date_;
81 std::string publisher_name_; 82 base::string16 publisher_name_;
82 float score_; 83 float score_;
83 84
84 DISALLOW_COPY_AND_ASSIGN(ContentSuggestion); 85 DISALLOW_COPY_AND_ASSIGN(ContentSuggestion);
85 }; 86 };
86 87
87 } // namespace ntp_snippets 88 } // namespace ntp_snippets
88 89
89 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTION_H_ 90 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTION_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/ntp/ntp_snippets_bridge.cc ('k') | components/ntp_snippets/ntp_snippets_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698