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 | |
99 if (testing_factory_) | 97 if (testing_factory_) |
100 return testing_factory_(context); | 98 return testing_factory_(context); |
101 | 99 |
102 #if defined(OS_ANDROID) | 100 #if defined(OS_ANDROID) |
103 return new ProfileInvalidationProvider(scoped_ptr<InvalidationService>( | 101 return new ProfileInvalidationProvider(scoped_ptr<InvalidationService>( |
104 new InvalidationServiceAndroid(profile, | 102 new InvalidationServiceAndroid(base::android::GetApplicationContext()))); |
105 new InvalidationControllerAndroid()))); | |
106 #else | 103 #else |
107 | 104 |
108 scoped_ptr<IdentityProvider> identity_provider; | 105 scoped_ptr<IdentityProvider> identity_provider; |
109 | 106 |
110 #if defined(OS_CHROMEOS) | 107 #if defined(OS_CHROMEOS) |
111 policy::BrowserPolicyConnectorChromeOS* connector = | 108 policy::BrowserPolicyConnectorChromeOS* connector = |
112 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 109 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
113 if (user_manager::UserManager::IsInitialized() && | 110 if (user_manager::UserManager::IsInitialized() && |
114 user_manager::UserManager::Get()->IsLoggedInAsKioskApp() && | 111 user_manager::UserManager::Get()->IsLoggedInAsKioskApp() && |
115 connector->IsEnterpriseManaged()) { | 112 connector->IsEnterpriseManaged()) { |
116 identity_provider.reset(new chromeos::DeviceIdentityProvider( | 113 identity_provider.reset(new chromeos::DeviceIdentityProvider( |
117 chromeos::DeviceOAuth2TokenServiceFactory::Get())); | 114 chromeos::DeviceOAuth2TokenServiceFactory::Get())); |
118 } | 115 } |
119 #endif | 116 #endif |
117 Profile* profile = static_cast<Profile*>(context); | |
Lei Zhang
2014/09/17 00:26:20
nit: (I know this is just cut+paste) you can use P
maxbogue
2014/09/17 00:57:20
Done.
| |
120 | 118 |
121 if (!identity_provider) { | 119 if (!identity_provider) { |
122 identity_provider.reset(new ProfileIdentityProvider( | 120 identity_provider.reset(new ProfileIdentityProvider( |
123 SigninManagerFactory::GetForProfile(profile), | 121 SigninManagerFactory::GetForProfile(profile), |
124 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), | 122 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), |
125 LoginUIServiceFactory::GetForProfile(profile))); | 123 LoginUIServiceFactory::GetForProfile(profile))); |
126 } | 124 } |
127 | 125 |
128 scoped_ptr<TiclInvalidationService> service(new TiclInvalidationService( | 126 scoped_ptr<TiclInvalidationService> service(new TiclInvalidationService( |
129 GetUserAgent(), | 127 GetUserAgent(), |
(...skipping 12 matching lines...) Expand all Loading... | |
142 void ProfileInvalidationProviderFactory::RegisterProfilePrefs( | 140 void ProfileInvalidationProviderFactory::RegisterProfilePrefs( |
143 user_prefs::PrefRegistrySyncable* registry) { | 141 user_prefs::PrefRegistrySyncable* registry) { |
144 registry->RegisterBooleanPref( | 142 registry->RegisterBooleanPref( |
145 prefs::kInvalidationServiceUseGCMChannel, | 143 prefs::kInvalidationServiceUseGCMChannel, |
146 false, | 144 false, |
147 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 145 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
148 InvalidatorStorage::RegisterProfilePrefs(registry); | 146 InvalidatorStorage::RegisterProfilePrefs(registry); |
149 } | 147 } |
150 | 148 |
151 } // namespace invalidation | 149 } // namespace invalidation |
OLD | NEW |