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

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

Issue 2528013002: Initialize the message center as part of the testing browser process (Closed)
Patch Set: re-uploding due to time outs Created 4 years 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 27 matching lines...) Expand all
38 38
39 // Selection of the implementation works as follows: 39 // Selection of the implementation works as follows:
40 // - Android always uses the NativeNotificationDisplayService. 40 // - Android always uses the NativeNotificationDisplayService.
41 // - Mac uses the MessageCenterDisplayService by default, but can use the 41 // - Mac uses the MessageCenterDisplayService by default, but can use the
42 // NativeNotificationDisplayService by using the chrome://flags or via 42 // NativeNotificationDisplayService by using the chrome://flags or via
43 // the --enable-features=NativeNotifications command line flag. 43 // the --enable-features=NativeNotifications command line flag.
44 // - All other platforms always use the MessageCenterDisplayService. 44 // - All other platforms always use the MessageCenterDisplayService.
45 KeyedService* NotificationDisplayServiceFactory::BuildServiceInstanceFor( 45 KeyedService* NotificationDisplayServiceFactory::BuildServiceInstanceFor(
46 content::BrowserContext* context) const { 46 content::BrowserContext* context) const {
47 #if defined(OS_ANDROID) 47 #if defined(OS_ANDROID)
48 if (!g_browser_process->notification_platform_bridge()) {
49 DCHECK(Profile::FromBrowserContext(context)->AsTestingProfile());
50 return nullptr;
51 }
48 return new NativeNotificationDisplayService( 52 return new NativeNotificationDisplayService(
49 Profile::FromBrowserContext(context), 53 Profile::FromBrowserContext(context),
50 g_browser_process->notification_platform_bridge()); 54 g_browser_process->notification_platform_bridge());
51 #elif defined(OS_MACOSX) 55 #elif defined(OS_MACOSX)
52 if (base::FeatureList::IsEnabled(features::kNativeNotifications)) { 56 if (base::FeatureList::IsEnabled(features::kNativeNotifications)) {
53 return new NativeNotificationDisplayService( 57 return new NativeNotificationDisplayService(
54 Profile::FromBrowserContext(context), 58 Profile::FromBrowserContext(context),
55 g_browser_process->notification_platform_bridge()); 59 g_browser_process->notification_platform_bridge());
56 } 60 }
57 #endif 61 #endif
62 if (!g_browser_process->notification_ui_manager()) {
63 DCHECK(Profile::FromBrowserContext(context)->AsTestingProfile());
64 return nullptr;
65 }
58 return new MessageCenterDisplayService( 66 return new MessageCenterDisplayService(
59 Profile::FromBrowserContext(context), 67 Profile::FromBrowserContext(context),
60 g_browser_process->notification_ui_manager()); 68 g_browser_process->notification_ui_manager());
61 } 69 }
62 70
63 content::BrowserContext* 71 content::BrowserContext*
64 NotificationDisplayServiceFactory::GetBrowserContextToUse( 72 NotificationDisplayServiceFactory::GetBrowserContextToUse(
65 content::BrowserContext* context) const { 73 content::BrowserContext* context) const {
66 return chrome::GetBrowserContextOwnInstanceInIncognito(context); 74 return chrome::GetBrowserContextOwnInstanceInIncognito(context);
67 } 75 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698