| OLD | NEW |
| 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 #ifndef COMPONENTS_NTP_SNIPPETS_NTP_SNIPPET_H_ | 4 #ifndef COMPONENTS_NTP_SNIPPETS_NTP_SNIPPET_H_ |
| 5 #define COMPONENTS_NTP_SNIPPETS_NTP_SNIPPET_H_ | 5 #define COMPONENTS_NTP_SNIPPETS_NTP_SNIPPET_H_ |
| 6 | 6 |
| 7 #include <memory> | |
| 8 #include <string> | 7 #include <string> |
| 9 | 8 |
| 10 #include "base/macros.h" | 9 #include "base/macros.h" |
| 11 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 12 #include "url/gurl.h" | 11 #include "url/gurl.h" |
| 13 | 12 |
| 14 namespace base { | 13 namespace base { |
| 15 class DictionaryValue; | 14 class DictionaryValue; |
| 16 } | 15 } |
| 17 | 16 |
| 18 namespace ntp_snippets { | 17 namespace ntp_snippets { |
| 19 | 18 |
| 20 // Stores and vend fresh content data for the NTP. This is a dumb class with no | 19 // Stores and vend fresh content data for the NTP. This is a dumb class with no |
| 21 // smarts at all, all the logic is in the service. | 20 // smarts at all, all the logic is in the service. |
| 22 class NTPSnippet { | 21 class NTPSnippet { |
| 23 public: | 22 public: |
| 24 // Creates a new snippet with the given URL. URL must be valid. | 23 // Creates a new snippet with the given URL. URL must be valid. |
| 25 NTPSnippet(const GURL& url); | 24 NTPSnippet(const GURL& url); |
| 26 | 25 |
| 27 ~NTPSnippet(); | 26 ~NTPSnippet(); |
| 28 | 27 |
| 29 // Creates an NTPSnippet from a dictionary. Returns a null pointer if the | 28 // Creates an NTPSnippet from a dictionary. Returns a null pointer if the |
| 30 // dictionary doesn't contain at least a url. The keys in the dictionary are | 29 // dictionary doesn't contain at least a url. The keys in the dictionary are |
| 31 // expected to be the same as the property name, with exceptions documented in | 30 // expected to be the same as the property name, with exceptions documented in |
| 32 // the property comment. | 31 // the property comment. |
| 33 static std::unique_ptr<NTPSnippet> NTPSnippetFromDictionary( | 32 static scoped_ptr<NTPSnippet> NTPSnippetFromDictionary( |
| 34 const base::DictionaryValue& dict); | 33 const base::DictionaryValue& dict); |
| 35 | 34 |
| 36 // URL of the page described by this snippet. | 35 // URL of the page described by this snippet. |
| 37 const GURL& url() const { return url_; } | 36 const GURL& url() const { return url_; } |
| 38 | 37 |
| 39 // Subtitle to identify the site the snippet is from. | 38 // Subtitle to identify the site the snippet is from. |
| 40 const std::string& site_title() const { return site_title_; } | 39 const std::string& site_title() const { return site_title_; } |
| 41 void set_site_title(const std::string& site_title) { | 40 void set_site_title(const std::string& site_title) { |
| 42 site_title_ = site_title; | 41 site_title_ = site_title; |
| 43 } | 42 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 std::string snippet_; | 84 std::string snippet_; |
| 86 base::Time publish_date_; | 85 base::Time publish_date_; |
| 87 base::Time expiry_date_; | 86 base::Time expiry_date_; |
| 88 | 87 |
| 89 DISALLOW_COPY_AND_ASSIGN(NTPSnippet); | 88 DISALLOW_COPY_AND_ASSIGN(NTPSnippet); |
| 90 }; | 89 }; |
| 91 | 90 |
| 92 } // namespace ntp_snippets | 91 } // namespace ntp_snippets |
| 93 | 92 |
| 94 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPET_H_ | 93 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPET_H_ |
| OLD | NEW |