OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_EXTENSIONS_APP_NOTIFICATION_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_APP_NOTIFICATION_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_APP_NOTIFICATION_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_APP_NOTIFICATION_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/memory/linked_ptr.h" | 12 #include "base/memory/linked_ptr.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
15 | 15 |
16 // This class is used to represent a notification for an installed app, to be | 16 // This class is used to represent a notification for an installed app, to be |
17 // displayed on the New Tab Page. | 17 // displayed on the New Tab Page. |
18 class AppNotification { | 18 class AppNotification { |
19 public: | 19 public: |
20 // Creates an instance with the given properties. | 20 // Creates an instance with the given properties. |
21 // If |is_local| is true, notification is not synced. | 21 // If |is_local| is true, notification is not synced. |
22 // If |guid| is empty, a new guid is automatically created. | 22 // If |guid| is empty, a new guid is automatically created. |
23 AppNotification(bool is_local, | 23 AppNotification(bool is_local, |
24 double creation_timestamp_ms, | |
Munjal (Google)
2011/11/17 19:45:32
Is double the right data type for ms since epoch?
Munjal (Google)
2011/11/17 19:45:32
Nit: may be just name it creation_time_ms
asargent_no_longer_on_chrome
2011/11/17 22:36:24
Actually it would probably be better to use our Ti
elvin
2011/11/17 22:52:58
Done.
| |
24 const std::string& guid, | 25 const std::string& guid, |
25 const std::string& extension_id, | 26 const std::string& extension_id, |
26 const std::string& title, | 27 const std::string& title, |
27 const std::string& body); | 28 const std::string& body); |
28 ~AppNotification(); | 29 ~AppNotification(); |
29 | 30 |
30 // Returns a new object that is a copy of this one. | 31 // Returns a new object that is a copy of this one. |
31 // Caller owns the returned instance. | 32 // Caller owns the returned instance. |
32 AppNotification* Copy(); | 33 AppNotification* Copy(); |
33 | 34 |
34 // Setters for optional properties. | 35 // Setters for optional properties. |
35 void set_link_url(const GURL& url) { link_url_ = url; } | 36 void set_link_url(const GURL& url) { link_url_ = url; } |
36 void set_link_text(const std::string& text) { link_text_ = text; } | 37 void set_link_text(const std::string& text) { link_text_ = text; } |
37 | 38 |
38 // Accessors. | 39 // Accessors. |
39 bool is_local() const { return is_local_; } | 40 bool is_local() const { return is_local_; } |
41 double creation_timestamp_ms() const { return creation_timestamp_ms_; } | |
Munjal (Google)
2011/11/17 19:45:32
Nit: name creation_time_ms()
| |
40 const std::string& guid() const { return guid_; } | 42 const std::string& guid() const { return guid_; } |
41 const std::string& extension_id() const { return extension_id_; } | 43 const std::string& extension_id() const { return extension_id_; } |
42 const std::string& title() const { return title_; } | 44 const std::string& title() const { return title_; } |
43 const std::string& body() const { return body_; } | 45 const std::string& body() const { return body_; } |
44 const GURL& link_url() const { return link_url_; } | 46 const GURL& link_url() const { return link_url_; } |
45 const std::string& link_text() const { return link_text_; } | 47 const std::string& link_text() const { return link_text_; } |
46 | 48 |
47 // Useful methods for serialization. | 49 // Useful methods for serialization. |
48 void ToDictionaryValue(DictionaryValue* result); | 50 void ToDictionaryValue(DictionaryValue* result); |
49 static AppNotification* FromDictionaryValue(const DictionaryValue& value); | 51 static AppNotification* FromDictionaryValue(const DictionaryValue& value); |
50 | 52 |
51 // Return whether |other| is equal to this object. Useful for tests. | 53 // Return whether |other| is equal to this object. Useful for tests. |
52 bool Equals(const AppNotification& other) const; | 54 bool Equals(const AppNotification& other) const; |
53 | 55 |
54 private: | 56 private: |
55 // If you add to the list of data members, make sure to add appropriate checks | 57 // If you add to the list of data members, make sure to add appropriate checks |
56 // to the Equals, Copy and {To,From}DictionaryValue methods, keeping in mind | 58 // to the Equals, Copy and {To,From}DictionaryValue methods, keeping in mind |
57 // backwards compatibility. | 59 // backwards compatibility. |
58 | 60 |
59 // Whether notification is local only, which means it is not synced | 61 // Whether notification is local only, which means it is not synced |
60 // across machines. | 62 // across machines. |
61 bool is_local_; | 63 bool is_local_; |
64 double creation_timestamp_ms_; | |
Munjal (Google)
2011/11/17 19:45:32
Nit: same name nit here.
elvin
2011/11/17 22:52:58
Done.
| |
62 std::string guid_; | 65 std::string guid_; |
63 std::string extension_id_; | 66 std::string extension_id_; |
64 std::string title_; | 67 std::string title_; |
65 std::string body_; | 68 std::string body_; |
66 GURL link_url_; | 69 GURL link_url_; |
67 std::string link_text_; | 70 std::string link_text_; |
68 | 71 |
69 DISALLOW_COPY_AND_ASSIGN(AppNotification); | 72 DISALLOW_COPY_AND_ASSIGN(AppNotification); |
70 }; | 73 }; |
71 | 74 |
72 // A list of AppNotification's. | 75 // A list of AppNotification's. |
73 typedef std::vector<linked_ptr<AppNotification> > AppNotificationList; | 76 typedef std::vector<linked_ptr<AppNotification> > AppNotificationList; |
74 | 77 |
75 // A way to copy an AppNotificationList, which uses AppNotification::Copy on | 78 // A way to copy an AppNotificationList, which uses AppNotification::Copy on |
76 // each element. | 79 // each element. |
77 // Caller owns the returned instance. | 80 // Caller owns the returned instance. |
78 AppNotificationList* CopyAppNotificationList(const AppNotificationList& source); | 81 AppNotificationList* CopyAppNotificationList(const AppNotificationList& source); |
79 | 82 |
80 #endif // CHROME_BROWSER_EXTENSIONS_APP_NOTIFICATION_H_ | 83 #endif // CHROME_BROWSER_EXTENSIONS_APP_NOTIFICATION_H_ |
OLD | NEW |