| 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_client_factory.h" | 9 #include "chrome/browser/services/gcm/gcm_client_factory.h" |
| 10 #include "chrome/browser/services/gcm/gcm_profile_service.h" | 10 #include "chrome/browser/services/gcm/gcm_profile_service.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 "GCMProfileService", | 31 "GCMProfileService", |
| 32 BrowserContextDependencyManager::GetInstance()) { | 32 BrowserContextDependencyManager::GetInstance()) { |
| 33 } | 33 } |
| 34 | 34 |
| 35 GCMProfileServiceFactory::~GCMProfileServiceFactory() { | 35 GCMProfileServiceFactory::~GCMProfileServiceFactory() { |
| 36 } | 36 } |
| 37 | 37 |
| 38 BrowserContextKeyedService* GCMProfileServiceFactory::BuildServiceInstanceFor( | 38 BrowserContextKeyedService* GCMProfileServiceFactory::BuildServiceInstanceFor( |
| 39 content::BrowserContext* context) const { | 39 content::BrowserContext* context) const { |
| 40 Profile* profile = static_cast<Profile*>(context); | 40 Profile* profile = static_cast<Profile*>(context); |
| 41 if (!gcm::GCMProfileService::IsGCMEnabled(profile)) | |
| 42 return NULL; | |
| 43 GCMProfileService* service = new GCMProfileService(profile); | 41 GCMProfileService* service = new GCMProfileService(profile); |
| 44 scoped_ptr<GCMClientFactory> gcm_client_factory(new GCMClientFactory); | 42 scoped_ptr<GCMClientFactory> gcm_client_factory(new GCMClientFactory); |
| 45 service->Initialize(gcm_client_factory.Pass()); | 43 service->Initialize(gcm_client_factory.Pass()); |
| 46 return service; | 44 return service; |
| 47 } | 45 } |
| 48 | 46 |
| 49 content::BrowserContext* GCMProfileServiceFactory::GetBrowserContextToUse( | 47 content::BrowserContext* GCMProfileServiceFactory::GetBrowserContextToUse( |
| 50 content::BrowserContext* context) const { | 48 content::BrowserContext* context) const { |
| 51 return chrome::GetBrowserContextOwnInstanceInIncognito(context); | 49 return chrome::GetBrowserContextOwnInstanceInIncognito(context); |
| 52 } | 50 } |
| 53 | 51 |
| 54 } // namespace gcm | 52 } // namespace gcm |
| OLD | NEW |