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/chrome_notification_types.h" |
10 #include "chrome/browser/extensions/extension_info_map.h" | 11 #include "chrome/browser/extensions/extension_info_map.h" |
11 #include "chrome/browser/extensions/extension_system.h" | 12 #include "chrome/browser/extensions/extension_system.h" |
12 #include "chrome/browser/notifications/desktop_notification_service.h" | 13 #include "chrome/browser/notifications/desktop_notification_service.h" |
13 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 14 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
14 #include "chrome/browser/notifications/message_center_settings_controller.h" | 15 #include "chrome/browser/notifications/message_center_settings_controller.h" |
15 #include "chrome/browser/notifications/notification.h" | 16 #include "chrome/browser/notifications/notification.h" |
16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/ui/browser_finder.h" | 18 #include "chrome/browser/ui/browser_finder.h" |
18 #include "chrome/browser/ui/chrome_pages.h" | 19 #include "chrome/browser/ui/chrome_pages.h" |
19 #include "chrome/browser/ui/host_desktop.h" | 20 #include "chrome/browser/ui/host_desktop.h" |
20 #include "chrome/common/extensions/extension_set.h" | 21 #include "chrome/common/extensions/extension_set.h" |
21 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 23 #include "content/public/browser/notification_service.h" |
| 24 #include "content/public/browser/user_metrics.h" |
22 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
23 #include "content/public/common/url_constants.h" | 26 #include "content/public/common/url_constants.h" |
24 #include "ui/message_center/message_center_style.h" | 27 #include "ui/message_center/message_center_style.h" |
25 #include "ui/message_center/message_center_tray.h" | 28 #include "ui/message_center/message_center_tray.h" |
26 #include "ui/message_center/notifier_settings.h" | 29 #include "ui/message_center/notifier_settings.h" |
27 | 30 |
28 namespace { | 31 namespace { |
29 // The first-run balloon will be shown |kFirstRunIdleDelaySeconds| after all | 32 // The first-run balloon will be shown |kFirstRunIdleDelaySeconds| after all |
30 // popups go away and the user has notifications in the message center. | 33 // popups go away and the user has notifications in the message center. |
31 const int kFirstRunIdleDelaySeconds = 1; | 34 const int kFirstRunIdleDelaySeconds = 1; |
(...skipping 16 matching lines...) Expand all Loading... |
48 message_center_->SetDelegate(this); | 51 message_center_->SetDelegate(this); |
49 message_center_->AddObserver(this); | 52 message_center_->AddObserver(this); |
50 message_center_->SetNotifierSettingsProvider(settings_controller_.get()); | 53 message_center_->SetNotifierSettingsProvider(settings_controller_.get()); |
51 | 54 |
52 #if defined(OS_WIN) || defined(OS_MACOSX) \ | 55 #if defined(OS_WIN) || defined(OS_MACOSX) \ |
53 || (defined(USE_AURA) && !defined(USE_ASH)) | 56 || (defined(USE_AURA) && !defined(USE_ASH)) |
54 // On Windows, Linux and Mac, the notification manager owns the tray icon and | 57 // On Windows, Linux and Mac, the notification manager owns the tray icon and |
55 // views.Other platforms have global ownership and Create will return NULL. | 58 // views.Other platforms have global ownership and Create will return NULL. |
56 tray_.reset(message_center::CreateMessageCenterTray()); | 59 tray_.reset(message_center::CreateMessageCenterTray()); |
57 #endif | 60 #endif |
| 61 registrar_.Add(this, |
| 62 chrome::NOTIFICATION_FULLSCREEN_CHANGED, |
| 63 content::NotificationService::AllSources()); |
58 } | 64 } |
59 | 65 |
60 MessageCenterNotificationManager::~MessageCenterNotificationManager() { | 66 MessageCenterNotificationManager::~MessageCenterNotificationManager() { |
61 message_center_->RemoveObserver(this); | 67 message_center_->RemoveObserver(this); |
62 } | 68 } |
63 | 69 |
64 //////////////////////////////////////////////////////////////////////////////// | 70 //////////////////////////////////////////////////////////////////////////////// |
65 // NotificationUIManager | 71 // NotificationUIManager |
66 | 72 |
67 const Notification* MessageCenterNotificationManager::FindById( | 73 const Notification* MessageCenterNotificationManager::FindById( |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 #if defined(OS_WIN) | 327 #if defined(OS_WIN) |
322 CheckFirstRunTimer(); | 328 CheckFirstRunTimer(); |
323 #endif | 329 #endif |
324 } | 330 } |
325 | 331 |
326 void MessageCenterNotificationManager::SetMessageCenterTrayDelegateForTest( | 332 void MessageCenterNotificationManager::SetMessageCenterTrayDelegateForTest( |
327 message_center::MessageCenterTrayDelegate* delegate) { | 333 message_center::MessageCenterTrayDelegate* delegate) { |
328 tray_.reset(delegate); | 334 tray_.reset(delegate); |
329 } | 335 } |
330 | 336 |
| 337 void MessageCenterNotificationManager::Observe( |
| 338 int type, |
| 339 const content::NotificationSource& source, |
| 340 const content::NotificationDetails& details) { |
| 341 if (type == chrome::NOTIFICATION_FULLSCREEN_CHANGED) { |
| 342 const bool is_fullscreen = *content::Details<bool>(details).ptr(); |
| 343 |
| 344 if (is_fullscreen && tray_.get() && tray_->GetMessageCenterTray()) |
| 345 tray_->GetMessageCenterTray()->HidePopupBubble(); |
| 346 } else { |
| 347 NotificationUIManagerImpl::Observe(type, source, details); |
| 348 } |
| 349 } |
| 350 |
331 //////////////////////////////////////////////////////////////////////////////// | 351 //////////////////////////////////////////////////////////////////////////////// |
332 // ImageDownloads | 352 // ImageDownloads |
333 | 353 |
334 MessageCenterNotificationManager::ImageDownloads::ImageDownloads( | 354 MessageCenterNotificationManager::ImageDownloads::ImageDownloads( |
335 message_center::MessageCenter* message_center, | 355 message_center::MessageCenter* message_center, |
336 ImageDownloadsObserver* observer) | 356 ImageDownloadsObserver* observer) |
337 : message_center_(message_center), | 357 : message_center_(message_center), |
338 pending_downloads_(0), | 358 pending_downloads_(0), |
339 observer_(observer) { | 359 observer_(observer) { |
340 } | 360 } |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 | 558 |
539 MessageCenterNotificationManager::ProfileNotification* | 559 MessageCenterNotificationManager::ProfileNotification* |
540 MessageCenterNotificationManager::FindProfileNotification( | 560 MessageCenterNotificationManager::FindProfileNotification( |
541 const std::string& id) const { | 561 const std::string& id) const { |
542 NotificationMap::const_iterator iter = profile_notifications_.find(id); | 562 NotificationMap::const_iterator iter = profile_notifications_.find(id); |
543 if (iter == profile_notifications_.end()) | 563 if (iter == profile_notifications_.end()) |
544 return NULL; | 564 return NULL; |
545 | 565 |
546 return (*iter).second; | 566 return (*iter).second; |
547 } | 567 } |
OLD | NEW |