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

Side by Side Diff: ui/message_center/notification.h

Issue 12277024: Notificaitons refactor step 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more feedback from Steven Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « ui/message_center/message_view.cc ('k') | ui/message_center/notification.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 UI_MESSAGE_CENTER_NOTIFICATION_H_ 5 #ifndef UI_MESSAGE_CENTER_NOTIFICATION_H_
6 #define UI_MESSAGE_CENTER_NOTIFICATION_H_ 6 #define UI_MESSAGE_CENTER_NOTIFICATION_H_
7 7
8 #include <string>
8 #include <vector> 9 #include <vector>
9 10
10 #include "base/string16.h" 11 #include "base/string16.h"
11 #include "base/time.h" 12 #include "base/time.h"
13 #include "base/values.h"
12 #include "ui/gfx/image/image_skia.h" 14 #include "ui/gfx/image/image_skia.h"
13 #include "ui/message_center/message_center_export.h" 15 #include "ui/message_center/message_center_export.h"
14 #include "ui/notifications/notification_types.h" 16 #include "ui/message_center/notification_types.h"
15 17
16 namespace message_center { 18 namespace message_center {
17 19
18 struct MESSAGE_CENTER_EXPORT NotificationItem { 20 struct MESSAGE_CENTER_EXPORT NotificationItem {
19 string16 title; 21 string16 title;
20 string16 message; 22 string16 message;
21 23
22 NotificationItem(string16 title, string16 message); 24 NotificationItem(const string16& title, const string16& message);
23 }; 25 };
24 26
25 struct MESSAGE_CENTER_EXPORT Notification { 27 struct MESSAGE_CENTER_EXPORT ButtonInfo {
26 Notification(); 28 string16 title;
29 gfx::ImageSkia icon;
30
31 ButtonInfo(const string16& title);
32 };
33
34 class MESSAGE_CENTER_EXPORT Notification {
35 public:
36 Notification(NotificationType type,
37 const std::string& id,
38 const string16& title,
39 const string16& message,
40 const string16& display_source,
41 const std::string& extension_id,
42 const DictionaryValue* optional_fields); // May be NULL.
27 virtual ~Notification(); 43 virtual ~Notification();
28 44
29 ui::notifications::NotificationType type; 45 NotificationType type() const { return type_; }
30 std::string id; 46 const std::string& id() const { return id_; }
31 string16 title; 47 const string16& title() const { return title_; }
32 string16 message; 48 const string16& message() const { return message_; }
33 string16 display_source; 49 const string16& display_source() const { return display_source_; }
34 std::string extension_id; 50 const std::string& extension_id() const { return extension_id_; }
35 51
36 // Begin unpacked values from optional_fields 52 // Begin unpacked values from optional_fields.
37 int priority; 53 int priority() { return priority_; }
38 base::Time timestamp; 54 base::Time timestamp() const { return timestamp_; }
39 std::vector<string16> button_titles; 55 const string16& expanded_message() const { return expanded_message_; }
40 string16 expanded_message; 56 const std::vector<NotificationItem>& items() const { return items_; }
41 std::vector<NotificationItem> items; 57 // End unpacked values.
42 // End unpacked values
43 58
44 // Images fetched asynchronously 59 // Images fetched asynchronously.
45 gfx::ImageSkia primary_icon; 60 const gfx::ImageSkia& primary_icon() const { return primary_icon_; }
46 gfx::ImageSkia image; 61 void set_primary_icon(const gfx::ImageSkia& icon) { primary_icon_ = icon; }
47 std::vector<gfx::ImageSkia> button_icons;
48 62
49 bool is_read; // True if this has been seen in the message center 63 const gfx::ImageSkia& image() const { return image_; }
50 bool shown_as_popup; // True if this has been shown as a popup notification 64 void set_image(const gfx::ImageSkia& image) { image_ = image; }
65
66 // Buttons, with icons fetched asynchronously.
67 const std::vector<ButtonInfo>& buttons() const { return buttons_; }
68 bool SetButtonIcon(size_t index, const gfx::ImageSkia& icon);
69
70 // Status in MessageCenter.
71 bool is_read() const { return is_read_; }
72 void set_is_read(bool is_read) { is_read_ = is_read; }
73
74 bool shown_as_popup() const { return shown_as_popup_; }
75 void set_shown_as_popup(bool shown_as_popup) {
76 shown_as_popup_ = shown_as_popup;
77 }
78
79 // Used to keep the order of notifications with the same timestamp.
80 // The notification with lesser serial_number is considered 'older'.
81 unsigned serial_number() { return serial_number_; }
82
83 private:
84 // Unpacks the provided |optional_fields| and applies the values to override
85 // the notification's data members.
86 void ApplyOptionalFields(const DictionaryValue* optional_fields);
87
88 NotificationType type_;
89 std::string id_;
90 string16 title_;
91 string16 message_;
92 string16 display_source_;
93 std::string extension_id_;
94 int priority_;
95 base::Time timestamp_;
96 unsigned serial_number_;
97 string16 expanded_message_;
98 std::vector<NotificationItem> items_;
99 gfx::ImageSkia primary_icon_;
100 gfx::ImageSkia image_;
101 std::vector<ButtonInfo> buttons_;
102 bool is_read_; // True if this has been seen in the message center.
103 bool shown_as_popup_; // True if this has been shown as a popup notification.
104
105 DISALLOW_COPY_AND_ASSIGN(Notification);
51 }; 106 };
52 107
53 } // namespace message_center 108 } // namespace message_center
54 109
55 #endif // UI_MESSAGE_CENTER_NOTIFICATION_H_ 110 #endif // UI_MESSAGE_CENTER_NOTIFICATION_H_
OLDNEW
« no previous file with comments | « ui/message_center/message_view.cc ('k') | ui/message_center/notification.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698