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/chromeos/login/managed/managed_user_creation_controller
_new.h" | 5 #include "chrome/browser/chromeos/login/supervised/supervised_user_creation_cont
roller_new.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/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/sys_info.h" | 13 #include "base/sys_info.h" |
14 #include "base/task_runner_util.h" | 14 #include "base/task_runner_util.h" |
15 #include "base/threading/sequenced_worker_pool.h" | 15 #include "base/threading/sequenced_worker_pool.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "chrome/browser/chromeos/login/auth/mount_manager.h" | 17 #include "chrome/browser/chromeos/login/auth/mount_manager.h" |
18 #include "chrome/browser/chromeos/login/managed/locally_managed_user_constants.h
" | 18 #include "chrome/browser/chromeos/login/supervised/supervised_user_authenticatio
n.h" |
19 #include "chrome/browser/chromeos/login/managed/supervised_user_authentication.h
" | 19 #include "chrome/browser/chromeos/login/supervised/supervised_user_constants.h" |
20 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" | 20 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" |
21 #include "chrome/browser/chromeos/login/users/user.h" | 21 #include "chrome/browser/chromeos/login/users/user.h" |
22 #include "chrome/browser/chromeos/login/users/user_manager.h" | 22 #include "chrome/browser/chromeos/login/users/user_manager.h" |
23 #include "chrome/browser/lifetime/application_lifetime.h" | 23 #include "chrome/browser/lifetime/application_lifetime.h" |
24 #include "chrome/browser/sync/profile_sync_service.h" | 24 #include "chrome/browser/sync/profile_sync_service.h" |
25 #include "chrome/browser/sync/profile_sync_service_factory.h" | 25 #include "chrome/browser/sync/profile_sync_service_factory.h" |
26 #include "chromeos/cryptohome/cryptohome_parameters.h" | 26 #include "chromeos/cryptohome/cryptohome_parameters.h" |
27 #include "chromeos/dbus/dbus_thread_manager.h" | 27 #include "chromeos/dbus/dbus_thread_manager.h" |
28 #include "chromeos/dbus/session_manager_client.h" | 28 #include "chromeos/dbus/session_manager_client.h" |
29 #include "chromeos/login/auth/key.h" | 29 #include "chromeos/login/auth/key.h" |
30 #include "chromeos/login/auth/user_context.h" | 30 #include "chromeos/login/auth/user_context.h" |
31 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
32 #include "content/public/browser/user_metrics.h" | 32 #include "content/public/browser/user_metrics.h" |
33 #include "crypto/random.h" | 33 #include "crypto/random.h" |
34 #include "google_apis/gaia/google_service_auth_error.h" | 34 #include "google_apis/gaia/google_service_auth_error.h" |
35 | 35 |
36 namespace chromeos { | 36 namespace chromeos { |
37 | 37 |
38 namespace { | 38 namespace { |
39 | 39 |
40 const int kUserCreationTimeoutSeconds = 30; // 30 seconds. | 40 const int kUserCreationTimeoutSeconds = 30; // 30 seconds. |
41 | 41 |
42 bool StoreManagedUserFiles(const std::string& token, | 42 bool StoreSupervisedUserFiles(const std::string& token, |
43 const base::FilePath& base_path) { | 43 const base::FilePath& base_path) { |
44 if (!base::SysInfo::IsRunningOnChromeOS()) { | 44 if (!base::SysInfo::IsRunningOnChromeOS()) { |
45 // If running on desktop, cryptohome stub does not create home directory. | 45 // If running on desktop, cryptohome stub does not create home directory. |
46 base::CreateDirectory(base_path); | 46 base::CreateDirectory(base_path); |
47 } | 47 } |
48 base::FilePath token_file = base_path.Append(kSupervisedUserTokenFilename); | 48 base::FilePath token_file = base_path.Append(kSupervisedUserTokenFilename); |
49 int bytes = base::WriteFile(token_file, token.c_str(), token.length()); | 49 int bytes = base::WriteFile(token_file, token.c_str(), token.length()); |
50 return bytes >= 0; | 50 return bytes >= 0; |
51 } | 51 } |
52 | 52 |
53 } // namespace | 53 } // namespace |
54 | 54 |
55 ManagedUserCreationControllerNew::ManagedUserCreationControllerNew( | 55 SupervisedUserCreationControllerNew::SupervisedUserCreationControllerNew( |
56 ManagedUserCreationControllerNew::StatusConsumer* consumer, | 56 SupervisedUserCreationControllerNew::StatusConsumer* consumer, |
57 const std::string& manager_id) | 57 const std::string& manager_id) |
58 : ManagedUserCreationController(consumer), | 58 : SupervisedUserCreationController(consumer), |
59 stage_(STAGE_INITIAL), | 59 stage_(STAGE_INITIAL), |
60 weak_factory_(this) { | 60 weak_factory_(this) { |
61 creation_context_.reset( | 61 creation_context_.reset( |
62 new ManagedUserCreationControllerNew::UserCreationContext()); | 62 new SupervisedUserCreationControllerNew::UserCreationContext()); |
63 creation_context_->manager_id = manager_id; | 63 creation_context_->manager_id = manager_id; |
64 } | 64 } |
65 | 65 |
66 ManagedUserCreationControllerNew::~ManagedUserCreationControllerNew() {} | 66 SupervisedUserCreationControllerNew::~SupervisedUserCreationControllerNew() {} |
67 | 67 |
68 ManagedUserCreationControllerNew::UserCreationContext::UserCreationContext() {} | 68 SupervisedUserCreationControllerNew::UserCreationContext:: |
| 69 UserCreationContext() {} |
69 | 70 |
70 ManagedUserCreationControllerNew::UserCreationContext::~UserCreationContext() {} | 71 SupervisedUserCreationControllerNew::UserCreationContext:: |
| 72 ~UserCreationContext() {} |
71 | 73 |
72 void ManagedUserCreationControllerNew::SetManagerProfile( | 74 void SupervisedUserCreationControllerNew::SetManagerProfile( |
73 Profile* manager_profile) { | 75 Profile* manager_profile) { |
74 creation_context_->manager_profile = manager_profile; | 76 creation_context_->manager_profile = manager_profile; |
75 } | 77 } |
76 | 78 |
77 Profile* ManagedUserCreationControllerNew::GetManagerProfile() { | 79 Profile* SupervisedUserCreationControllerNew::GetManagerProfile() { |
78 return creation_context_->manager_profile; | 80 return creation_context_->manager_profile; |
79 } | 81 } |
80 | 82 |
81 void ManagedUserCreationControllerNew::StartCreation( | 83 void SupervisedUserCreationControllerNew::StartCreation( |
82 const base::string16& display_name, | 84 const base::string16& display_name, |
83 const std::string& password, | 85 const std::string& password, |
84 int avatar_index) { | 86 int avatar_index) { |
85 DCHECK(creation_context_); | 87 DCHECK(creation_context_); |
86 creation_context_->creation_type = NEW_USER; | 88 creation_context_->creation_type = NEW_USER; |
87 creation_context_->display_name = display_name; | 89 creation_context_->display_name = display_name; |
88 creation_context_->password = password; | 90 creation_context_->password = password; |
89 creation_context_->avatar_index = avatar_index; | 91 creation_context_->avatar_index = avatar_index; |
90 StartCreationImpl(); | 92 StartCreationImpl(); |
91 } | 93 } |
92 | 94 |
93 void ManagedUserCreationControllerNew::StartImport( | 95 void SupervisedUserCreationControllerNew::StartImport( |
94 const base::string16& display_name, | 96 const base::string16& display_name, |
95 const std::string& password, | 97 const std::string& password, |
96 int avatar_index, | 98 int avatar_index, |
97 const std::string& sync_id, | 99 const std::string& sync_id, |
98 const std::string& master_key) { | 100 const std::string& master_key) { |
99 DCHECK(creation_context_); | 101 DCHECK(creation_context_); |
100 creation_context_->creation_type = USER_IMPORT_OLD; | 102 creation_context_->creation_type = USER_IMPORT_OLD; |
101 | 103 |
102 creation_context_->display_name = display_name; | 104 creation_context_->display_name = display_name; |
103 creation_context_->password = password; | 105 creation_context_->password = password; |
104 creation_context_->avatar_index = avatar_index; | 106 creation_context_->avatar_index = avatar_index; |
105 | 107 |
106 creation_context_->sync_user_id = sync_id; | 108 creation_context_->sync_user_id = sync_id; |
107 | 109 |
108 creation_context_->master_key = master_key; | 110 creation_context_->master_key = master_key; |
109 StartCreationImpl(); | 111 StartCreationImpl(); |
110 } | 112 } |
111 | 113 |
112 void ManagedUserCreationControllerNew::StartImport( | 114 void SupervisedUserCreationControllerNew::StartImport( |
113 const base::string16& display_name, | 115 const base::string16& display_name, |
114 int avatar_index, | 116 int avatar_index, |
115 const std::string& sync_id, | 117 const std::string& sync_id, |
116 const std::string& master_key, | 118 const std::string& master_key, |
117 const base::DictionaryValue* password_data, | 119 const base::DictionaryValue* password_data, |
118 const std::string& encryption_key, | 120 const std::string& encryption_key, |
119 const std::string& signature_key) { | 121 const std::string& signature_key) { |
120 DCHECK(creation_context_); | 122 DCHECK(creation_context_); |
121 creation_context_->creation_type = USER_IMPORT_NEW; | 123 creation_context_->creation_type = USER_IMPORT_NEW; |
122 | 124 |
123 creation_context_->display_name = display_name; | 125 creation_context_->display_name = display_name; |
124 | 126 |
125 creation_context_->avatar_index = avatar_index; | 127 creation_context_->avatar_index = avatar_index; |
126 | 128 |
127 creation_context_->sync_user_id = sync_id; | 129 creation_context_->sync_user_id = sync_id; |
128 | 130 |
129 creation_context_->master_key = master_key; | 131 creation_context_->master_key = master_key; |
130 | 132 |
131 password_data->GetStringWithoutPathExpansion( | 133 password_data->GetStringWithoutPathExpansion( |
132 kEncryptedPassword, &creation_context_->salted_password); | 134 kEncryptedPassword, &creation_context_->salted_password); |
133 | 135 |
134 creation_context_->signature_key = signature_key; | 136 creation_context_->signature_key = signature_key; |
135 creation_context_->encryption_key = encryption_key; | 137 creation_context_->encryption_key = encryption_key; |
136 | 138 |
137 creation_context_->password_data.MergeDictionary(password_data); | 139 creation_context_->password_data.MergeDictionary(password_data); |
138 | 140 |
139 StartCreationImpl(); | 141 StartCreationImpl(); |
140 } | 142 } |
141 | 143 |
142 void ManagedUserCreationControllerNew::StartCreationImpl() { | 144 void SupervisedUserCreationControllerNew::StartCreationImpl() { |
143 DCHECK(creation_context_); | 145 DCHECK(creation_context_); |
144 DCHECK_EQ(STAGE_INITIAL, stage_); | 146 DCHECK_EQ(STAGE_INITIAL, stage_); |
145 VLOG(1) << "Starting supervised user creation"; | 147 VLOG(1) << "Starting supervised user creation"; |
146 VLOG(1) << " Phase 1 : Prepare keys"; | 148 VLOG(1) << " Phase 1 : Prepare keys"; |
147 | 149 |
148 SupervisedUserManager* manager = | 150 SupervisedUserManager* manager = |
149 UserManager::Get()->GetSupervisedUserManager(); | 151 UserManager::Get()->GetSupervisedUserManager(); |
150 manager->StartCreationTransaction(creation_context_->display_name); | 152 manager->StartCreationTransaction(creation_context_->display_name); |
151 | 153 |
152 creation_context_->local_user_id = manager->GenerateUserId(); | 154 creation_context_->local_user_id = manager->GenerateUserId(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 authentication->StorePasswordData(creation_context_->local_user_id, | 194 authentication->StorePasswordData(creation_context_->local_user_id, |
193 creation_context_->password_data); | 195 creation_context_->password_data); |
194 stage_ = KEYS_GENERATED; | 196 stage_ = KEYS_GENERATED; |
195 | 197 |
196 VLOG(1) << " Phase 2 : Create cryptohome"; | 198 VLOG(1) << " Phase 2 : Create cryptohome"; |
197 | 199 |
198 timeout_timer_.Start( | 200 timeout_timer_.Start( |
199 FROM_HERE, | 201 FROM_HERE, |
200 base::TimeDelta::FromSeconds(kUserCreationTimeoutSeconds), | 202 base::TimeDelta::FromSeconds(kUserCreationTimeoutSeconds), |
201 this, | 203 this, |
202 &ManagedUserCreationControllerNew::CreationTimedOut); | 204 &SupervisedUserCreationControllerNew::CreationTimedOut); |
203 authenticator_ = new ExtendedAuthenticator(this); | 205 authenticator_ = new ExtendedAuthenticator(this); |
204 UserContext user_context; | 206 UserContext user_context; |
205 user_context.SetKey(Key(creation_context_->master_key)); | 207 user_context.SetKey(Key(creation_context_->master_key)); |
206 authenticator_->TransformKeyIfNeeded( | 208 authenticator_->TransformKeyIfNeeded( |
207 user_context, | 209 user_context, |
208 base::Bind(&ManagedUserCreationControllerNew::OnKeyTransformedIfNeeded, | 210 base::Bind(&SupervisedUserCreationControllerNew::OnKeyTransformedIfNeeded, |
209 weak_factory_.GetWeakPtr())); | 211 weak_factory_.GetWeakPtr())); |
210 } | 212 } |
211 | 213 |
212 void ManagedUserCreationControllerNew::OnKeyTransformedIfNeeded( | 214 void SupervisedUserCreationControllerNew::OnKeyTransformedIfNeeded( |
213 const UserContext& user_context) { | 215 const UserContext& user_context) { |
214 VLOG(1) << " Phase 2.1 : Got hashed master key"; | 216 VLOG(1) << " Phase 2.1 : Got hashed master key"; |
215 creation_context_->salted_master_key = user_context.GetKey()->GetSecret(); | 217 creation_context_->salted_master_key = user_context.GetKey()->GetSecret(); |
216 | 218 |
217 // Create home dir with two keys. | 219 // Create home dir with two keys. |
218 std::vector<cryptohome::KeyDefinition> keys; | 220 std::vector<cryptohome::KeyDefinition> keys; |
219 | 221 |
220 // Main key is the master key. Just as keys for plain GAIA users, it is salted | 222 // Main key is the master key. Just as keys for plain GAIA users, it is salted |
221 // with system salt. It has all usual privileges. | 223 // with system salt. It has all usual privileges. |
222 cryptohome::KeyDefinition master_key(creation_context_->salted_master_key, | 224 cryptohome::KeyDefinition master_key(creation_context_->salted_master_key, |
223 kCryptohomeMasterKeyLabel, | 225 kCryptohomeMasterKeyLabel, |
224 cryptohome::PRIV_DEFAULT); | 226 cryptohome::PRIV_DEFAULT); |
225 | 227 |
226 keys.push_back(master_key); | 228 keys.push_back(master_key); |
227 authenticator_->CreateMount( | 229 authenticator_->CreateMount( |
228 creation_context_->local_user_id, | 230 creation_context_->local_user_id, |
229 keys, | 231 keys, |
230 base::Bind(&ManagedUserCreationControllerNew::OnMountSuccess, | 232 base::Bind(&SupervisedUserCreationControllerNew::OnMountSuccess, |
231 weak_factory_.GetWeakPtr())); | 233 weak_factory_.GetWeakPtr())); |
232 } | 234 } |
233 | 235 |
234 void ManagedUserCreationControllerNew::OnAuthenticationFailure( | 236 void SupervisedUserCreationControllerNew::OnAuthenticationFailure( |
235 ExtendedAuthenticator::AuthState error) { | 237 ExtendedAuthenticator::AuthState error) { |
236 timeout_timer_.Stop(); | 238 timeout_timer_.Stop(); |
237 ErrorCode code = NO_ERROR; | 239 ErrorCode code = NO_ERROR; |
238 switch (error) { | 240 switch (error) { |
239 case ManagedUserAuthenticator::NO_MOUNT: | 241 case SupervisedUserAuthenticator::NO_MOUNT: |
240 code = CRYPTOHOME_NO_MOUNT; | 242 code = CRYPTOHOME_NO_MOUNT; |
241 break; | 243 break; |
242 case ManagedUserAuthenticator::FAILED_MOUNT: | 244 case SupervisedUserAuthenticator::FAILED_MOUNT: |
243 code = CRYPTOHOME_FAILED_MOUNT; | 245 code = CRYPTOHOME_FAILED_MOUNT; |
244 break; | 246 break; |
245 case ManagedUserAuthenticator::FAILED_TPM: | 247 case SupervisedUserAuthenticator::FAILED_TPM: |
246 code = CRYPTOHOME_FAILED_TPM; | 248 code = CRYPTOHOME_FAILED_TPM; |
247 break; | 249 break; |
248 default: | 250 default: |
249 NOTREACHED(); | 251 NOTREACHED(); |
250 } | 252 } |
251 stage_ = STAGE_ERROR; | 253 stage_ = STAGE_ERROR; |
252 if (consumer_) | 254 if (consumer_) |
253 consumer_->OnCreationError(code); | 255 consumer_->OnCreationError(code); |
254 } | 256 } |
255 | 257 |
256 void ManagedUserCreationControllerNew::OnMountSuccess( | 258 void SupervisedUserCreationControllerNew::OnMountSuccess( |
257 const std::string& mount_hash) { | 259 const std::string& mount_hash) { |
258 DCHECK(creation_context_); | 260 DCHECK(creation_context_); |
259 DCHECK_EQ(KEYS_GENERATED, stage_); | 261 DCHECK_EQ(KEYS_GENERATED, stage_); |
260 VLOG(1) << " Phase 2.2 : Created home dir with master key"; | 262 VLOG(1) << " Phase 2.2 : Created home dir with master key"; |
261 | 263 |
262 creation_context_->mount_hash = mount_hash; | 264 creation_context_->mount_hash = mount_hash; |
263 | 265 |
264 // Plain text password, hashed and salted with individual salt. | 266 // Plain text password, hashed and salted with individual salt. |
265 // It can be used for mounting homedir, and can be replaced only when signed. | 267 // It can be used for mounting homedir, and can be replaced only when signed. |
266 cryptohome::KeyDefinition password_key( | 268 cryptohome::KeyDefinition password_key( |
(...skipping 10 matching lines...) Expand all Loading... |
277 creation_context_->salted_master_key); | 279 creation_context_->salted_master_key); |
278 key.SetLabel(kCryptohomeMasterKeyLabel); | 280 key.SetLabel(kCryptohomeMasterKeyLabel); |
279 UserContext context(creation_context_->local_user_id); | 281 UserContext context(creation_context_->local_user_id); |
280 context.SetKey(key); | 282 context.SetKey(key); |
281 context.SetIsUsingOAuth(false); | 283 context.SetIsUsingOAuth(false); |
282 | 284 |
283 authenticator_->AddKey( | 285 authenticator_->AddKey( |
284 context, | 286 context, |
285 password_key, | 287 password_key, |
286 true, | 288 true, |
287 base::Bind(&ManagedUserCreationControllerNew::OnAddKeySuccess, | 289 base::Bind(&SupervisedUserCreationControllerNew::OnAddKeySuccess, |
288 weak_factory_.GetWeakPtr())); | 290 weak_factory_.GetWeakPtr())); |
289 } | 291 } |
290 | 292 |
291 void ManagedUserCreationControllerNew::OnAddKeySuccess() { | 293 void SupervisedUserCreationControllerNew::OnAddKeySuccess() { |
292 DCHECK(creation_context_); | 294 DCHECK(creation_context_); |
293 DCHECK_EQ(KEYS_GENERATED, stage_); | 295 DCHECK_EQ(KEYS_GENERATED, stage_); |
294 stage_ = CRYPTOHOME_CREATED; | 296 stage_ = CRYPTOHOME_CREATED; |
295 | 297 |
296 VLOG(1) << " Phase 3 : Create/update user on chrome.com/manage"; | 298 VLOG(1) << " Phase 3 : Create/update user on chrome.com/manage"; |
297 | 299 |
298 ProfileSyncService* sync_service = | 300 ProfileSyncService* sync_service = |
299 ProfileSyncServiceFactory::GetInstance()->GetForProfile( | 301 ProfileSyncServiceFactory::GetInstance()->GetForProfile( |
300 creation_context_->manager_profile); | 302 creation_context_->manager_profile); |
301 ProfileSyncService::SyncStatusSummary status = | 303 ProfileSyncService::SyncStatusSummary status = |
(...skipping 11 matching lines...) Expand all Loading... |
313 info.master_key = creation_context_->master_key; | 315 info.master_key = creation_context_->master_key; |
314 info.password_signature_key = creation_context_->signature_key; | 316 info.password_signature_key = creation_context_->signature_key; |
315 info.password_encryption_key = creation_context_->encryption_key; | 317 info.password_encryption_key = creation_context_->encryption_key; |
316 | 318 |
317 info.password_data.MergeDictionary(&creation_context_->password_data); | 319 info.password_data.MergeDictionary(&creation_context_->password_data); |
318 | 320 |
319 // Registration utility will update user data if user already exist. | 321 // Registration utility will update user data if user already exist. |
320 creation_context_->registration_utility->Register( | 322 creation_context_->registration_utility->Register( |
321 creation_context_->sync_user_id, | 323 creation_context_->sync_user_id, |
322 info, | 324 info, |
323 base::Bind(&ManagedUserCreationControllerNew::RegistrationCallback, | 325 base::Bind(&SupervisedUserCreationControllerNew::RegistrationCallback, |
324 weak_factory_.GetWeakPtr())); | 326 weak_factory_.GetWeakPtr())); |
325 } | 327 } |
326 | 328 |
327 void ManagedUserCreationControllerNew::RegistrationCallback( | 329 void SupervisedUserCreationControllerNew::RegistrationCallback( |
328 const GoogleServiceAuthError& error, | 330 const GoogleServiceAuthError& error, |
329 const std::string& token) { | 331 const std::string& token) { |
330 DCHECK(creation_context_); | 332 DCHECK(creation_context_); |
331 DCHECK_EQ(CRYPTOHOME_CREATED, stage_); | 333 DCHECK_EQ(CRYPTOHOME_CREATED, stage_); |
332 | 334 |
333 stage_ = DASHBOARD_CREATED; | 335 stage_ = DASHBOARD_CREATED; |
334 | 336 |
335 if (error.state() == GoogleServiceAuthError::NONE) { | 337 if (error.state() == GoogleServiceAuthError::NONE) { |
336 creation_context_->token = token; | 338 creation_context_->token = token; |
337 | 339 |
338 PostTaskAndReplyWithResult( | 340 PostTaskAndReplyWithResult( |
339 content::BrowserThread::GetBlockingPool(), | 341 content::BrowserThread::GetBlockingPool(), |
340 FROM_HERE, | 342 FROM_HERE, |
341 base::Bind(&StoreManagedUserFiles, | 343 base::Bind(&StoreSupervisedUserFiles, |
342 creation_context_->token, | 344 creation_context_->token, |
343 MountManager::GetHomeDir(creation_context_->mount_hash)), | 345 MountManager::GetHomeDir(creation_context_->mount_hash)), |
344 base::Bind(&ManagedUserCreationControllerNew::OnManagedUserFilesStored, | 346 base::Bind(&SupervisedUserCreationControllerNew:: |
| 347 OnSupervisedUserFilesStored, |
345 weak_factory_.GetWeakPtr())); | 348 weak_factory_.GetWeakPtr())); |
346 } else { | 349 } else { |
347 stage_ = STAGE_ERROR; | 350 stage_ = STAGE_ERROR; |
348 LOG(ERROR) << "Managed user creation failed. Error code " << error.state(); | 351 LOG(ERROR) << "Supervised user creation failed. Error code " |
| 352 << error.state(); |
349 if (consumer_) | 353 if (consumer_) |
350 consumer_->OnCreationError(CLOUD_SERVER_ERROR); | 354 consumer_->OnCreationError(CLOUD_SERVER_ERROR); |
351 } | 355 } |
352 } | 356 } |
353 | 357 |
354 void ManagedUserCreationControllerNew::OnManagedUserFilesStored(bool success) { | 358 void SupervisedUserCreationControllerNew::OnSupervisedUserFilesStored( |
| 359 bool success) { |
355 DCHECK(creation_context_); | 360 DCHECK(creation_context_); |
356 DCHECK_EQ(DASHBOARD_CREATED, stage_); | 361 DCHECK_EQ(DASHBOARD_CREATED, stage_); |
357 | 362 |
358 if (!success) { | 363 if (!success) { |
359 stage_ = STAGE_ERROR; | 364 stage_ = STAGE_ERROR; |
360 if (consumer_) | 365 if (consumer_) |
361 consumer_->OnCreationError(TOKEN_WRITE_FAILED); | 366 consumer_->OnCreationError(TOKEN_WRITE_FAILED); |
362 return; | 367 return; |
363 } | 368 } |
364 // Assume that new token is valid. It will be automatically invalidated if | 369 // Assume that new token is valid. It will be automatically invalidated if |
365 // sync service fails to use it. | 370 // sync service fails to use it. |
366 UserManager::Get()->SaveUserOAuthStatus(creation_context_->local_user_id, | 371 UserManager::Get()->SaveUserOAuthStatus(creation_context_->local_user_id, |
367 User::OAUTH2_TOKEN_STATUS_VALID); | 372 User::OAUTH2_TOKEN_STATUS_VALID); |
368 | 373 |
369 stage_ = TOKEN_WRITTEN; | 374 stage_ = TOKEN_WRITTEN; |
370 | 375 |
371 timeout_timer_.Stop(); | 376 timeout_timer_.Stop(); |
372 UserManager::Get()->GetSupervisedUserManager()->CommitCreationTransaction(); | 377 UserManager::Get()->GetSupervisedUserManager()->CommitCreationTransaction(); |
373 content::RecordAction( | 378 content::RecordAction( |
374 base::UserMetricsAction("ManagedMode_LocallyManagedUserCreated")); | 379 base::UserMetricsAction("ManagedMode_LocallyManagedUserCreated")); |
375 | 380 |
376 stage_ = TRANSACTION_COMMITTED; | 381 stage_ = TRANSACTION_COMMITTED; |
377 | 382 |
378 if (consumer_) | 383 if (consumer_) |
379 consumer_->OnCreationSuccess(); | 384 consumer_->OnCreationSuccess(); |
380 } | 385 } |
381 | 386 |
382 void ManagedUserCreationControllerNew::CreationTimedOut() { | 387 void SupervisedUserCreationControllerNew::CreationTimedOut() { |
383 LOG(ERROR) << "Supervised user creation timed out. stage = " << stage_; | 388 LOG(ERROR) << "Supervised user creation timed out. stage = " << stage_; |
384 if (consumer_) | 389 if (consumer_) |
385 consumer_->OnCreationTimeout(); | 390 consumer_->OnCreationTimeout(); |
386 } | 391 } |
387 | 392 |
388 void ManagedUserCreationControllerNew::FinishCreation() { | 393 void SupervisedUserCreationControllerNew::FinishCreation() { |
389 chrome::AttemptUserExit(); | 394 chrome::AttemptUserExit(); |
390 } | 395 } |
391 | 396 |
392 void ManagedUserCreationControllerNew::CancelCreation() { | 397 void SupervisedUserCreationControllerNew::CancelCreation() { |
393 creation_context_->registration_utility.reset(); | 398 creation_context_->registration_utility.reset(); |
394 chrome::AttemptUserExit(); | 399 chrome::AttemptUserExit(); |
395 } | 400 } |
396 | 401 |
397 std::string ManagedUserCreationControllerNew::GetManagedUserId() { | 402 std::string SupervisedUserCreationControllerNew::GetSupervisedUserId() { |
398 DCHECK(creation_context_); | 403 DCHECK(creation_context_); |
399 return creation_context_->local_user_id; | 404 return creation_context_->local_user_id; |
400 } | 405 } |
401 | 406 |
402 } // namespace chromeos | 407 } // namespace chromeos |
OLD | NEW |