| 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 #include "chrome/browser/notifications/notification.h" | 5 #include "chrome/browser/notifications/notification.h" |
| 6 | 6 |
| 7 #include "chrome/browser/notifications/desktop_notification_service.h" | 7 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 8 | 8 |
| 9 Notification::Notification(const GURL& origin_url, | 9 Notification::Notification(const GURL& origin_url, |
| 10 const GURL& content_url, | 10 const GURL& content_url, |
| 11 const string16& display_source, | 11 const string16& display_source, |
| 12 const string16& replace_id, | 12 const string16& replace_id, |
| 13 NotificationDelegate* delegate) | 13 NotificationDelegate* delegate) |
| 14 : type_(message_center::NOTIFICATION_TYPE_SIMPLE), | 14 : type_(message_center::NOTIFICATION_TYPE_SIMPLE), |
| 15 origin_url_(origin_url), | 15 origin_url_(origin_url), |
| 16 is_html_(true), | 16 is_html_(true), |
| 17 content_url_(content_url), | 17 content_url_(content_url), |
| 18 display_source_(display_source), | 18 display_source_(display_source), |
| 19 replace_id_(replace_id), | 19 replace_id_(replace_id), |
| 20 has_rich_notification_(false), |
| 20 delegate_(delegate) {} | 21 delegate_(delegate) {} |
| 21 | 22 |
| 22 Notification::Notification(const GURL& origin_url, | 23 Notification::Notification(const GURL& origin_url, |
| 23 const GURL& icon_url, | 24 const GURL& icon_url, |
| 24 const string16& title, | 25 const string16& title, |
| 25 const string16& body, | 26 const string16& body, |
| 26 WebKit::WebTextDirection dir, | 27 WebKit::WebTextDirection dir, |
| 27 const string16& display_source, | 28 const string16& display_source, |
| 28 const string16& replace_id, | 29 const string16& replace_id, |
| 29 NotificationDelegate* delegate) | 30 NotificationDelegate* delegate) |
| 30 : type_(message_center::NOTIFICATION_TYPE_SIMPLE), | 31 : type_(message_center::NOTIFICATION_TYPE_SIMPLE), |
| 31 origin_url_(origin_url), | 32 origin_url_(origin_url), |
| 32 icon_url_(icon_url), | 33 icon_url_(icon_url), |
| 33 is_html_(false), | 34 is_html_(false), |
| 34 title_(title), | 35 title_(title), |
| 35 body_(body), | 36 body_(body), |
| 36 display_source_(display_source), | 37 display_source_(display_source), |
| 37 replace_id_(replace_id), | 38 replace_id_(replace_id), |
| 39 has_rich_notification_(false), |
| 38 delegate_(delegate) { | 40 delegate_(delegate) { |
| 39 // "Upconvert" the string parameters to a data: URL. | 41 // "Upconvert" the string parameters to a data: URL. |
| 40 content_url_ = GURL(DesktopNotificationService::CreateDataUrl( | 42 content_url_ = GURL(DesktopNotificationService::CreateDataUrl( |
| 41 icon_url, title, body, dir)); | 43 icon_url, title, body, dir)); |
| 42 } | 44 } |
| 43 | 45 |
| 44 Notification::Notification(message_center::NotificationType type, | 46 Notification::Notification(message_center::NotificationType type, |
| 45 const GURL& origin_url, | 47 const GURL& origin_url, |
| 46 const GURL& icon_url, | 48 const GURL& icon_url, |
| 47 const string16& title, | 49 const string16& title, |
| 48 const string16& body, | 50 const string16& body, |
| 49 WebKit::WebTextDirection dir, | 51 WebKit::WebTextDirection dir, |
| 50 const string16& display_source, | 52 const string16& display_source, |
| 51 const string16& replace_id, | 53 const string16& replace_id, |
| 52 const DictionaryValue* optional_fields, | 54 const DictionaryValue* optional_fields, |
| 53 NotificationDelegate* delegate) | 55 NotificationDelegate* delegate) |
| 54 : type_(type), | 56 : type_(type), |
| 55 origin_url_(origin_url), | 57 origin_url_(origin_url), |
| 56 icon_url_(icon_url), | 58 icon_url_(icon_url), |
| 57 is_html_(false), | 59 is_html_(false), |
| 58 title_(title), | 60 title_(title), |
| 59 body_(body), | 61 body_(body), |
| 60 display_source_(display_source), | 62 display_source_(display_source), |
| 61 replace_id_(replace_id), | 63 replace_id_(replace_id), |
| 62 optional_fields_(NULL), | 64 optional_fields_(NULL), |
| 65 has_rich_notification_(false), |
| 63 delegate_(delegate) { | 66 delegate_(delegate) { |
| 64 if (optional_fields) | 67 if (optional_fields) |
| 65 optional_fields_.reset(optional_fields->DeepCopy()); | 68 optional_fields_.reset(optional_fields->DeepCopy()); |
| 66 // "Upconvert" the string parameters to a data: URL. Some balloon views | 69 // "Upconvert" the string parameters to a data: URL. Some balloon views |
| 67 // require content URL to render anything, so this serves as a backup. | 70 // require content URL to render anything, so this serves as a backup. |
| 68 content_url_ = GURL(DesktopNotificationService::CreateDataUrl( | 71 content_url_ = GURL(DesktopNotificationService::CreateDataUrl( |
| 69 icon_url, title, body, dir)); | 72 icon_url, title, body, dir)); |
| 70 } | 73 } |
| 71 | 74 |
| 75 Notification::Notification( |
| 76 message_center::NotificationType type, |
| 77 const GURL& origin_url, |
| 78 const string16& title, |
| 79 const string16& body, |
| 80 WebKit::WebTextDirection dir, |
| 81 const string16& display_source, |
| 82 const string16& replace_id, |
| 83 const message_center::RichNotificationData& rich_notification_data, |
| 84 NotificationDelegate* delegate) |
| 85 : type_(type), |
| 86 origin_url_(origin_url), |
| 87 is_html_(false), |
| 88 title_(title), |
| 89 body_(body), |
| 90 display_source_(display_source), |
| 91 replace_id_(replace_id), |
| 92 has_rich_notification_(true), |
| 93 rich_notification_data_(rich_notification_data), |
| 94 delegate_(delegate) {} |
| 95 |
| 72 Notification::Notification(const GURL& origin_url, | 96 Notification::Notification(const GURL& origin_url, |
| 73 const gfx::Image& icon, | 97 const gfx::Image& icon, |
| 74 const string16& title, | 98 const string16& title, |
| 75 const string16& body, | 99 const string16& body, |
| 76 WebKit::WebTextDirection dir, | 100 WebKit::WebTextDirection dir, |
| 77 const string16& display_source, | 101 const string16& display_source, |
| 78 const string16& replace_id, | 102 const string16& replace_id, |
| 79 NotificationDelegate* delegate) | 103 NotificationDelegate* delegate) |
| 80 : type_(message_center::NOTIFICATION_TYPE_SIMPLE), | 104 : type_(message_center::NOTIFICATION_TYPE_SIMPLE), |
| 81 origin_url_(origin_url), | 105 origin_url_(origin_url), |
| 82 icon_(icon), | 106 icon_(icon), |
| 83 is_html_(false), | 107 is_html_(false), |
| 84 title_(title), | 108 title_(title), |
| 85 body_(body), | 109 body_(body), |
| 86 display_source_(display_source), | 110 display_source_(display_source), |
| 87 replace_id_(replace_id), | 111 replace_id_(replace_id), |
| 112 has_rich_notification_(false), |
| 88 delegate_(delegate) {} | 113 delegate_(delegate) {} |
| 89 | 114 |
| 90 Notification::Notification(const Notification& notification) | 115 Notification::Notification(const Notification& notification) |
| 91 : type_(notification.type()), | 116 : type_(notification.type()), |
| 92 origin_url_(notification.origin_url()), | 117 origin_url_(notification.origin_url()), |
| 93 icon_(notification.icon()), | 118 icon_(notification.icon()), |
| 94 icon_url_(notification.icon_url()), | 119 icon_url_(notification.icon_url()), |
| 95 is_html_(notification.is_html()), | 120 is_html_(notification.is_html()), |
| 96 content_url_(notification.content_url()), | 121 content_url_(notification.content_url()), |
| 97 title_(notification.title()), | 122 title_(notification.title()), |
| 98 body_(notification.body()), | 123 body_(notification.body()), |
| 99 display_source_(notification.display_source()), | 124 display_source_(notification.display_source()), |
| 100 replace_id_(notification.replace_id()), | 125 replace_id_(notification.replace_id()), |
| 126 has_rich_notification_(notification.has_rich_notification()), |
| 127 rich_notification_data_(notification.rich_notification_data()), |
| 101 delegate_(notification.delegate()) { | 128 delegate_(notification.delegate()) { |
| 102 if (notification.optional_fields()) | 129 if (notification.optional_fields()) |
| 103 optional_fields_.reset(notification.optional_fields()->DeepCopy()); | 130 optional_fields_.reset(notification.optional_fields()->DeepCopy()); |
| 104 } | 131 } |
| 105 | 132 |
| 106 Notification::~Notification() {} | 133 Notification::~Notification() {} |
| 107 | 134 |
| 108 Notification& Notification::operator=(const Notification& notification) { | 135 Notification& Notification::operator=(const Notification& notification) { |
| 109 type_ = notification.type(); | 136 type_ = notification.type(); |
| 110 origin_url_ = notification.origin_url(); | 137 origin_url_ = notification.origin_url(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 122 optional_fields_.reset(); | 149 optional_fields_.reset(); |
| 123 delegate_ = notification.delegate(); | 150 delegate_ = notification.delegate(); |
| 124 return *this; | 151 return *this; |
| 125 } | 152 } |
| 126 | 153 |
| 127 void Notification::DisableTimeout() { | 154 void Notification::DisableTimeout() { |
| 128 if (!optional_fields_.get()) | 155 if (!optional_fields_.get()) |
| 129 optional_fields_.reset(new base::DictionaryValue()); | 156 optional_fields_.reset(new base::DictionaryValue()); |
| 130 optional_fields_->SetBoolean(message_center::kPrivateNeverTimeoutKey, true); | 157 optional_fields_->SetBoolean(message_center::kPrivateNeverTimeoutKey, true); |
| 131 } | 158 } |
| OLD | NEW |