Chromium Code Reviews| 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" |
| 11 #include "chrome/browser/notifications/notification_ui_manager.h" | 11 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 12 #include "chrome/browser/profiles/incognito_helpers.h" | 12 #include "chrome/browser/profiles/incognito_helpers.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/common/chrome_features.h" | 14 #include "chrome/common/chrome_features.h" |
| 15 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 15 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 16 | 16 |
| 17 #if defined(OS_ANDROID) || defined(OS_MACOSX) | 17 #if defined(OS_ANDROID) || defined(OS_MACOSX) || \ |
| 18 (defined(OS_LINUX) && !defined(OS_CHROMEOS)) | |
|
Lei Zhang
2017/04/04 07:47:21
To make this even longer, do we need to gate this
Peter Beverloo
2017/04/04 13:34:46
It probably makes sense to use a BUILDFLAG for thi
Tom (Use chromium acct)
2017/04/04 21:47:10
Added the BUILDFLAG and made the condition depend
| |
| 18 #include "chrome/browser/notifications/native_notification_display_service.h" | 19 #include "chrome/browser/notifications/native_notification_display_service.h" |
| 19 #endif | 20 #endif |
| 20 | 21 |
| 21 // static | 22 // static |
| 22 NotificationDisplayService* NotificationDisplayServiceFactory::GetForProfile( | 23 NotificationDisplayService* NotificationDisplayServiceFactory::GetForProfile( |
| 23 Profile* profile) { | 24 Profile* profile) { |
| 24 return static_cast<NotificationDisplayService*>( | 25 return static_cast<NotificationDisplayService*>( |
| 25 GetInstance()->GetServiceForBrowserContext(profile, true /* create */)); | 26 GetInstance()->GetServiceForBrowserContext(profile, true /* create */)); |
| 26 } | 27 } |
| 27 | 28 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 41 // - Mac uses the MessageCenterDisplayService by default, but can use the | 42 // - Mac uses the MessageCenterDisplayService by default, but can use the |
| 42 // NativeNotificationDisplayService by using the chrome://flags or via | 43 // NativeNotificationDisplayService by using the chrome://flags or via |
| 43 // the --enable-features=NativeNotifications command line flag. | 44 // the --enable-features=NativeNotifications command line flag. |
| 44 // - All other platforms always use the MessageCenterDisplayService. | 45 // - All other platforms always use the MessageCenterDisplayService. |
| 45 KeyedService* NotificationDisplayServiceFactory::BuildServiceInstanceFor( | 46 KeyedService* NotificationDisplayServiceFactory::BuildServiceInstanceFor( |
| 46 content::BrowserContext* context) const { | 47 content::BrowserContext* context) const { |
| 47 #if defined(OS_ANDROID) | 48 #if defined(OS_ANDROID) |
| 48 return new NativeNotificationDisplayService( | 49 return new NativeNotificationDisplayService( |
| 49 Profile::FromBrowserContext(context), | 50 Profile::FromBrowserContext(context), |
| 50 g_browser_process->notification_platform_bridge()); | 51 g_browser_process->notification_platform_bridge()); |
| 51 #elif defined(OS_MACOSX) | 52 #elif defined(OS_MACOSX) || (defined(OS_LINUX) && !defined(OS_CHROMEOS)) |
| 52 if (base::FeatureList::IsEnabled(features::kNativeNotifications)) { | 53 if (base::FeatureList::IsEnabled(features::kNativeNotifications) && |
| 54 g_browser_process->notification_platform_bridge()) { | |
| 53 return new NativeNotificationDisplayService( | 55 return new NativeNotificationDisplayService( |
| 54 Profile::FromBrowserContext(context), | 56 Profile::FromBrowserContext(context), |
| 55 g_browser_process->notification_platform_bridge()); | 57 g_browser_process->notification_platform_bridge()); |
| 56 } | 58 } |
| 57 #endif | 59 #endif |
| 58 return new MessageCenterDisplayService( | 60 return new MessageCenterDisplayService( |
| 59 Profile::FromBrowserContext(context), | 61 Profile::FromBrowserContext(context), |
| 60 g_browser_process->notification_ui_manager()); | 62 g_browser_process->notification_ui_manager()); |
| 61 } | 63 } |
| 62 | 64 |
| 63 content::BrowserContext* | 65 content::BrowserContext* |
| 64 NotificationDisplayServiceFactory::GetBrowserContextToUse( | 66 NotificationDisplayServiceFactory::GetBrowserContextToUse( |
| 65 content::BrowserContext* context) const { | 67 content::BrowserContext* context) const { |
| 66 return chrome::GetBrowserContextOwnInstanceInIncognito(context); | 68 return chrome::GetBrowserContextOwnInstanceInIncognito(context); |
| 67 } | 69 } |
| OLD | NEW |