| 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" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chrome/browser/favicon/favicon_util.h" | 12 #include "chrome/browser/favicon/favicon_util.h" |
| 13 #include "chrome/browser/notifications/balloon_collection.h" | 13 #include "chrome/browser/notifications/balloon_collection.h" |
| 14 #include "chrome/browser/notifications/notification.h" | 14 #include "chrome/browser/notifications/notification.h" |
| 15 #include "content/public/browser/render_process_host.h" | 15 #include "content/public/browser/render_process_host.h" |
| 16 #include "content/public/browser/render_view_host.h" | 16 #include "content/public/browser/render_view_host.h" |
| 17 #include "content/public/browser/site_instance.h" | 17 #include "content/public/browser/site_instance.h" |
| 18 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 19 #include "content/public/browser/web_contents_delegate.h" | 19 #include "content/public/browser/web_contents_delegate.h" |
| 20 #include "content/public/browser/web_contents_observer.h" | 20 #include "content/public/browser/web_contents_observer.h" |
| 21 #include "ipc/ipc_message.h" | 21 #include "ipc/ipc_message.h" |
| 22 #include "ipc/ipc_message_macros.h" | 22 #include "ipc/ipc_message_macros.h" |
| 23 #include "ui/gfx/image/image_skia.h" | 23 #include "ui/gfx/image/image_skia.h" |
| 24 #include "ui/message_center/message_center.h" | 24 #include "ui/message_center/message_center.h" |
| 25 #include "ui/message_center/message_center_constants.h" | 25 #include "ui/message_center/message_center_constants.h" |
| 26 #include "ui/message_center/notification_types.h" |
| 26 #include "webkit/glue/image_resource_fetcher.h" | 27 #include "webkit/glue/image_resource_fetcher.h" |
| 27 | 28 |
| 28 namespace { | 29 namespace { |
| 29 | 30 |
| 30 typedef base::Callback<void(const gfx::ImageSkia&)> SetImageCallback; | 31 typedef base::Callback<void(const gfx::ImageSkia&)> SetImageCallback; |
| 31 | 32 |
| 32 const int kPrimaryIconImageSize = 64; | 33 const int kPrimaryIconImageSize = 64; |
| 33 const int kSecondaryIconImageSize = 15; | 34 const int kSecondaryIconImageSize = 15; |
| 34 | 35 |
| 35 // static | 36 // static |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 downloads_.push_back(linked_ptr<ImageDownload>(new ImageDownload( | 189 downloads_.push_back(linked_ptr<ImageDownload>(new ImageDownload( |
| 189 notification, notification.icon_url(), | 190 notification, notification.icon_url(), |
| 190 message_center::kNotificationIconSize, | 191 message_center::kNotificationIconSize, |
| 191 base::Bind(&BalloonViewAsh::SetNotificationIcon, | 192 base::Bind(&BalloonViewAsh::SetNotificationIcon, |
| 192 base::Unretained(this), notification.notification_id())))); | 193 base::Unretained(this), notification.notification_id())))); |
| 193 } | 194 } |
| 194 | 195 |
| 195 const base::DictionaryValue* optional_fields = notification.optional_fields(); | 196 const base::DictionaryValue* optional_fields = notification.optional_fields(); |
| 196 if (optional_fields) { | 197 if (optional_fields) { |
| 197 // Start a download for the notification's image if appropriate. | 198 // Start a download for the notification's image if appropriate. |
| 198 if (optional_fields->HasKey(ui::notifications::kImageUrlKey)) { | 199 if (optional_fields->HasKey(message_center::kImageUrlKey)) { |
| 199 string16 url; | 200 string16 url; |
| 200 optional_fields->GetString(ui::notifications::kImageUrlKey, &url); | 201 optional_fields->GetString(message_center::kImageUrlKey, &url); |
| 201 if (!url.empty()) { | 202 if (!url.empty()) { |
| 202 downloads_.push_back(linked_ptr<ImageDownload>(new ImageDownload( | 203 downloads_.push_back(linked_ptr<ImageDownload>(new ImageDownload( |
| 203 notification, | 204 notification, |
| 204 GURL(url), | 205 GURL(url), |
| 205 message_center::kNotificationPreferredImageSize, | 206 message_center::kNotificationPreferredImageSize, |
| 206 base::Bind(&BalloonViewAsh::SetNotificationImage, | 207 base::Bind(&BalloonViewAsh::SetNotificationImage, |
| 207 base::Unretained(this), | 208 base::Unretained(this), |
| 208 notification.notification_id())))); | 209 notification.notification_id())))); |
| 209 } | 210 } |
| 210 } | 211 } |
| 211 | 212 |
| 212 // Start a download for the notification's button icons if appropriate. | 213 // Start a download for the notification's button icons if appropriate. |
| 213 const char* kButtonIconKeys[] = { ui::notifications::kButtonOneIconUrlKey, | 214 const char* kButtonIconKeys[] = { message_center::kButtonOneIconUrlKey, |
| 214 ui::notifications::kButtonTwoIconUrlKey }; | 215 message_center::kButtonTwoIconUrlKey }; |
| 215 for (size_t i = 0; i < arraysize(kButtonIconKeys); ++i) { | 216 for (size_t i = 0; i < arraysize(kButtonIconKeys); ++i) { |
| 216 if (optional_fields->HasKey(kButtonIconKeys[i])) { | 217 if (optional_fields->HasKey(kButtonIconKeys[i])) { |
| 217 string16 url; | 218 string16 url; |
| 218 optional_fields->GetString(kButtonIconKeys[i], &url); | 219 optional_fields->GetString(kButtonIconKeys[i], &url); |
| 219 if (!url.empty()) { | 220 if (!url.empty()) { |
| 220 downloads_.push_back(linked_ptr<ImageDownload>(new ImageDownload( | 221 downloads_.push_back(linked_ptr<ImageDownload>(new ImageDownload( |
| 221 notification, | 222 notification, |
| 222 GURL(url), | 223 GURL(url), |
| 223 message_center::kNotificationButtonIconSize, | 224 message_center::kNotificationButtonIconSize, |
| 224 base::Bind(&BalloonViewAsh::SetNotificationButtonIcon, | 225 base::Bind(&BalloonViewAsh::SetNotificationButtonIcon, |
| 225 base::Unretained(this), | 226 base::Unretained(this), |
| 226 notification.notification_id(), | 227 notification.notification_id(), |
| 227 i)))); | 228 i)))); |
| 228 } | 229 } |
| 229 } | 230 } |
| 230 } | 231 } |
| 231 } | 232 } |
| 232 } | 233 } |
| OLD | NEW |