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" |
23 #include "chrome/browser/sync/glue/device_info.h" | 25 #include "chrome/browser/sync/glue/device_info.h" |
24 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
25 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
26 #include "google_apis/gaia/gaia_urls.h" | 28 #include "google_apis/gaia/gaia_urls.h" |
27 #include "google_apis/gaia/google_service_auth_error.h" | 29 #include "google_apis/gaia/google_service_auth_error.h" |
28 | 30 |
29 using base::DictionaryValue; | 31 using base::DictionaryValue; |
30 | 32 |
31 namespace { | 33 namespace { |
32 | 34 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 scoped_ptr<ManagedUserRegistrationUtility> | 136 scoped_ptr<ManagedUserRegistrationUtility> |
135 ManagedUserRegistrationUtility::Create(Profile* profile) { | 137 ManagedUserRegistrationUtility::Create(Profile* profile) { |
136 if (g_instance_for_tests) { | 138 if (g_instance_for_tests) { |
137 ManagedUserRegistrationUtility* result = g_instance_for_tests; | 139 ManagedUserRegistrationUtility* result = g_instance_for_tests; |
138 g_instance_for_tests = NULL; | 140 g_instance_for_tests = NULL; |
139 return make_scoped_ptr(result); | 141 return make_scoped_ptr(result); |
140 } | 142 } |
141 | 143 |
142 ProfileOAuth2TokenService* token_service = | 144 ProfileOAuth2TokenService* token_service = |
143 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); | 145 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
| 146 SigninManagerBase* signin_manager = |
| 147 SigninManagerFactory::GetForProfile(profile); |
144 scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher = | 148 scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher = |
145 ManagedUserRefreshTokenFetcher::Create( | 149 ManagedUserRefreshTokenFetcher::Create( |
146 token_service, | 150 token_service, |
147 token_service->GetPrimaryAccountId(), | 151 signin_manager->GetAuthenticatedAccountId(), |
148 profile->GetRequestContext()); | 152 profile->GetRequestContext()); |
149 ManagedUserSyncService* managed_user_sync_service = | 153 ManagedUserSyncService* managed_user_sync_service = |
150 ManagedUserSyncServiceFactory::GetForProfile(profile); | 154 ManagedUserSyncServiceFactory::GetForProfile(profile); |
151 ManagedUserSharedSettingsService* managed_user_shared_settings_service = | 155 ManagedUserSharedSettingsService* managed_user_shared_settings_service = |
152 ManagedUserSharedSettingsServiceFactory::GetForBrowserContext(profile); | 156 ManagedUserSharedSettingsServiceFactory::GetForBrowserContext(profile); |
153 return make_scoped_ptr(ManagedUserRegistrationUtility::CreateImpl( | 157 return make_scoped_ptr(ManagedUserRegistrationUtility::CreateImpl( |
154 profile->GetPrefs(), | 158 profile->GetPrefs(), |
155 token_fetcher.Pass(), | 159 token_fetcher.Pass(), |
156 managed_user_sync_service, | 160 managed_user_sync_service, |
157 managed_user_shared_settings_service)); | 161 managed_user_shared_settings_service)); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 pending_managed_user_id_); | 332 pending_managed_user_id_); |
329 } | 333 } |
330 } | 334 } |
331 | 335 |
332 if (run_callback) | 336 if (run_callback) |
333 callback_.Run(error, pending_managed_user_token_); | 337 callback_.Run(error, pending_managed_user_token_); |
334 callback_.Reset(); | 338 callback_.Reset(); |
335 } | 339 } |
336 | 340 |
337 } // namespace | 341 } // namespace |
OLD | NEW |