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/ui/views/ash/balloon_view_ash.h" | 5 #include "chrome/browser/ui/views/ash/balloon_view_ash.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/system/web_notification/web_notification_tray.h" | 8 #include "ash/system/web_notification/web_notification_tray.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 159 |
160 BalloonHost* BalloonViewAsh::GetHost() const { | 160 BalloonHost* BalloonViewAsh::GetHost() const { |
161 return NULL; | 161 return NULL; |
162 } | 162 } |
163 | 163 |
164 void BalloonViewAsh::SetNotificationIcon(const std::string& id, | 164 void BalloonViewAsh::SetNotificationIcon(const std::string& id, |
165 const gfx::ImageSkia& image) { | 165 const gfx::ImageSkia& image) { |
166 GetMessageCenter()->SetNotificationPrimaryIcon(id, image); | 166 GetMessageCenter()->SetNotificationPrimaryIcon(id, image); |
167 } | 167 } |
168 | 168 |
| 169 void BalloonViewAsh::SetNotificationImage(const std::string& id, |
| 170 const gfx::ImageSkia& image) { |
| 171 GetMessageCenter()->SetNotificationImage(id, image); |
| 172 } |
| 173 |
169 void BalloonViewAsh::DownloadImages(const Notification& notification) { | 174 void BalloonViewAsh::DownloadImages(const Notification& notification) { |
170 // Cancel any previous downloads. | 175 // Cancel any previous downloads. |
171 downloads_.clear(); | 176 downloads_.clear(); |
172 | 177 |
173 // Set the notification's primary icon, or start a download for it. | 178 // Set the notification's primary icon, or start a download for it. |
174 if (!notification.icon().isNull()) { | 179 if (!notification.icon().isNull()) { |
175 SetNotificationIcon(notification_id_, notification.icon()); | 180 SetNotificationIcon(notification_id_, notification.icon()); |
176 } else if (!notification.icon_url().is_empty()) { | 181 } else if (!notification.icon_url().is_empty()) { |
177 downloads_.push_back(linked_ptr<ImageDownload>(new ImageDownload( | 182 downloads_.push_back(linked_ptr<ImageDownload>(new ImageDownload( |
178 notification, notification.icon_url(), | 183 notification, notification.icon_url(), |
179 message_center::kNotificationIconWidth, | 184 message_center::kNotificationIconWidth, |
180 base::Bind(&BalloonViewAsh::SetNotificationIcon, | 185 base::Bind(&BalloonViewAsh::SetNotificationIcon, |
181 base::Unretained(this), notification.notification_id())))); | 186 base::Unretained(this), notification.notification_id())))); |
182 } | 187 } |
| 188 |
| 189 // Start a download for the notification's image if appropriate. |
| 190 const base::DictionaryValue* optional_fields = notification.optional_fields(); |
| 191 if (optional_fields && |
| 192 optional_fields->HasKey(ui::notifications::kImageUrlKey)) { |
| 193 string16 url; |
| 194 optional_fields->GetString(ui::notifications::kImageUrlKey, &url); |
| 195 if (!url.empty()) { |
| 196 downloads_.push_back(linked_ptr<ImageDownload>(new ImageDownload( |
| 197 notification, GURL(url), |
| 198 message_center::kNotificationPreferredImageSize, |
| 199 base::Bind(&BalloonViewAsh::SetNotificationImage, |
| 200 base::Unretained(this), notification.notification_id())))); |
| 201 } |
| 202 } |
183 } | 203 } |
OLD | NEW |