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

Side by Side Diff: chrome/browser/invalidation/invalidation_service_factory.cc

Issue 255443005: Remove Profile dependency from TiclInvalidationService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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/invalidation/invalidation_service_factory.h" 5 #include "chrome/browser/invalidation/invalidation_service_factory.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/prefs/pref_registry.h" 8 #include "base/prefs/pref_registry.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/invalidation/fake_invalidation_service.h" 10 #include "chrome/browser/invalidation/fake_invalidation_service.h"
11 #include "chrome/browser/invalidation/invalidation_service.h" 11 #include "chrome/browser/invalidation/invalidation_service.h"
12 #include "chrome/browser/invalidation/invalidation_service_android.h" 12 #include "chrome/browser/invalidation/invalidation_service_android.h"
13 #include "chrome/browser/invalidation/invalidator_storage.h" 13 #include "chrome/browser/invalidation/invalidator_storage.h"
14 #include "chrome/browser/invalidation/ticl_invalidation_service.h" 14 #include "chrome/browser/invalidation/ticl_invalidation_service.h"
15 #include "chrome/browser/invalidation/ticl_invalidation_service_profile_settings _provider.h"
16 #include "chrome/browser/invalidation/ticl_invalidation_service_settings_provide r.h"
15 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/services/gcm/gcm_profile_service.h" 18 #include "chrome/browser/services/gcm/gcm_profile_service.h"
17 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" 19 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h"
18 #include "chrome/browser/signin/profile_identity_provider.h" 20 #include "chrome/browser/signin/profile_identity_provider.h"
19 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 21 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
20 #include "chrome/browser/signin/signin_manager_factory.h" 22 #include "chrome/browser/signin/signin_manager_factory.h"
21 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" 23 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
22 #include "chrome/common/pref_names.h" 24 #include "chrome/common/pref_names.h"
23 #include "components/keyed_service/content/browser_context_dependency_manager.h" 25 #include "components/keyed_service/content/browser_context_dependency_manager.h"
24 #include "components/signin/core/browser/profile_oauth2_token_service.h" 26 #include "components/signin/core/browser/profile_oauth2_token_service.h"
(...skipping 26 matching lines...) Expand all
51 // itself. Using ProfileHelper::GetSigninProfileDir() is safe because it does 53 // itself. Using ProfileHelper::GetSigninProfileDir() is safe because it does
52 // not try to access the sign-in profile. 54 // not try to access the sign-in profile.
53 if (profile->GetPath() == chromeos::ProfileHelper::GetSigninProfileDir()|| 55 if (profile->GetPath() == chromeos::ProfileHelper::GetSigninProfileDir()||
54 (chromeos::UserManager::IsInitialized() && 56 (chromeos::UserManager::IsInitialized() &&
55 chromeos::UserManager::Get()->IsLoggedInAsGuest())) { 57 chromeos::UserManager::Get()->IsLoggedInAsGuest())) {
56 // The Chrome OS login and Chrome OS guest profiles do not have GAIA 58 // The Chrome OS login and Chrome OS guest profiles do not have GAIA
57 // credentials and do not support invalidation. 59 // credentials and do not support invalidation.
58 return NULL; 60 return NULL;
59 } 61 }
60 #endif 62 #endif
63 if (profile->IsManaged()) {
dcheng 2014/04/24 18:26:54 Nit: Not sure why this is needed in this CL. Is th
bartfab (slow) 2014/04/24 19:14:48 This was previously handled by TiclInvalidationSer
64 // Managed profiles do not have GAIA credentials and do not support
65 // invalidation.
66 return NULL;
67 }
68
61 return static_cast<InvalidationService*>( 69 return static_cast<InvalidationService*>(
62 GetInstance()->GetServiceForBrowserContext(profile, true)); 70 GetInstance()->GetServiceForBrowserContext(profile, true));
63 } 71 }
64 72
65 // static 73 // static
66 InvalidationServiceFactory* InvalidationServiceFactory::GetInstance() { 74 InvalidationServiceFactory* InvalidationServiceFactory::GetInstance() {
67 return Singleton<InvalidationServiceFactory>::get(); 75 return Singleton<InvalidationServiceFactory>::get();
68 } 76 }
69 77
70 InvalidationServiceFactory::InvalidationServiceFactory() 78 InvalidationServiceFactory::InvalidationServiceFactory()
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 122
115 if (!identity_provider) { 123 if (!identity_provider) {
116 identity_provider.reset(new ProfileIdentityProvider( 124 identity_provider.reset(new ProfileIdentityProvider(
117 SigninManagerFactory::GetForProfile(profile), 125 SigninManagerFactory::GetForProfile(profile),
118 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), 126 ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
119 LoginUIServiceFactory::GetForProfile(profile))); 127 LoginUIServiceFactory::GetForProfile(profile)));
120 } 128 }
121 129
122 TiclInvalidationService* service = new TiclInvalidationService( 130 TiclInvalidationService* service = new TiclInvalidationService(
123 identity_provider.Pass(), 131 identity_provider.Pass(),
132 scoped_ptr<TiclInvalidationServiceSettingsProvider>(
133 new TiclInvalidationServiceProfileSettingsProvider(profile)),
124 gcm::GCMProfileServiceFactory::GetForProfile(profile), 134 gcm::GCMProfileServiceFactory::GetForProfile(profile),
125 profile->GetRequestContext(), 135 profile->GetRequestContext());
126 profile);
127 service->Init(scoped_ptr<syncer::InvalidationStateTracker>( 136 service->Init(scoped_ptr<syncer::InvalidationStateTracker>(
128 new InvalidatorStorage(profile->GetPrefs()))); 137 new InvalidatorStorage(profile->GetPrefs())));
129 return service; 138 return service;
130 #endif 139 #endif
131 } 140 }
132 141
133 void InvalidationServiceFactory::RegisterProfilePrefs( 142 void InvalidationServiceFactory::RegisterProfilePrefs(
134 user_prefs::PrefRegistrySyncable* registry) { 143 user_prefs::PrefRegistrySyncable* registry) {
135 registry->RegisterBooleanPref( 144 registry->RegisterBooleanPref(
136 prefs::kInvalidationServiceUseGCMChannel, 145 prefs::kInvalidationServiceUseGCMChannel,
137 false, 146 false,
138 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 147 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
139 InvalidatorStorage::RegisterProfilePrefs(registry); 148 InvalidatorStorage::RegisterProfilePrefs(registry);
140 } 149 }
141 150
142 } // namespace invalidation 151 } // namespace invalidation
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698