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