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
3 // found in the LICENSE file.
5 #include "chrome/browser/notifications/notification_ui_manager.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/notifications/message_center_notification_manager.h"
10 #include "chrome/browser/notifications/message_center_settings_controller.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/profiles/profile_info_cache.h"
13 #include "chrome/browser/profiles/profile_manager.h"
14 #include "ui/message_center/message_center_util.h"
16 #if !defined(OS_CHROMEOS)
17 #include "chrome/browser/notifications/balloon_notification_ui_manager.h"
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)
28 return message_center::IsRichNotificationEnabled();
31 #if !defined(OS_MACOSX)
33 NotificationUIManager* NotificationUIManager::Create(PrefService* local_state) {
34 if (DelegatesToMessageCenter()) {
35 ProfileInfoCache* profile_info_cache =
36 &g_browser_process->profile_manager()->GetProfileInfoCache();
37 scoped_ptr<message_center::NotifierSettingsProvider> settings_provider(
38 new MessageCenterSettingsController(profile_info_cache));
39 return new MessageCenterNotificationManager(
40 g_browser_process->message_center(),
42 settings_provider.Pass());
45 #if defined(OS_CHROMEOS)
46 // Since we can't reach here for CrOS (see above), no point compiling all
47 // the dependent classes there.
51 BalloonNotificationUIManager* balloon_manager =
52 new BalloonNotificationUIManager(local_state);
53 balloon_manager->SetBalloonCollection(BalloonCollection::Create());
54 return balloon_manager;