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