| 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/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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |