Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(670)

Side by Side Diff: chrome/browser/notifications/notification_display_service_factory.cc

Issue 1814923002: Nuke NotificationUIManager from PlatformNotificationServiceImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@profile_manager_load
Patch Set: Review comments + unique_ptr rename Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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_display_service_factory.h"
6
7 #include "base/command_line.h"
8 #include "base/memory/singleton.h"
9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/notifications/message_center_display_service.h"
11 #include "chrome/browser/notifications/notification_ui_manager.h"
12 #include "chrome/browser/profiles/incognito_helpers.h"
13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/common/chrome_switches.h"
15 #include "components/keyed_service/content/browser_context_dependency_manager.h"
16
17 #if defined(OS_ANDROID) || defined(OS_MACOSX)
18 #include "chrome/browser/notifications/native_notification_display_service.h"
19 #endif
20
21 // static
22 NotificationDisplayService* NotificationDisplayServiceFactory::GetForProfile(
23 Profile* profile) {
24 return static_cast<NotificationDisplayService*>(
25 GetInstance()->GetServiceForBrowserContext(profile, true /* create */));
26 }
27
28 // static
29 NotificationDisplayServiceFactory*
30 NotificationDisplayServiceFactory::GetInstance() {
31 return base::Singleton<NotificationDisplayServiceFactory>::get();
32 }
33
34 NotificationDisplayServiceFactory::NotificationDisplayServiceFactory()
35 : BrowserContextKeyedServiceFactory(
36 "NotificationDisplayService",
37 BrowserContextDependencyManager::GetInstance()) {}
38
39 // Android always uses the native service
40 // MAC uses the native manager if chrome://flags#enable-native-notifications is
41 // toggled
42 // Everything else uses the chrome service
Peter Beverloo 2016/04/20 17:34:08 nit: I would phrase this as follows: // Selection
Miguel Garcia 2016/04/21 14:32:10 Done.
43 KeyedService* NotificationDisplayServiceFactory::BuildServiceInstanceFor(
44 content::BrowserContext* context) const {
45 #if defined(OS_ANDROID)
46 return new NativeNotificationDisplayService(
47 Profile::FromBrowserContext(context),
48 g_browser_process->notification_bridge());
49 #elif defined(OS_MACOSX)
50 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
51 switches::kEnableNativeNotifications)) {
52 return new NativeNotificationDisplayService(
53 Profile::FromBrowserContext(context),
54 g_browser_process->notification_bridge());
55 }
56 #endif
57 return new MessageCenterDisplayService(
58 Profile::FromBrowserContext(context),
59 g_browser_process->notification_ui_manager());
60 }
61
62 content::BrowserContext*
63 NotificationDisplayServiceFactory::GetBrowserContextToUse(
64 content::BrowserContext* context) const {
65 return chrome::GetBrowserContextOwnInstanceInIncognito(context);
66 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698