OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/profile_invalidation_provider_factory.h" | 5 #include "chrome/browser/invalidation/profile_invalidation_provider_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/ticl_profile_settings_provider.h" | 10 #include "chrome/browser/invalidation/ticl_profile_settings_provider.h" |
(...skipping 12 matching lines...) Expand all Loading... | |
23 #include "components/invalidation/profile_invalidation_provider.h" | 23 #include "components/invalidation/profile_invalidation_provider.h" |
24 #include "components/invalidation/ticl_invalidation_service.h" | 24 #include "components/invalidation/ticl_invalidation_service.h" |
25 #include "components/invalidation/ticl_settings_provider.h" | 25 #include "components/invalidation/ticl_settings_provider.h" |
26 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 26 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
27 #include "components/pref_registry/pref_registry_syncable.h" | 27 #include "components/pref_registry/pref_registry_syncable.h" |
28 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 28 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
29 #include "components/signin/core/browser/signin_manager.h" | 29 #include "components/signin/core/browser/signin_manager.h" |
30 #include "net/url_request/url_request_context_getter.h" | 30 #include "net/url_request/url_request_context_getter.h" |
31 | 31 |
32 #if defined(OS_ANDROID) | 32 #if defined(OS_ANDROID) |
33 #include "chrome/browser/invalidation/invalidation_controller_android.h" | 33 #include "base/android/jni_android.h" |
34 #include "chrome/browser/invalidation/invalidation_service_android.h" | 34 #include "components/invalidation/invalidation_service_android.h" |
35 #endif // defined(OS_ANDROID) | 35 #endif // defined(OS_ANDROID) |
36 | 36 |
37 #if defined(OS_CHROMEOS) | 37 #if defined(OS_CHROMEOS) |
38 #include "base/files/file_path.h" | 38 #include "base/files/file_path.h" |
39 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 39 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
40 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 40 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
41 #include "chrome/browser/chromeos/settings/device_identity_provider.h" | 41 #include "chrome/browser/chromeos/settings/device_identity_provider.h" |
42 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h " | 42 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h " |
43 #include "components/user_manager/user_manager.h" | 43 #include "components/user_manager/user_manager.h" |
44 #endif | 44 #endif |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 ProfileInvalidationProviderFactory::~ProfileInvalidationProviderFactory() { | 87 ProfileInvalidationProviderFactory::~ProfileInvalidationProviderFactory() { |
88 } | 88 } |
89 | 89 |
90 void ProfileInvalidationProviderFactory::RegisterTestingFactory( | 90 void ProfileInvalidationProviderFactory::RegisterTestingFactory( |
91 TestingFactoryFunction testing_factory) { | 91 TestingFactoryFunction testing_factory) { |
92 testing_factory_ = testing_factory; | 92 testing_factory_ = testing_factory; |
93 } | 93 } |
94 | 94 |
95 KeyedService* ProfileInvalidationProviderFactory::BuildServiceInstanceFor( | 95 KeyedService* ProfileInvalidationProviderFactory::BuildServiceInstanceFor( |
96 content::BrowserContext* context) const { | 96 content::BrowserContext* context) const { |
97 Profile* profile = static_cast<Profile*>(context); | |
98 | 97 |
nyquist
2014/09/04 09:01:56
Nit: remove empty line
maxbogue
2014/09/05 16:42:45
Done.
| |
99 if (testing_factory_) | 98 if (testing_factory_) |
100 return testing_factory_(context); | 99 return testing_factory_(context); |
101 | 100 |
102 #if defined(OS_ANDROID) | 101 #if defined(OS_ANDROID) |
103 return new ProfileInvalidationProvider(scoped_ptr<InvalidationService>( | 102 return new ProfileInvalidationProvider(scoped_ptr<InvalidationService>( |
104 new InvalidationServiceAndroid(profile, | 103 new InvalidationServiceAndroid(base::android::GetApplicationContext()))); |
105 new InvalidationControllerAndroid()))); | |
106 #else | 104 #else |
107 | 105 |
108 scoped_ptr<IdentityProvider> identity_provider; | 106 scoped_ptr<IdentityProvider> identity_provider; |
109 | 107 |
110 #if defined(OS_CHROMEOS) | 108 #if defined(OS_CHROMEOS) |
111 policy::BrowserPolicyConnectorChromeOS* connector = | 109 policy::BrowserPolicyConnectorChromeOS* connector = |
112 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 110 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
113 if (user_manager::UserManager::IsInitialized() && | 111 if (user_manager::UserManager::IsInitialized() && |
114 user_manager::UserManager::Get()->IsLoggedInAsKioskApp() && | 112 user_manager::UserManager::Get()->IsLoggedInAsKioskApp() && |
115 connector->IsEnterpriseManaged()) { | 113 connector->IsEnterpriseManaged()) { |
116 identity_provider.reset(new chromeos::DeviceIdentityProvider( | 114 identity_provider.reset(new chromeos::DeviceIdentityProvider( |
117 chromeos::DeviceOAuth2TokenServiceFactory::Get())); | 115 chromeos::DeviceOAuth2TokenServiceFactory::Get())); |
118 } | 116 } |
119 #endif | 117 #endif |
118 Profile* profile = static_cast<Profile*>(context); | |
120 | 119 |
121 if (!identity_provider) { | 120 if (!identity_provider) { |
122 identity_provider.reset(new ProfileIdentityProvider( | 121 identity_provider.reset(new ProfileIdentityProvider( |
123 SigninManagerFactory::GetForProfile(profile), | 122 SigninManagerFactory::GetForProfile(profile), |
124 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), | 123 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), |
125 LoginUIServiceFactory::GetForProfile(profile))); | 124 LoginUIServiceFactory::GetForProfile(profile))); |
126 } | 125 } |
127 | 126 |
128 scoped_ptr<TiclInvalidationService> service(new TiclInvalidationService( | 127 scoped_ptr<TiclInvalidationService> service(new TiclInvalidationService( |
129 GetUserAgent(), | 128 GetUserAgent(), |
(...skipping 12 matching lines...) Expand all Loading... | |
142 void ProfileInvalidationProviderFactory::RegisterProfilePrefs( | 141 void ProfileInvalidationProviderFactory::RegisterProfilePrefs( |
143 user_prefs::PrefRegistrySyncable* registry) { | 142 user_prefs::PrefRegistrySyncable* registry) { |
144 registry->RegisterBooleanPref( | 143 registry->RegisterBooleanPref( |
145 prefs::kInvalidationServiceUseGCMChannel, | 144 prefs::kInvalidationServiceUseGCMChannel, |
146 false, | 145 false, |
147 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 146 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
148 InvalidatorStorage::RegisterProfilePrefs(registry); | 147 InvalidatorStorage::RegisterProfilePrefs(registry); |
149 } | 148 } |
150 | 149 |
151 } // namespace invalidation | 150 } // namespace invalidation |
OLD | NEW |