Upstream version 7.35.144.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / notifications / notification_ui_manager.cc
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
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"
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 #if !defined(OS_MACOSX)
32 // static
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(),
41         local_state,
42         settings_provider.Pass());
43   }
44
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.
48   CHECK(false);
49   return NULL;
50 #else
51   BalloonNotificationUIManager* balloon_manager =
52       new BalloonNotificationUIManager(local_state);
53   balloon_manager->SetBalloonCollection(BalloonCollection::Create());
54   return balloon_manager;
55 #endif
56 }
57 #endif