Chromium Code Reviews| OLD | NEW |
|---|---|
| 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.h" | 17 #include "ui/gfx/image/image.h" |
| 18 #include "ui/message_center/notification.h" | |
| 18 #include "ui/message_center/notification_types.h" | 19 #include "ui/message_center/notification_types.h" |
| 19 | 20 |
| 20 // Representation of a notification to be shown to the user. | 21 // Representation of a notification to be shown to the user. |
| 21 // On non-Ash platforms these are rendered as HTML, sometimes described by a | 22 // 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 | 23 // data url converted from text + icon data. On Ash they are rendered as |
| 23 // formated text and icon data. | 24 // formated text and icon data. |
| 24 class Notification { | 25 class Notification { |
|
Jun Mukai
2013/05/31 17:08:10
Can we make this class a subclass of message_cente
dewittj
2013/05/31 22:13:56
Not easily, since the prevailing style is to pass
| |
| 25 public: | 26 public: |
| 26 // Initializes a notification with HTML content. | 27 // Initializes a notification with HTML content. |
| 27 Notification(const GURL& origin_url, | 28 Notification(const GURL& origin_url, |
| 28 const GURL& content_url, | 29 const GURL& content_url, |
| 29 const string16& display_source, | 30 const string16& display_source, |
| 30 const string16& replace_id, | 31 const string16& replace_id, |
| 31 NotificationDelegate* delegate); | 32 NotificationDelegate* delegate); |
| 32 | 33 |
| 33 // Initializes a notification with text content. On non-ash platforms, this | 34 // Initializes a notification with text content. On non-ash platforms, this |
| 34 // creates an HTML representation using a data: URL for display. | 35 // creates an HTML representation using a data: URL for display. |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 58 // only used on Ash. Does not generate content_url_. | 59 // only used on Ash. Does not generate content_url_. |
| 59 Notification(const GURL& origin_url, | 60 Notification(const GURL& origin_url, |
| 60 const gfx::Image& icon, | 61 const gfx::Image& icon, |
| 61 const string16& title, | 62 const string16& title, |
| 62 const string16& body, | 63 const string16& body, |
| 63 WebKit::WebTextDirection dir, | 64 WebKit::WebTextDirection dir, |
| 64 const string16& display_source, | 65 const string16& display_source, |
| 65 const string16& replace_id, | 66 const string16& replace_id, |
| 66 NotificationDelegate* delegate); | 67 NotificationDelegate* delegate); |
| 67 | 68 |
| 69 Notification( | |
| 70 message_center::NotificationType type, | |
| 71 const GURL& origin_url, | |
| 72 const string16& title, | |
| 73 const string16& body, | |
| 74 WebKit::WebTextDirection dir, | |
| 75 const string16& display_source, | |
| 76 const string16& replace_id, | |
| 77 const message_center::RichNotificationData& rich_notification_data, | |
| 78 NotificationDelegate* delegate); | |
| 79 | |
| 68 Notification(const Notification& notification); | 80 Notification(const Notification& notification); |
| 69 ~Notification(); | 81 ~Notification(); |
| 70 Notification& operator=(const Notification& notification); | 82 Notification& operator=(const Notification& notification); |
| 71 | 83 |
| 72 // If this is a HTML notification. | 84 // If this is a HTML notification. |
| 73 bool is_html() const { return is_html_; } | 85 bool is_html() const { return is_html_; } |
| 74 | 86 |
| 75 message_center::NotificationType type() const { | 87 message_center::NotificationType type() const { |
| 76 return type_; | 88 return type_; |
| 77 } | 89 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 void DoneRendering() { delegate()->ReleaseRenderViewHost(); } | 127 void DoneRendering() { delegate()->ReleaseRenderViewHost(); } |
| 116 | 128 |
| 117 std::string notification_id() const { return delegate()->id(); } | 129 std::string notification_id() const { return delegate()->id(); } |
| 118 | 130 |
| 119 int process_id() const { return delegate()->process_id(); } | 131 int process_id() const { return delegate()->process_id(); } |
| 120 | 132 |
| 121 content::RenderViewHost* GetRenderViewHost() const { | 133 content::RenderViewHost* GetRenderViewHost() const { |
| 122 return delegate()->GetRenderViewHost(); | 134 return delegate()->GetRenderViewHost(); |
| 123 } | 135 } |
| 124 | 136 |
| 137 bool has_rich_notification() const { return has_rich_notification_; } | |
| 138 const message_center::RichNotificationData& rich_notification_data() const { | |
| 139 return rich_notification_data_; | |
| 140 } | |
| 141 | |
| 125 NotificationDelegate* delegate() const { return delegate_.get(); } | 142 NotificationDelegate* delegate() const { return delegate_.get(); } |
| 126 | 143 |
| 127 private: | 144 private: |
| 128 // The type of notification we'd like displayed. | 145 // The type of notification we'd like displayed. |
| 129 message_center::NotificationType type_; | 146 message_center::NotificationType type_; |
| 130 | 147 |
| 131 // The Origin of the page/worker which created this notification. | 148 // The Origin of the page/worker which created this notification. |
| 132 GURL origin_url_; | 149 GURL origin_url_; |
| 133 | 150 |
| 134 // Image data for the associated icon, used by Ash when available. | 151 // Image data for the associated icon, used by Ash when available. |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 152 | 169 |
| 153 // The display string for the source of the notification. Could be | 170 // The display string for the source of the notification. Could be |
| 154 // the same as origin_url_, or the name of an extension. | 171 // the same as origin_url_, or the name of an extension. |
| 155 string16 display_source_; | 172 string16 display_source_; |
| 156 | 173 |
| 157 // The replace ID for the notification. | 174 // The replace ID for the notification. |
| 158 string16 replace_id_; | 175 string16 replace_id_; |
| 159 | 176 |
| 160 scoped_ptr<DictionaryValue> optional_fields_; | 177 scoped_ptr<DictionaryValue> optional_fields_; |
| 161 | 178 |
| 179 bool has_rich_notification_; | |
| 180 message_center::RichNotificationData rich_notification_data_; | |
| 181 | |
| 162 // A proxy object that allows access back to the JavaScript object that | 182 // A proxy object that allows access back to the JavaScript object that |
| 163 // represents the notification, for firing events. | 183 // represents the notification, for firing events. |
| 164 scoped_refptr<NotificationDelegate> delegate_; | 184 scoped_refptr<NotificationDelegate> delegate_; |
| 165 }; | 185 }; |
| 166 | 186 |
| 167 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_ | 187 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_ |
| OLD | NEW |