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

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: 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/chrome_notification_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
16 #if defined(OS_ANDROID) || defined(OS_MACOSX)
17 #include "chrome/browser/notifications/native_notification_display_service.h"
18 #endif
19
20 // static
21 NotificationDisplayService* NotificationDisplayServiceFactory::GetForProfile(
22 Profile* profile) {
23 return static_cast<NotificationDisplayService*>(
24 GetInstance()->GetServiceForBrowserContext(profile, true));
Peter Beverloo 2016/04/18 14:57:10 GetInstance()->GetServiceForBrowserContext(profile
Miguel Garcia 2016/04/19 14:24:57 Done.
25 }
26
27 // static
28 NotificationDisplayServiceFactory*
29 NotificationDisplayServiceFactory::GetInstance() {
30 return base::Singleton<NotificationDisplayServiceFactory>::get();
31 }
32
33 NotificationDisplayServiceFactory::NotificationDisplayServiceFactory()
34 : BrowserContextKeyedServiceFactory(
35 "NotificationDisplayService",
36 BrowserContextDependencyManager::GetInstance()) {}
37
38 // Android always uses the native service
39 // MAC uses the native manager if chrome://flags#enable-native-notifications is
40 // toggled
41 // Everything else uses the chrome service
42 KeyedService* NotificationDisplayServiceFactory::BuildServiceInstanceFor(
43 content::BrowserContext* context) const {
44 #if defined(OS_ANDROID)
45 return new NativeNotificationDisplayService(
46 Profile::FromBrowserContext(context),
47 g_browser_process->notification_bridge());
48 #elif defined(OS_MACOSX)
49 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
50 switches::kEnableNativeNotifications)) {
51 return new NativeNotificationDisplayService(
52 Profile::FromBrowserContext(context),
53 g_browser_process->notification_bridge());
54 }
55 #endif
56 return new ChromeNotificationDisplayService(
57 Profile::FromBrowserContext(context),
58 g_browser_process->notification_ui_manager());
59 }
60
61 content::BrowserContext*
62 NotificationDisplayServiceFactory::GetBrowserContextToUse(
63 content::BrowserContext* context) const {
64 return chrome::GetBrowserContextOwnInstanceInIncognito(context);
65 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698