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.
5 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h"
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_manager.h"
15 GCMProfileService
* GCMProfileServiceFactory::GetForProfile(Profile
* profile
) {
16 if (!gcm::GCMProfileService::IsGCMEnabled(profile
))
19 return static_cast<GCMProfileService
*>(
20 GetInstance()->GetServiceForBrowserContext(profile
, true));
24 GCMProfileServiceFactory
* GCMProfileServiceFactory::GetInstance() {
25 return Singleton
<GCMProfileServiceFactory
>::get();
28 GCMProfileServiceFactory::GCMProfileServiceFactory()
29 : BrowserContextKeyedServiceFactory(
31 BrowserContextDependencyManager::GetInstance()) {
34 GCMProfileServiceFactory::~GCMProfileServiceFactory() {
37 BrowserContextKeyedService
* GCMProfileServiceFactory::BuildServiceInstanceFor(
38 content::BrowserContext
* context
) const {
39 Profile
* profile
= static_cast<Profile
*>(context
);
40 return gcm::GCMProfileService::IsGCMEnabled(profile
) ?
41 new GCMProfileService(profile
) : NULL
;
44 content::BrowserContext
* GCMProfileServiceFactory::GetBrowserContextToUse(
45 content::BrowserContext
* context
) const {
46 return chrome::GetBrowserContextOwnInstanceInIncognito(context
);