| 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/message_center_notification_manager.h" | 5 #include "chrome/browser/notifications/message_center_notification_manager.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| 11 #include "chrome/browser/notifications/desktop_notification_service.h" | 11 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 12 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 12 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
| 13 #include "chrome/browser/notifications/message_center_settings_controller.h" | 13 #include "chrome/browser/notifications/message_center_settings_controller.h" |
| 14 #include "chrome/browser/notifications/notification.h" | 14 #include "chrome/browser/notifications/notification.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/ui/browser_finder.h" | 16 #include "chrome/browser/ui/browser_finder.h" |
| 17 #include "chrome/browser/ui/chrome_pages.h" | 17 #include "chrome/browser/ui/chrome_pages.h" |
| 18 #include "chrome/browser/ui/host_desktop.h" | 18 #include "chrome/browser/ui/host_desktop.h" |
| 19 #include "chrome/common/extensions/extension_set.h" | 19 #include "chrome/common/extensions/extension_set.h" |
| 20 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| 21 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 22 #include "content/public/common/content_constants.h" |
| 22 #include "ui/message_center/message_center_constants.h" | 23 #include "ui/message_center/message_center_constants.h" |
| 23 #include "ui/message_center/message_center_tray.h" | 24 #include "ui/message_center/message_center_tray.h" |
| 24 | 25 |
| 25 MessageCenterNotificationManager::MessageCenterNotificationManager( | 26 MessageCenterNotificationManager::MessageCenterNotificationManager( |
| 26 message_center::MessageCenter* message_center) | 27 message_center::MessageCenter* message_center) |
| 27 : message_center_(message_center), | 28 : message_center_(message_center), |
| 28 settings_controller_(new MessageCenterSettingsController) { | 29 settings_controller_(new MessageCenterSettingsController) { |
| 29 message_center_->SetDelegate(this); | 30 message_center_->SetDelegate(this); |
| 30 | 31 |
| 31 #if !defined(OS_CHROMEOS) | 32 #if !defined(OS_CHROMEOS) |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 | 302 |
| 302 content::WebContents* contents = | 303 content::WebContents* contents = |
| 303 content::WebContents::FromRenderViewHost(host); | 304 content::WebContents::FromRenderViewHost(host); |
| 304 if (!contents) { | 305 if (!contents) { |
| 305 LOG(WARNING) << "Notification needs an image but has no WebContents"; | 306 LOG(WARNING) << "Notification needs an image but has no WebContents"; |
| 306 return; | 307 return; |
| 307 } | 308 } |
| 308 | 309 |
| 309 contents->DownloadFavicon( | 310 contents->DownloadFavicon( |
| 310 url, | 311 url, |
| 312 content::DOWNLOAD_OTHER, |
| 311 size, | 313 size, |
| 312 base::Bind( | 314 base::Bind( |
| 313 &MessageCenterNotificationManager::ImageDownloads::DownloadComplete, | 315 &MessageCenterNotificationManager::ImageDownloads::DownloadComplete, |
| 314 AsWeakPtr(), | 316 AsWeakPtr(), |
| 315 callback)); | 317 callback)); |
| 316 } | 318 } |
| 317 | 319 |
| 318 void MessageCenterNotificationManager::ImageDownloads::StartDownloadByKey( | 320 void MessageCenterNotificationManager::ImageDownloads::StartDownloadByKey( |
| 319 const Notification& notification, | 321 const Notification& notification, |
| 320 const char* key, | 322 const char* key, |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 | 405 |
| 404 MessageCenterNotificationManager::ProfileNotification* | 406 MessageCenterNotificationManager::ProfileNotification* |
| 405 MessageCenterNotificationManager::FindProfileNotification( | 407 MessageCenterNotificationManager::FindProfileNotification( |
| 406 const std::string& id) const { | 408 const std::string& id) const { |
| 407 NotificationMap::const_iterator iter = profile_notifications_.find(id); | 409 NotificationMap::const_iterator iter = profile_notifications_.find(id); |
| 408 // If the notification is shown in UI, it must be in the map. | 410 // If the notification is shown in UI, it must be in the map. |
| 409 DCHECK(iter != profile_notifications_.end()); | 411 DCHECK(iter != profile_notifications_.end()); |
| 410 DCHECK((*iter).second); | 412 DCHECK((*iter).second); |
| 411 return (*iter).second; | 413 return (*iter).second; |
| 412 } | 414 } |
| OLD | NEW |