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

Side by Side Diff: chrome/browser/notifications/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, 10 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_NOTIFICATIONS_NOTIFICATION_H_ 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_
6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_ 6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/string16.h" 12 #include "base/string16.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/notifications/notification_delegate.h" 14 #include "chrome/browser/notifications/notification_delegate.h"
15 #include "googleurl/src/gurl.h" 15 #include "googleurl/src/gurl.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextDirection.h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextDirection.h"
17 #include "ui/gfx/image/image_skia.h" 17 #include "ui/gfx/image/image_skia.h"
18 #include "ui/notifications/notification_types.h" 18 #include "ui/message_center/notification_types.h"
19 19
20 // Representation of a notification to be shown to the user. 20 // Representation of a notification to be shown to the user.
21 // On non-Ash platforms these are rendered as HTML, sometimes described by a 21 // On non-Ash platforms these are rendered as HTML, sometimes described by a
22 // data url converted from text + icon data. On Ash they are rendered as 22 // data url converted from text + icon data. On Ash they are rendered as
23 // formated text and icon data. 23 // formated text and icon data.
24 class Notification { 24 class Notification {
25 public: 25 public:
26 // Initializes a notification with HTML content. 26 // Initializes a notification with HTML content.
27 Notification(const GURL& origin_url, 27 Notification(const GURL& origin_url,
28 const GURL& content_url, 28 const GURL& content_url,
29 const string16& display_source, 29 const string16& display_source,
30 const string16& replace_id, 30 const string16& replace_id,
31 NotificationDelegate* delegate); 31 NotificationDelegate* delegate);
32 32
33 // Initializes a notification with text content. On non-ash platforms, this 33 // Initializes a notification with text content. On non-ash platforms, this
34 // creates an HTML representation using a data: URL for display. 34 // creates an HTML representation using a data: URL for display.
35 Notification(const GURL& origin_url, 35 Notification(const GURL& origin_url,
36 const GURL& icon_url, 36 const GURL& icon_url,
37 const string16& title, 37 const string16& title,
38 const string16& body, 38 const string16& body,
39 WebKit::WebTextDirection dir, 39 WebKit::WebTextDirection dir,
40 const string16& display_source, 40 const string16& display_source,
41 const string16& replace_id, 41 const string16& replace_id,
42 NotificationDelegate* delegate); 42 NotificationDelegate* delegate);
43 43
44 // Initializes a notification with a given type. Takes ownership of 44 // Initializes a notification with a given type. Takes ownership of
45 // optional_fields. 45 // optional_fields.
46 Notification(ui::notifications::NotificationType type, 46 Notification(message_center::NotificationType type,
47 const GURL& origin_url, 47 const GURL& origin_url,
48 const GURL& icon_url, 48 const GURL& icon_url,
49 const string16& title, 49 const string16& title,
50 const string16& body, 50 const string16& body,
51 WebKit::WebTextDirection dir, 51 WebKit::WebTextDirection dir,
52 const string16& display_source, 52 const string16& display_source,
53 const string16& replace_id, 53 const string16& replace_id,
54 const DictionaryValue* optional_fields, 54 const DictionaryValue* optional_fields,
55 NotificationDelegate* delegate); 55 NotificationDelegate* delegate);
56 56
57 // Initializes a notification with text content and an icon image. Currently 57 // Initializes a notification with text content and an icon image. Currently
58 // only used on Ash. Does not generate content_url_. 58 // only used on Ash. Does not generate content_url_.
59 Notification(const GURL& origin_url, 59 Notification(const GURL& origin_url,
60 const gfx::ImageSkia& icon, 60 const gfx::ImageSkia& icon,
61 const string16& title, 61 const string16& title,
62 const string16& body, 62 const string16& body,
63 WebKit::WebTextDirection dir, 63 WebKit::WebTextDirection dir,
64 const string16& display_source, 64 const string16& display_source,
65 const string16& replace_id, 65 const string16& replace_id,
66 NotificationDelegate* delegate); 66 NotificationDelegate* delegate);
67 67
68 Notification(const Notification& notification); 68 Notification(const Notification& notification);
69 ~Notification(); 69 ~Notification();
70 Notification& operator=(const Notification& notification); 70 Notification& operator=(const Notification& notification);
71 71
72 // If this is a HTML notification. 72 // If this is a HTML notification.
73 bool is_html() const { return is_html_; } 73 bool is_html() const { return is_html_; }
74 74
75 ui::notifications::NotificationType type() const { 75 message_center::NotificationType type() const {
76 return type_; 76 return type_;
77 } 77 }
78 78
79 // The URL (may be data:) containing the contents for the notification. 79 // The URL (may be data:) containing the contents for the notification.
80 const GURL& content_url() const { return content_url_; } 80 const GURL& content_url() const { return content_url_; }
81 81
82 // Title and message text of the notification. 82 // Title and message text of the notification.
83 const string16& title() const { return title_; } 83 const string16& title() const { return title_; }
84 const string16& body() const { return body_; } 84 const string16& body() const { return body_; }
85 85
(...skipping 25 matching lines...) Expand all
111 std::string notification_id() const { return delegate()->id(); } 111 std::string notification_id() const { return delegate()->id(); }
112 112
113 content::RenderViewHost* GetRenderViewHost() const { 113 content::RenderViewHost* GetRenderViewHost() const {
114 return delegate()->GetRenderViewHost(); 114 return delegate()->GetRenderViewHost();
115 } 115 }
116 116
117 private: 117 private:
118 NotificationDelegate* delegate() const { return delegate_.get(); } 118 NotificationDelegate* delegate() const { return delegate_.get(); }
119 119
120 // The type of notification we'd like displayed. 120 // The type of notification we'd like displayed.
121 ui::notifications::NotificationType type_; 121 message_center::NotificationType type_;
122 122
123 // The Origin of the page/worker which created this notification. 123 // The Origin of the page/worker which created this notification.
124 GURL origin_url_; 124 GURL origin_url_;
125 125
126 // Image data for the associated icon, used by Ash when available. 126 // Image data for the associated icon, used by Ash when available.
127 gfx::ImageSkia icon_; 127 gfx::ImageSkia icon_;
128 128
129 // URL for the icon associated with the notification. Requires delegate_ 129 // URL for the icon associated with the notification. Requires delegate_
130 // to have a non NULL RenderViewHost. 130 // to have a non NULL RenderViewHost.
131 GURL icon_url_; 131 GURL icon_url_;
(...skipping 18 matching lines...) Expand all
150 string16 replace_id_; 150 string16 replace_id_;
151 151
152 scoped_ptr<DictionaryValue> optional_fields_; 152 scoped_ptr<DictionaryValue> optional_fields_;
153 153
154 // A proxy object that allows access back to the JavaScript object that 154 // A proxy object that allows access back to the JavaScript object that
155 // represents the notification, for firing events. 155 // represents the notification, for firing events.
156 scoped_refptr<NotificationDelegate> delegate_; 156 scoped_refptr<NotificationDelegate> delegate_;
157 }; 157 };
158 158
159 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_ 159 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_
OLDNEW
« no previous file with comments | « chrome/browser/notifications/message_center_notification_manager.cc ('k') | chrome/browser/notifications/notification.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698