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/notification_ui_manager.h" | 5 #include "chrome/browser/notifications/notification_ui_manager.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "chrome/browser/notifications/balloon_notification_ui_manager.h" | 8 #include "chrome/browser/notifications/balloon_notification_ui_manager.h" |
9 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
10 | 10 |
11 #if defined(ENABLE_MESSAGE_CENTER) | 11 #if defined(ENABLE_MESSAGE_CENTER) |
12 #include "chrome/browser/notifications/message_center_notification_manager.h" | 12 #include "chrome/browser/notifications/message_center_notification_manager.h" |
| 13 |
| 14 // MessageCenter either lives in ash::Shell (with USE_ASH), or in |
| 15 // BrowserProcess for non-ash builds. It has to be in ash::Shell since UI |
| 16 // elements of Shell that show notifications use it. |
| 17 #if defined(USE_ASH) |
| 18 #include "ash/shell.h" |
| 19 #else |
| 20 #include "chrome/browser/browser_process.h" |
13 #endif | 21 #endif |
14 | 22 |
| 23 namespace { |
| 24 message_center::MessageCenter* GetMessageCenterInstance() { |
| 25 #if defined (USE_ASH) |
| 26 return ash::Shell::GetInstance()->message_center(); |
| 27 #else |
| 28 return g_browser_process->message_center(); |
| 29 #endif |
| 30 } |
| 31 } |
| 32 #endif // defined(ENABLE_MESSAGE_CENTER) |
| 33 |
15 // static | 34 // static |
16 bool NotificationUIManager::DelegatesToMessageCenter() { | 35 bool NotificationUIManager::DelegatesToMessageCenter() { |
17 #if defined(ENABLE_MESSAGE_CENTER) | |
18 return CommandLine::ForCurrentProcess()->HasSwitch( | 36 return CommandLine::ForCurrentProcess()->HasSwitch( |
19 switches::kEnableRichNotifications); | 37 switches::kEnableRichNotifications); |
20 #else | |
21 return false; | 38 return false; |
22 #endif | |
23 } | 39 } |
24 | 40 |
25 #if !defined(OS_MACOSX) | 41 #if !defined(OS_MACOSX) |
26 // static | 42 // static |
27 NotificationUIManager* NotificationUIManager::Create(PrefService* local_state) { | 43 NotificationUIManager* NotificationUIManager::Create(PrefService* local_state) { |
28 #if defined(ENABLE_MESSAGE_CENTER) | 44 #if defined(ENABLE_MESSAGE_CENTER) |
29 if (DelegatesToMessageCenter()) | 45 if (DelegatesToMessageCenter()) |
30 return new MessageCenterNotificationManager(); | 46 return new MessageCenterNotificationManager(GetMessageCenterInstance()); |
31 #endif | 47 #endif |
32 BalloonNotificationUIManager* balloon_manager = | 48 BalloonNotificationUIManager* balloon_manager = |
33 new BalloonNotificationUIManager(local_state); | 49 new BalloonNotificationUIManager(local_state); |
34 balloon_manager->SetBalloonCollection(BalloonCollection::Create()); | 50 balloon_manager->SetBalloonCollection(BalloonCollection::Create()); |
35 return balloon_manager; | 51 return balloon_manager; |
36 } | 52 } |
37 #endif | 53 #endif |
38 | 54 |
OLD | NEW |