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/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/notifications/balloon_notification_ui_manager.h" | 9 #include "chrome/browser/notifications/balloon_notification_ui_manager.h" |
10 #include "chrome/browser/notifications/message_center_notification_manager.h" | 10 #include "chrome/browser/notifications/message_center_notification_manager.h" |
11 #include "chrome/browser/notifications/message_center_settings_controller.h" | 11 #include "chrome/browser/notifications/message_center_settings_controller.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/profiles/profile_info_cache.h" | 13 #include "chrome/browser/profiles/profile_info_cache.h" |
14 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
15 #include "ui/message_center/message_center_util.h" | 15 #include "ui/message_center/message_center_util.h" |
16 | 16 |
17 // static | 17 // static |
18 bool NotificationUIManager::DelegatesToMessageCenter() { | 18 bool NotificationUIManager::DelegatesToMessageCenter() { |
19 // In ChromeOS, it always uses MessageCenterNotificationManager. The flag of | 19 // In ChromeOS, it always uses MessageCenterNotificationManager. The flag of |
20 // --enable-rich-notifications switches the contents and behaviors inside of | 20 // --enable-rich-notifications switches the contents and behaviors inside of |
21 // the message center. | 21 // the message center. |
22 #if defined(OS_CHROMEOS) | 22 #if defined(OS_CHROMEOS) |
23 return true; | 23 return true; |
24 #endif | 24 #endif |
25 return message_center::IsRichNotificationEnabled(); | 25 return message_center::IsRichNotificationEnabled(); |
26 } | 26 } |
27 | 27 |
28 #if !defined(OS_MACOSX) | |
29 // static | 28 // static |
30 NotificationUIManager* NotificationUIManager::Create(PrefService* local_state) { | 29 NotificationUIManager* NotificationUIManager::Create(PrefService* local_state) { |
31 if (DelegatesToMessageCenter()) { | 30 if (DelegatesToMessageCenter()) { |
32 ProfileInfoCache* profile_info_cache = | 31 ProfileInfoCache* profile_info_cache = |
33 &g_browser_process->profile_manager()->GetProfileInfoCache(); | 32 &g_browser_process->profile_manager()->GetProfileInfoCache(); |
34 scoped_ptr<message_center::NotifierSettingsProvider> settings_provider( | 33 scoped_ptr<message_center::NotifierSettingsProvider> settings_provider( |
35 new MessageCenterSettingsController(profile_info_cache)); | 34 new MessageCenterSettingsController(profile_info_cache)); |
36 return new MessageCenterNotificationManager( | 35 return new MessageCenterNotificationManager( |
37 g_browser_process->message_center(), | 36 g_browser_process->message_center(), |
38 local_state, | 37 local_state, |
39 settings_provider.Pass()); | 38 settings_provider.Pass()); |
40 } | 39 } |
41 | 40 |
| 41 #if defined(OS_MACOSX) |
| 42 NOTREACHED(); |
| 43 return NULL; |
| 44 #else |
42 BalloonNotificationUIManager* balloon_manager = | 45 BalloonNotificationUIManager* balloon_manager = |
43 new BalloonNotificationUIManager(local_state); | 46 new BalloonNotificationUIManager(local_state); |
44 balloon_manager->SetBalloonCollection(BalloonCollection::Create()); | 47 balloon_manager->SetBalloonCollection(BalloonCollection::Create()); |
45 return balloon_manager; | 48 return balloon_manager; |
| 49 #endif |
46 } | 50 } |
47 #endif | |
OLD | NEW |