Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(358)

Side by Side Diff: chrome/browser/services/gcm/gcm_profile_service_factory.cc

Issue 225403021: Extract Profile-independent GCMService from GCMProfileService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Provide GCMService with the list of all accounts. It does use it after all. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/memory/scoped_ptr.h"
7 #include "chrome/browser/profiles/incognito_helpers.h" 8 #include "chrome/browser/profiles/incognito_helpers.h"
8 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/services/gcm/gcm_client_factory.h" 10 #include "chrome/browser/services/gcm/gcm_client_factory.h"
10 #include "chrome/browser/services/gcm/gcm_profile_service.h" 11 #include "chrome/browser/services/gcm/gcm_profile_service.h"
12 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
11 #include "chrome/browser/signin/signin_manager_factory.h" 13 #include "chrome/browser/signin/signin_manager_factory.h"
14 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
12 #include "components/keyed_service/content/browser_context_dependency_manager.h" 15 #include "components/keyed_service/content/browser_context_dependency_manager.h"
13 16
14 namespace gcm { 17 namespace gcm {
15 18
16 // static 19 // static
17 GCMProfileService* GCMProfileServiceFactory::GetForProfile(Profile* profile) { 20 GCMProfileService* GCMProfileServiceFactory::GetForProfile(Profile* profile) {
18 // GCM is not supported in incognito mode. 21 // GCM is not supported in incognito mode.
19 if (profile->IsOffTheRecord()) 22 if (profile->IsOffTheRecord())
20 return NULL; 23 return NULL;
21 24
22 return static_cast<GCMProfileService*>( 25 return static_cast<GCMProfileService*>(
23 GetInstance()->GetServiceForBrowserContext(profile, true)); 26 GetInstance()->GetServiceForBrowserContext(profile, true));
24 } 27 }
25 28
26 // static 29 // static
27 GCMProfileServiceFactory* GCMProfileServiceFactory::GetInstance() { 30 GCMProfileServiceFactory* GCMProfileServiceFactory::GetInstance() {
28 return Singleton<GCMProfileServiceFactory>::get(); 31 return Singleton<GCMProfileServiceFactory>::get();
29 } 32 }
30 33
31 GCMProfileServiceFactory::GCMProfileServiceFactory() 34 GCMProfileServiceFactory::GCMProfileServiceFactory()
32 : BrowserContextKeyedServiceFactory( 35 : BrowserContextKeyedServiceFactory(
33 "GCMProfileService", 36 "GCMProfileService",
34 BrowserContextDependencyManager::GetInstance()) { 37 BrowserContextDependencyManager::GetInstance()) {
35 DependsOn(SigninManagerFactory::GetInstance()); 38 DependsOn(SigninManagerFactory::GetInstance());
39 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance());
40 DependsOn(LoginUIServiceFactory::GetInstance());
36 } 41 }
37 42
38 GCMProfileServiceFactory::~GCMProfileServiceFactory() { 43 GCMProfileServiceFactory::~GCMProfileServiceFactory() {
39 } 44 }
40 45
41 KeyedService* GCMProfileServiceFactory::BuildServiceInstanceFor( 46 KeyedService* GCMProfileServiceFactory::BuildServiceInstanceFor(
42 content::BrowserContext* context) const { 47 content::BrowserContext* context) const {
43 Profile* profile = static_cast<Profile*>(context); 48 Profile* profile = static_cast<Profile*>(context);
44 GCMProfileService* service = new GCMProfileService(profile); 49 GCMProfileService* service = new GCMProfileService(profile);
45 scoped_ptr<GCMClientFactory> gcm_client_factory(new GCMClientFactory); 50 scoped_ptr<GCMClientFactory> gcm_client_factory(new GCMClientFactory);
46 service->Initialize(gcm_client_factory.Pass()); 51 service->Initialize(gcm_client_factory.Pass());
47 return service; 52 return service;
48 } 53 }
49 54
50 content::BrowserContext* GCMProfileServiceFactory::GetBrowserContextToUse( 55 content::BrowserContext* GCMProfileServiceFactory::GetBrowserContextToUse(
51 content::BrowserContext* context) const { 56 content::BrowserContext* context) const {
52 return chrome::GetBrowserContextOwnInstanceInIncognito(context); 57 return chrome::GetBrowserContextOwnInstanceInIncognito(context);
53 } 58 }
54 59
55 } // namespace gcm 60 } // namespace gcm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698