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

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

Issue 2836093002: Make Android notifications rely on the native notification flag (Closed)
Patch Set: Add an additional check for Android Created 3 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/notifications/notification_display_service_factory.h" 5 #include "chrome/browser/notifications/notification_display_service_factory.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/singleton.h" 8 #include "base/memory/singleton.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/notifications/message_center_display_service.h" 10 #include "chrome/browser/notifications/message_center_display_service.h"
(...skipping 21 matching lines...) Expand all
32 return base::Singleton<NotificationDisplayServiceFactory>::get(); 32 return base::Singleton<NotificationDisplayServiceFactory>::get();
33 } 33 }
34 34
35 NotificationDisplayServiceFactory::NotificationDisplayServiceFactory() 35 NotificationDisplayServiceFactory::NotificationDisplayServiceFactory()
36 : BrowserContextKeyedServiceFactory( 36 : BrowserContextKeyedServiceFactory(
37 "NotificationDisplayService", 37 "NotificationDisplayService",
38 BrowserContextDependencyManager::GetInstance()) {} 38 BrowserContextDependencyManager::GetInstance()) {}
39 39
40 // Selection of the implementation works as follows: 40 // Selection of the implementation works as follows:
41 // - Android always uses the NativeNotificationDisplayService. 41 // - Android always uses the NativeNotificationDisplayService.
42 // - Mac uses the MessageCenterDisplayService by default, but can use the 42 // - Mac uses the NativeNotificationDisplayService by default but
43 // NativeNotificationDisplayService by using the chrome://flags or via 43 // can revert to MessageCenterDisplayService via
44 // the --enable-features=NativeNotifications command line flag. 44 // chrome://flags#enable-native-notifications or Finch
45 // - Linux uses MessageCenterDisplayService by default but can switch
46 // to NativeNotificationDisplayService via
47 // chrome://flags#enable-native-notifications
45 // - All other platforms always use the MessageCenterDisplayService. 48 // - All other platforms always use the MessageCenterDisplayService.
46 KeyedService* NotificationDisplayServiceFactory::BuildServiceInstanceFor( 49 KeyedService* NotificationDisplayServiceFactory::BuildServiceInstanceFor(
47 content::BrowserContext* context) const { 50 content::BrowserContext* context) const {
48 #if BUILDFLAG(ENABLE_NATIVE_NOTIFICATIONS) 51 #if BUILDFLAG(ENABLE_NATIVE_NOTIFICATIONS)
49 #if defined(OS_ANDROID) 52 #if defined(OS_ANDROID)
53 DCHECK(base::FeatureList::IsEnabled(features::kNativeNotifications));
50 return new NativeNotificationDisplayService( 54 return new NativeNotificationDisplayService(
51 Profile::FromBrowserContext(context), 55 Profile::FromBrowserContext(context),
52 g_browser_process->notification_platform_bridge()); 56 g_browser_process->notification_platform_bridge());
53 #else // defined(OS_ANDROID) 57 #endif
54 if (base::FeatureList::IsEnabled(features::kNativeNotifications) && 58 if (base::FeatureList::IsEnabled(features::kNativeNotifications) &&
55 g_browser_process->notification_platform_bridge()) { 59 g_browser_process->notification_platform_bridge()) {
56 return new NativeNotificationDisplayService( 60 return new NativeNotificationDisplayService(
57 Profile::FromBrowserContext(context), 61 Profile::FromBrowserContext(context),
58 g_browser_process->notification_platform_bridge()); 62 g_browser_process->notification_platform_bridge());
59 } 63 }
60 #endif // defined(OS_ANDROID)
61 #endif // BUILDFLAG(ENABLE_NATIVE_NOTIFICATIONS) 64 #endif // BUILDFLAG(ENABLE_NATIVE_NOTIFICATIONS)
62 return new MessageCenterDisplayService( 65 return new MessageCenterDisplayService(
63 Profile::FromBrowserContext(context), 66 Profile::FromBrowserContext(context),
64 g_browser_process->notification_ui_manager()); 67 g_browser_process->notification_ui_manager());
65 } 68 }
66 69
67 content::BrowserContext* 70 content::BrowserContext*
68 NotificationDisplayServiceFactory::GetBrowserContextToUse( 71 NotificationDisplayServiceFactory::GetBrowserContextToUse(
69 content::BrowserContext* context) const { 72 content::BrowserContext* context) const {
70 return chrome::GetBrowserContextOwnInstanceInIncognito(context); 73 return chrome::GetBrowserContextOwnInstanceInIncognito(context);
71 } 74 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698