Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 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. |
| 4 | |
| 5 | #include "chrome/browser/notifications/notification_ui_manager.h" |
| 6 | |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 7 | #include "base/memory/scoped_ptr.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 8 | #include "chrome/browser/browser_process.h" |
Torne (Richard Coles) | a93a17c | 2013-05-15 11:34:50 +0100 | [diff] [blame] | 9 | #include "chrome/browser/notifications/balloon_notification_ui_manager.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 10 | #include "chrome/browser/notifications/message_center_notification_manager.h" |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 11 | #include "chrome/browser/notifications/message_center_settings_controller.h" |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 12 | #include "chrome/browser/profiles/profile.h" |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 13 | #include "chrome/browser/profiles/profile_info_cache.h" |
| 14 | #include "chrome/browser/profiles/profile_manager.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 15 | #include "ui/message_center/message_center_util.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 16 | |
| 17 | // static |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 18 | bool NotificationUIManager::DelegatesToMessageCenter() { |
| 19 | // In ChromeOS, it always uses MessageCenterNotificationManager. The flag of |
| 20 | // --enable-rich-notifications switches the contents and behaviors inside of |
| 21 | // the message center. |
| 22 | #if defined(OS_CHROMEOS) |
| 23 | return true; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 24 | #endif |
Torne (Richard Coles) | a93a17c | 2013-05-15 11:34:50 +0100 | [diff] [blame] | 25 | return message_center::IsRichNotificationEnabled(); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | #if !defined(OS_MACOSX) |
| 29 | // static |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 30 | NotificationUIManager* NotificationUIManager::Create(PrefService* local_state) { |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 31 | if (DelegatesToMessageCenter()) { |
| 32 | ProfileInfoCache* profile_info_cache = |
| 33 | &g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 34 | scoped_ptr<message_center::NotifierSettingsProvider> settings_provider( |
| 35 | new MessageCenterSettingsController(profile_info_cache)); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 36 | return new MessageCenterNotificationManager( |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 37 | g_browser_process->message_center(), |
| 38 | local_state, |
| 39 | settings_provider.Pass()); |
| 40 | } |
Torne (Richard Coles) | a93a17c | 2013-05-15 11:34:50 +0100 | [diff] [blame] | 41 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 42 | BalloonNotificationUIManager* balloon_manager = |
| 43 | new BalloonNotificationUIManager(local_state); |
| 44 | balloon_manager->SetBalloonCollection(BalloonCollection::Create()); |
| 45 | return balloon_manager; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 46 | } |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 47 | #endif |