OLD | NEW |
---|---|
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 Loading... | |
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 // Note that for android this flag must always be true. |
Peter Beverloo
2017/04/25 16:31:29
DCHECK?
Miguel Garcia
2017/05/03 07:11:33
As discussed offline in addition to the DCHECK I a
| |
50 return new NativeNotificationDisplayService( | |
51 Profile::FromBrowserContext(context), | |
52 g_browser_process->notification_platform_bridge()); | |
53 #else // defined(OS_ANDROID) | |
54 if (base::FeatureList::IsEnabled(features::kNativeNotifications) && | 53 if (base::FeatureList::IsEnabled(features::kNativeNotifications) && |
55 g_browser_process->notification_platform_bridge()) { | 54 g_browser_process->notification_platform_bridge()) { |
56 return new NativeNotificationDisplayService( | 55 return new NativeNotificationDisplayService( |
57 Profile::FromBrowserContext(context), | 56 Profile::FromBrowserContext(context), |
58 g_browser_process->notification_platform_bridge()); | 57 g_browser_process->notification_platform_bridge()); |
59 } | 58 } |
60 #endif // defined(OS_ANDROID) | |
61 #endif // BUILDFLAG(ENABLE_NATIVE_NOTIFICATIONS) | 59 #endif // BUILDFLAG(ENABLE_NATIVE_NOTIFICATIONS) |
62 return new MessageCenterDisplayService( | 60 return new MessageCenterDisplayService( |
63 Profile::FromBrowserContext(context), | 61 Profile::FromBrowserContext(context), |
64 g_browser_process->notification_ui_manager()); | 62 g_browser_process->notification_ui_manager()); |
65 } | 63 } |
66 | 64 |
67 content::BrowserContext* | 65 content::BrowserContext* |
68 NotificationDisplayServiceFactory::GetBrowserContextToUse( | 66 NotificationDisplayServiceFactory::GetBrowserContextToUse( |
69 content::BrowserContext* context) const { | 67 content::BrowserContext* context) const { |
70 return chrome::GetBrowserContextOwnInstanceInIncognito(context); | 68 return chrome::GetBrowserContextOwnInstanceInIncognito(context); |
71 } | 69 } |
OLD | NEW |