| 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/services/gcm/gcm_profile_service_factory.h" | 5 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
| 6 | 6 |
| 7 #include "chrome/browser/profiles/incognito_helpers.h" | 7 #include "chrome/browser/profiles/incognito_helpers.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/services/gcm/gcm_profile_service.h" | 9 #include "chrome/browser/services/gcm/gcm_profile_service.h" |
| 10 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" | 10 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" |
| 11 | 11 |
| 12 namespace gcm { | 12 namespace gcm { |
| 13 | 13 |
| 14 // static | 14 // static |
| 15 GCMProfileService* GCMProfileServiceFactory::GetForProfile(Profile* profile) { | 15 GCMProfileService* GCMProfileServiceFactory::GetForProfile(Profile* profile) { |
| 16 if (!gcm::GCMProfileService::IsGCMEnabled()) | 16 if (!gcm::GCMProfileService::IsGCMEnabled(profile)) |
| 17 return NULL; | 17 return NULL; |
| 18 | 18 |
| 19 return static_cast<GCMProfileService*>( | 19 return static_cast<GCMProfileService*>( |
| 20 GetInstance()->GetServiceForBrowserContext(profile, true)); | 20 GetInstance()->GetServiceForBrowserContext(profile, true)); |
| 21 } | 21 } |
| 22 | 22 |
| 23 // static | 23 // static |
| 24 GCMProfileServiceFactory* GCMProfileServiceFactory::GetInstance() { | 24 GCMProfileServiceFactory* GCMProfileServiceFactory::GetInstance() { |
| 25 return Singleton<GCMProfileServiceFactory>::get(); | 25 return Singleton<GCMProfileServiceFactory>::get(); |
| 26 } | 26 } |
| 27 | 27 |
| 28 GCMProfileServiceFactory::GCMProfileServiceFactory() | 28 GCMProfileServiceFactory::GCMProfileServiceFactory() |
| 29 : BrowserContextKeyedServiceFactory( | 29 : BrowserContextKeyedServiceFactory( |
| 30 "GCMProfileService", | 30 "GCMProfileService", |
| 31 BrowserContextDependencyManager::GetInstance()) { | 31 BrowserContextDependencyManager::GetInstance()) { |
| 32 } | 32 } |
| 33 | 33 |
| 34 GCMProfileServiceFactory::~GCMProfileServiceFactory() { | 34 GCMProfileServiceFactory::~GCMProfileServiceFactory() { |
| 35 } | 35 } |
| 36 | 36 |
| 37 BrowserContextKeyedService* GCMProfileServiceFactory::BuildServiceInstanceFor( | 37 BrowserContextKeyedService* GCMProfileServiceFactory::BuildServiceInstanceFor( |
| 38 content::BrowserContext* profile) const { | 38 content::BrowserContext* context) const { |
| 39 return gcm::GCMProfileService::IsGCMEnabled() ? | 39 Profile* profile = static_cast<Profile*>(context); |
| 40 new GCMProfileService(static_cast<Profile*>(profile)) : NULL; | 40 return gcm::GCMProfileService::IsGCMEnabled(profile) ? |
| 41 new GCMProfileService(profile) : NULL; |
| 41 } | 42 } |
| 42 | 43 |
| 43 content::BrowserContext* GCMProfileServiceFactory::GetBrowserContextToUse( | 44 content::BrowserContext* GCMProfileServiceFactory::GetBrowserContextToUse( |
| 44 content::BrowserContext* context) const { | 45 content::BrowserContext* context) const { |
| 45 return chrome::GetBrowserContextOwnInstanceInIncognito(context); | 46 return chrome::GetBrowserContextOwnInstanceInIncognito(context); |
| 46 } | 47 } |
| 47 | 48 |
| 48 } // namespace gcm | 49 } // namespace gcm |
| OLD | NEW |