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 "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 #include "chrome/browser/notifications/desktop_notification_service.h" | 8 #include "chrome/browser/notifications/desktop_notification_service.h" |
9 #include "ui/base/webui/web_ui_util.h" | 9 #include "ui/base/webui/web_ui_util.h" |
10 #include "ui/message_center/message_center_util.h" | 10 #include "ui/message_center/message_center_util.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 display_source, | 76 display_source, |
77 notifier_id, | 77 notifier_id, |
78 rich_notification_data, | 78 rich_notification_data, |
79 delegate), | 79 delegate), |
80 origin_url_(origin_url), | 80 origin_url_(origin_url), |
81 is_html_(false), | 81 is_html_(false), |
82 replace_id_(replace_id), | 82 replace_id_(replace_id), |
83 delegate_(delegate) { | 83 delegate_(delegate) { |
84 // It's important to leave |icon_url_| empty with rich notifications enabled, | 84 // It's important to leave |icon_url_| empty with rich notifications enabled, |
85 // to prevent "Downloading" the data url and overwriting the existing |icon|. | 85 // to prevent "Downloading" the data url and overwriting the existing |icon|. |
86 if (!message_center::IsRichNotificationEnabled()) { | |
87 // "Upconvert" the string parameters to a data: URL. Some balloon views | |
88 // require content URL to render anything, so this serves as a backup. | |
89 if (!icon.IsEmpty()) | |
90 icon_url_ = GURL(webui::GetBitmapDataUrl(*icon.ToSkBitmap())); | |
91 content_url_ = GURL( | |
92 DesktopNotificationService::CreateDataUrl(icon_url_, title, body, dir)); | |
93 } | |
94 } | 86 } |
95 | 87 |
96 Notification::Notification(const GURL& origin_url, | 88 Notification::Notification(const GURL& origin_url, |
97 const gfx::Image& icon, | 89 const gfx::Image& icon, |
98 const base::string16& title, | 90 const base::string16& title, |
99 const base::string16& body, | 91 const base::string16& body, |
100 blink::WebTextDirection dir, | 92 blink::WebTextDirection dir, |
101 const base::string16& display_source, | 93 const base::string16& display_source, |
102 const base::string16& replace_id, | 94 const base::string16& replace_id, |
103 NotificationDelegate* delegate) | 95 NotificationDelegate* delegate) |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 icon_url_ = notification.icon_url(); | 127 icon_url_ = notification.icon_url(); |
136 is_html_ = notification.is_html(); | 128 is_html_ = notification.is_html(); |
137 content_url_ = notification.content_url(); | 129 content_url_ = notification.content_url(); |
138 button_one_icon_url_ = notification.button_one_icon_url(); | 130 button_one_icon_url_ = notification.button_one_icon_url(); |
139 button_two_icon_url_ = notification.button_two_icon_url(); | 131 button_two_icon_url_ = notification.button_two_icon_url(); |
140 image_url_ = notification.image_url(); | 132 image_url_ = notification.image_url(); |
141 replace_id_ = notification.replace_id(); | 133 replace_id_ = notification.replace_id(); |
142 delegate_ = notification.delegate(); | 134 delegate_ = notification.delegate(); |
143 return *this; | 135 return *this; |
144 } | 136 } |
OLD | NEW |