Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / services / gcm / gcm_profile_service_factory.cc
blob2724911ffdf7cf00e0b03d6ce3fcc54bde1b1a41
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"
12 namespace gcm {
14 // static
15 GCMProfileService* GCMProfileServiceFactory::GetForProfile(Profile* profile) {
16 if (!gcm::GCMProfileService::IsGCMEnabled(profile))
17 return NULL;
19 return static_cast<GCMProfileService*>(
20 GetInstance()->GetServiceForBrowserContext(profile, true));
23 // static
24 GCMProfileServiceFactory* GCMProfileServiceFactory::GetInstance() {
25 return Singleton<GCMProfileServiceFactory>::get();
28 GCMProfileServiceFactory::GCMProfileServiceFactory()
29 : BrowserContextKeyedServiceFactory(
30 "GCMProfileService",
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);
49 } // namespace gcm