Index: chrome/browser/notifications/notification_ui_manager.cc |
diff --git a/chrome/browser/notifications/notification_ui_manager.cc b/chrome/browser/notifications/notification_ui_manager.cc |
index b4b7f883662ab18a81f9163e82c857b4c59384a0..5539382369e7f130aaed2f281d53135d8f8b8fdf 100644 |
--- a/chrome/browser/notifications/notification_ui_manager.cc |
+++ b/chrome/browser/notifications/notification_ui_manager.cc |
@@ -10,16 +10,32 @@ |
#if defined(ENABLE_MESSAGE_CENTER) |
#include "chrome/browser/notifications/message_center_notification_manager.h" |
+ |
+// MessageCenter either lives in ash::Shell (with USE_ASH), or in |
+// BrowserProcess for non-ash builds. It has to be in ash::Shell since UI |
+// elements of Shell that show notifications use it. |
+#if defined(USE_ASH) |
+#include "ash/shell.h" |
+#else |
+#include "chrome/browser/browser_process.h" |
+#endif |
+ |
+namespace { |
+message_center::MessageCenter* GetMessageCenterInstance() { |
+#if defined (USE_ASH) |
+ return ash::Shell::GetInstance()->message_center(); |
+#else |
+ return g_browser_process->message_center(); |
#endif |
+} |
+} |
+#endif // defined(ENABLE_MESSAGE_CENTER) |
// static |
bool NotificationUIManager::DelegatesToMessageCenter() { |
-#if defined(ENABLE_MESSAGE_CENTER) |
return CommandLine::ForCurrentProcess()->HasSwitch( |
switches::kEnableRichNotifications); |
-#else |
return false; |
-#endif |
} |
#if !defined(OS_MACOSX) |
@@ -27,7 +43,7 @@ bool NotificationUIManager::DelegatesToMessageCenter() { |
NotificationUIManager* NotificationUIManager::Create(PrefService* local_state) { |
#if defined(ENABLE_MESSAGE_CENTER) |
if (DelegatesToMessageCenter()) |
- return new MessageCenterNotificationManager(); |
+ return new MessageCenterNotificationManager(GetMessageCenterInstance()); |
#endif |
BalloonNotificationUIManager* balloon_manager = |
new BalloonNotificationUIManager(local_state); |