| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/desktop_notification_service_factory.h" | 5 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
| 6 | 6 |
| 7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
| 8 #include "chrome/browser/notifications/desktop_notification_service.h" | 8 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 9 #include "chrome/browser/profiles/incognito_helpers.h" | 9 #include "chrome/browser/profiles/incognito_helpers.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" | 11 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" |
| 12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 13 | 13 |
| 14 using content::BrowserThread; | 14 using content::BrowserThread; |
| 15 | 15 |
| 16 // static | 16 // static |
| 17 DesktopNotificationService* DesktopNotificationServiceFactory::GetForProfile( | 17 DesktopNotificationService* DesktopNotificationServiceFactory::GetForProfile( |
| 18 Profile* profile) { | 18 Profile* profile) { |
| 19 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 19 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 20 return static_cast<DesktopNotificationService*>( | 20 return static_cast<DesktopNotificationService*>( |
| 21 GetInstance()->GetServiceForProfile(profile, true)); | 21 GetInstance()->GetServiceForBrowserContext(profile, true)); |
| 22 } | 22 } |
| 23 | 23 |
| 24 // static | 24 // static |
| 25 DesktopNotificationServiceFactory* DesktopNotificationServiceFactory:: | 25 DesktopNotificationServiceFactory* DesktopNotificationServiceFactory:: |
| 26 GetInstance() { | 26 GetInstance() { |
| 27 return Singleton<DesktopNotificationServiceFactory>::get(); | 27 return Singleton<DesktopNotificationServiceFactory>::get(); |
| 28 } | 28 } |
| 29 | 29 |
| 30 DesktopNotificationServiceFactory::DesktopNotificationServiceFactory() | 30 DesktopNotificationServiceFactory::DesktopNotificationServiceFactory() |
| 31 : ProfileKeyedServiceFactory("DesktopNotificationService", | 31 : BrowserContextKeyedServiceFactory("DesktopNotificationService", |
| 32 ProfileDependencyManager::GetInstance()) { | 32 BrowserContextDependencyManager::GetInstance())
{ |
| 33 } | 33 } |
| 34 | 34 |
| 35 DesktopNotificationServiceFactory::~DesktopNotificationServiceFactory() { | 35 DesktopNotificationServiceFactory::~DesktopNotificationServiceFactory() { |
| 36 } | 36 } |
| 37 | 37 |
| 38 ProfileKeyedService* DesktopNotificationServiceFactory::BuildServiceInstanceFor( | 38 BrowserContextKeyedService* DesktopNotificationServiceFactory::BuildServiceInsta
nceFor( |
| 39 content::BrowserContext* profile) const { | 39 content::BrowserContext* profile) const { |
| 40 DesktopNotificationService* service = | 40 DesktopNotificationService* service = |
| 41 new DesktopNotificationService(static_cast<Profile*>(profile), NULL); | 41 new DesktopNotificationService(static_cast<Profile*>(profile), NULL); |
| 42 return service; | 42 return service; |
| 43 } | 43 } |
| 44 | 44 |
| 45 content::BrowserContext* | 45 content::BrowserContext* |
| 46 DesktopNotificationServiceFactory::GetBrowserContextToUse( | 46 DesktopNotificationServiceFactory::GetBrowserContextToUse( |
| 47 content::BrowserContext* context) const { | 47 content::BrowserContext* context) const { |
| 48 return chrome::GetBrowserContextOwnInstanceInIncognito(context); | 48 return chrome::GetBrowserContextOwnInstanceInIncognito(context); |
| 49 } | 49 } |
| OLD | NEW |