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

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

Issue 218903005: Make push messaging not create InvalidationService for login and guest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make code resilient against tests that do not create the Default profile first. 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/prefs/pref_registry.h" 7 #include "base/prefs/pref_registry.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/invalidation/fake_invalidation_service.h" 9 #include "chrome/browser/invalidation/fake_invalidation_service.h"
10 #include "chrome/browser/invalidation/invalidation_service.h" 10 #include "chrome/browser/invalidation/invalidation_service.h"
(...skipping 10 matching lines...) Expand all
21 #include "components/keyed_service/content/browser_context_dependency_manager.h" 21 #include "components/keyed_service/content/browser_context_dependency_manager.h"
22 #include "components/signin/core/browser/profile_oauth2_token_service.h" 22 #include "components/signin/core/browser/profile_oauth2_token_service.h"
23 #include "components/signin/core/browser/signin_manager.h" 23 #include "components/signin/core/browser/signin_manager.h"
24 #include "components/user_prefs/pref_registry_syncable.h" 24 #include "components/user_prefs/pref_registry_syncable.h"
25 25
26 #if defined(OS_ANDROID) 26 #if defined(OS_ANDROID)
27 #include "chrome/browser/invalidation/invalidation_controller_android.h" 27 #include "chrome/browser/invalidation/invalidation_controller_android.h"
28 #endif // defined(OS_ANDROID) 28 #endif // defined(OS_ANDROID)
29 29
30 #if defined(OS_CHROMEOS) 30 #if defined(OS_CHROMEOS)
31 #include "base/files/file_path.h"
31 #include "chrome/browser/chromeos/login/user_manager.h" 32 #include "chrome/browser/chromeos/login/user_manager.h"
32 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 33 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
34 #include "chrome/browser/chromeos/profiles/profile_helper.h"
33 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h " 35 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h "
34 #include "chrome/browser/invalidation/device_invalidation_auth_provider_chromeos .h" 36 #include "chrome/browser/invalidation/device_invalidation_auth_provider_chromeos .h"
35 #endif 37 #endif
36 38
37 namespace invalidation { 39 namespace invalidation {
38 40
39 // static 41 // static
40 InvalidationService* InvalidationServiceFactory::GetForProfile( 42 InvalidationService* InvalidationServiceFactory::GetForProfile(
41 Profile* profile) { 43 Profile* profile) {
44 #if defined(OS_CHROMEOS)
45 // Using ProfileHelper::GetSigninProfile() here would lead to an infinite loop
46 // when this method is called during the creation of the sign-in profile
47 // itself. Using ProfileHelper::GetSigninProfileDir() is safe because it does
48 // not try to access the sign-in profile.
49 if (profile->GetPath() == chromeos::ProfileHelper::GetSigninProfileDir()||
50 (chromeos::UserManager::IsInitialized() &&
51 chromeos::UserManager::Get()->IsLoggedInAsGuest())) {
52 // The Chrome OS login and Chrome OS guest profiles do not have GAIA
53 // credentials and do not support invalidation.
54 return NULL;
55 }
56 #endif
42 return static_cast<InvalidationService*>( 57 return static_cast<InvalidationService*>(
43 GetInstance()->GetServiceForBrowserContext(profile, true)); 58 GetInstance()->GetServiceForBrowserContext(profile, true));
44 } 59 }
45 60
46 // static 61 // static
47 InvalidationServiceFactory* InvalidationServiceFactory::GetInstance() { 62 InvalidationServiceFactory* InvalidationServiceFactory::GetInstance() {
48 return Singleton<InvalidationServiceFactory>::get(); 63 return Singleton<InvalidationServiceFactory>::get();
49 } 64 }
50 65
51 InvalidationServiceFactory::InvalidationServiceFactory() 66 InvalidationServiceFactory::InvalidationServiceFactory()
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 void InvalidationServiceFactory::RegisterProfilePrefs( 125 void InvalidationServiceFactory::RegisterProfilePrefs(
111 user_prefs::PrefRegistrySyncable* registry) { 126 user_prefs::PrefRegistrySyncable* registry) {
112 registry->RegisterBooleanPref( 127 registry->RegisterBooleanPref(
113 prefs::kInvalidationServiceUseGCMChannel, 128 prefs::kInvalidationServiceUseGCMChannel,
114 false, 129 false,
115 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 130 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
116 InvalidatorStorage::RegisterProfilePrefs(registry); 131 InvalidatorStorage::RegisterProfilePrefs(registry);
117 } 132 }
118 133
119 } // namespace invalidation 134 } // namespace invalidation
OLDNEW
« no previous file with comments | « chrome/browser/invalidation/invalidation_service_factory.h ('k') | chrome/browser/sync/glue/sync_backend_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698