OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/sync_notifier/chrome_notifier_service_fac
tory.h" | 5 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_fac
tory.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h" | 9 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h" |
| 10 #include "chrome/browser/notifications/sync_notifier/synced_notification_app_inf
o_service_factory.h" |
10 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
11 #include "chrome/common/chrome_version_info.h" | 12 #include "chrome/common/chrome_version_info.h" |
12 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" | 13 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" |
13 | 14 |
14 namespace notifier { | 15 namespace notifier { |
15 | 16 |
16 // static | 17 // static |
17 ChromeNotifierService* ChromeNotifierServiceFactory::GetForProfile( | 18 ChromeNotifierService* ChromeNotifierServiceFactory::GetForProfile( |
18 Profile* profile, Profile::ServiceAccessType service_access_type) { | 19 Profile* profile, Profile::ServiceAccessType service_access_type) { |
19 return static_cast<ChromeNotifierService*>( | 20 return static_cast<ChromeNotifierService*>( |
(...skipping 18 matching lines...) Expand all Loading... |
38 if (channel == chrome::VersionInfo::CHANNEL_UNKNOWN || | 39 if (channel == chrome::VersionInfo::CHANNEL_UNKNOWN || |
39 channel == chrome::VersionInfo::CHANNEL_DEV || | 40 channel == chrome::VersionInfo::CHANNEL_DEV || |
40 channel == chrome::VersionInfo::CHANNEL_CANARY) | 41 channel == chrome::VersionInfo::CHANNEL_CANARY) |
41 return true; | 42 return true; |
42 | 43 |
43 return false; | 44 return false; |
44 } | 45 } |
45 | 46 |
46 ChromeNotifierServiceFactory::ChromeNotifierServiceFactory() | 47 ChromeNotifierServiceFactory::ChromeNotifierServiceFactory() |
47 : BrowserContextKeyedServiceFactory( | 48 : BrowserContextKeyedServiceFactory( |
48 "ChromeNotifierService", | 49 "ChromeNotifierService", |
49 BrowserContextDependencyManager::GetInstance()) {} | 50 BrowserContextDependencyManager::GetInstance()) { |
| 51 // Mark this service as depending on the SyncedNotificationAppInfoService. |
| 52 // Marking it provides a guarantee that the other service will alwasys be |
| 53 // running whenever the ChromeNotifierServiceFactory is. |
| 54 DependsOn(SyncedNotificationAppInfoServiceFactory::GetInstance()); |
| 55 } |
50 | 56 |
51 ChromeNotifierServiceFactory::~ChromeNotifierServiceFactory() { | 57 ChromeNotifierServiceFactory::~ChromeNotifierServiceFactory() { |
52 } | 58 } |
53 | 59 |
54 BrowserContextKeyedService* | 60 BrowserContextKeyedService* |
55 ChromeNotifierServiceFactory::BuildServiceInstanceFor( | 61 ChromeNotifierServiceFactory::BuildServiceInstanceFor( |
56 content::BrowserContext* profile) const { | 62 content::BrowserContext* profile) const { |
57 NotificationUIManager* notification_manager = | 63 NotificationUIManager* notification_manager = |
58 g_browser_process->notification_ui_manager(); | 64 g_browser_process->notification_ui_manager(); |
59 ChromeNotifierService* chrome_notifier_service = | 65 ChromeNotifierService* chrome_notifier_service = |
60 new ChromeNotifierService(static_cast<Profile*>(profile), | 66 new ChromeNotifierService(static_cast<Profile*>(profile), |
61 notification_manager); | 67 notification_manager); |
62 return chrome_notifier_service; | 68 return chrome_notifier_service; |
63 } | 69 } |
64 | 70 |
65 } // namespace notifier | 71 } // namespace notifier |
OLD | NEW |