OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/managed_mode/managed_user_registration_utility.h" | 5 #include "chrome/browser/managed_mode/managed_user_registration_utility.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
12 #include "base/rand_util.h" | 12 #include "base/rand_util.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "chrome/browser/managed_mode/managed_user_constants.h" | 14 #include "chrome/browser/managed_mode/managed_user_constants.h" |
15 #include "chrome/browser/managed_mode/managed_user_refresh_token_fetcher.h" | 15 #include "chrome/browser/managed_mode/managed_user_refresh_token_fetcher.h" |
16 #include "chrome/browser/managed_mode/managed_user_shared_settings_service.h" | 16 #include "chrome/browser/managed_mode/managed_user_shared_settings_service.h" |
17 #include "chrome/browser/managed_mode/managed_user_shared_settings_service_facto
ry.h" | 17 #include "chrome/browser/managed_mode/managed_user_shared_settings_service_facto
ry.h" |
18 #include "chrome/browser/managed_mode/managed_user_sync_service.h" | 18 #include "chrome/browser/managed_mode/managed_user_sync_service.h" |
19 #include "chrome/browser/managed_mode/managed_user_sync_service_factory.h" | 19 #include "chrome/browser/managed_mode/managed_user_sync_service_factory.h" |
20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/signin/profile_oauth2_token_service.h" | 21 #include "chrome/browser/signin/profile_oauth2_token_service.h" |
22 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 22 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
23 #include "chrome/browser/signin/signin_manager.h" | |
24 #include "chrome/browser/signin/signin_manager_factory.h" | |
25 #include "chrome/browser/sync/glue/device_info.h" | 23 #include "chrome/browser/sync/glue/device_info.h" |
26 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
27 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
28 #include "google_apis/gaia/gaia_urls.h" | 26 #include "google_apis/gaia/gaia_urls.h" |
29 #include "google_apis/gaia/google_service_auth_error.h" | 27 #include "google_apis/gaia/google_service_auth_error.h" |
30 | 28 |
31 using base::DictionaryValue; | 29 using base::DictionaryValue; |
32 | 30 |
33 namespace { | 31 namespace { |
34 | 32 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 scoped_ptr<ManagedUserRegistrationUtility> | 134 scoped_ptr<ManagedUserRegistrationUtility> |
137 ManagedUserRegistrationUtility::Create(Profile* profile) { | 135 ManagedUserRegistrationUtility::Create(Profile* profile) { |
138 if (g_instance_for_tests) { | 136 if (g_instance_for_tests) { |
139 ManagedUserRegistrationUtility* result = g_instance_for_tests; | 137 ManagedUserRegistrationUtility* result = g_instance_for_tests; |
140 g_instance_for_tests = NULL; | 138 g_instance_for_tests = NULL; |
141 return make_scoped_ptr(result); | 139 return make_scoped_ptr(result); |
142 } | 140 } |
143 | 141 |
144 ProfileOAuth2TokenService* token_service = | 142 ProfileOAuth2TokenService* token_service = |
145 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); | 143 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
146 SigninManagerBase* signin_manager = | |
147 SigninManagerFactory::GetForProfile(profile); | |
148 scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher = | 144 scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher = |
149 ManagedUserRefreshTokenFetcher::Create( | 145 ManagedUserRefreshTokenFetcher::Create( |
150 token_service, | 146 token_service, |
151 signin_manager->GetAuthenticatedAccountId(), | 147 token_service->GetPrimaryAccountId(), |
152 profile->GetRequestContext()); | 148 profile->GetRequestContext()); |
153 ManagedUserSyncService* managed_user_sync_service = | 149 ManagedUserSyncService* managed_user_sync_service = |
154 ManagedUserSyncServiceFactory::GetForProfile(profile); | 150 ManagedUserSyncServiceFactory::GetForProfile(profile); |
155 ManagedUserSharedSettingsService* managed_user_shared_settings_service = | 151 ManagedUserSharedSettingsService* managed_user_shared_settings_service = |
156 ManagedUserSharedSettingsServiceFactory::GetForBrowserContext(profile); | 152 ManagedUserSharedSettingsServiceFactory::GetForBrowserContext(profile); |
157 return make_scoped_ptr(ManagedUserRegistrationUtility::CreateImpl( | 153 return make_scoped_ptr(ManagedUserRegistrationUtility::CreateImpl( |
158 profile->GetPrefs(), | 154 profile->GetPrefs(), |
159 token_fetcher.Pass(), | 155 token_fetcher.Pass(), |
160 managed_user_sync_service, | 156 managed_user_sync_service, |
161 managed_user_shared_settings_service)); | 157 managed_user_shared_settings_service)); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 pending_managed_user_id_); | 328 pending_managed_user_id_); |
333 } | 329 } |
334 } | 330 } |
335 | 331 |
336 if (run_callback) | 332 if (run_callback) |
337 callback_.Run(error, pending_managed_user_token_); | 333 callback_.Run(error, pending_managed_user_token_); |
338 callback_.Reset(); | 334 callback_.Reset(); |
339 } | 335 } |
340 | 336 |
341 } // namespace | 337 } // namespace |
OLD | NEW |