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/supervised/supervised_user_creation_scre
en.h" | 5 #include "chrome/browser/chromeos/login/supervised/supervised_user_creation_scre
en.h" |
6 | 6 |
7 #include "ash/desktop_background/desktop_background_controller.h" | 7 #include "ash/desktop_background/desktop_background_controller.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 ->GetSessionManagerClient() | 209 ->GetSessionManagerClient() |
210 ->NotifySupervisedUserCreationFinished(); | 210 ->NotifySupervisedUserCreationFinished(); |
211 controller_->FinishCreation(); | 211 controller_->FinishCreation(); |
212 } | 212 } |
213 | 213 |
214 void SupervisedUserCreationScreen::HideFlow() { | 214 void SupervisedUserCreationScreen::HideFlow() { |
215 Hide(); | 215 Hide(); |
216 } | 216 } |
217 | 217 |
218 void SupervisedUserCreationScreen::AuthenticateManager( | 218 void SupervisedUserCreationScreen::AuthenticateManager( |
219 const std::string& manager_id, | 219 const user_manager::UserID& manager_id, |
220 const std::string& manager_password) { | 220 const std::string& manager_password) { |
221 if (manager_signin_in_progress_) | 221 if (manager_signin_in_progress_) |
222 return; | 222 return; |
223 manager_signin_in_progress_ = true; | 223 manager_signin_in_progress_ = true; |
224 | 224 |
225 UserFlow* flow = new SupervisedUserCreationFlow(manager_id); | 225 UserFlow* flow = new SupervisedUserCreationFlow(manager_id); |
226 ChromeUserManager::Get()->SetUserFlow(manager_id, flow); | 226 ChromeUserManager::Get()->SetUserFlow(manager_id, flow); |
227 | 227 |
228 // Make sure no two controllers exist at the same time. | 228 // Make sure no two controllers exist at the same time. |
229 controller_.reset(); | 229 controller_.reset(); |
(...skipping 13 matching lines...) Expand all Loading... |
243 int image; | 243 int image; |
244 if (selected_image_ == user_manager::User::USER_IMAGE_EXTERNAL) | 244 if (selected_image_ == user_manager::User::USER_IMAGE_EXTERNAL) |
245 // TODO(dzhioev): crbug/249660 | 245 // TODO(dzhioev): crbug/249660 |
246 image = SupervisedUserCreationController::kDummyAvatarIndex; | 246 image = SupervisedUserCreationController::kDummyAvatarIndex; |
247 else | 247 else |
248 image = selected_image_; | 248 image = selected_image_; |
249 controller_->StartCreation(display_name, supervised_user_password, image); | 249 controller_->StartCreation(display_name, supervised_user_password, image); |
250 } | 250 } |
251 | 251 |
252 void SupervisedUserCreationScreen::ImportSupervisedUser( | 252 void SupervisedUserCreationScreen::ImportSupervisedUser( |
253 const std::string& user_id) { | 253 const user_manager::UserID& user_id) { |
254 DCHECK(controller_.get()); | 254 DCHECK(controller_.get()); |
255 DCHECK(existing_users_.get()); | 255 DCHECK(existing_users_.get()); |
256 VLOG(1) << "Importing user " << user_id; | 256 VLOG(1) << "Importing user " << user_id.GetUserEmail(); |
257 base::DictionaryValue* user_info; | 257 base::DictionaryValue* user_info; |
258 if (!existing_users_->GetDictionary(user_id, &user_info)) { | 258 if (!existing_users_->GetDictionary(user_id.GetUserEmail(), &user_info)) { |
259 LOG(ERROR) << "Can not import non-existing user " << user_id; | 259 LOG(ERROR) << "Can not import non-existing user " << user_id.GetUserEmail(); |
260 return; | 260 return; |
261 } | 261 } |
262 base::string16 display_name; | 262 base::string16 display_name; |
263 std::string master_key; | 263 std::string master_key; |
264 std::string signature_key; | 264 std::string signature_key; |
265 std::string encryption_key; | 265 std::string encryption_key; |
266 std::string avatar; | 266 std::string avatar; |
267 bool exists; | 267 bool exists; |
268 int avatar_index = SupervisedUserCreationController::kDummyAvatarIndex; | 268 int avatar_index = SupervisedUserCreationController::kDummyAvatarIndex; |
269 user_info->GetString(SupervisedUserSyncService::kName, &display_name); | 269 user_info->GetString(SupervisedUserSyncService::kName, &display_name); |
(...skipping 17 matching lines...) Expand all Loading... |
287 return; | 287 return; |
288 } | 288 } |
289 | 289 |
290 SupervisedUserSyncService::GetAvatarIndex(avatar, &avatar_index); | 290 SupervisedUserSyncService::GetAvatarIndex(avatar, &avatar_index); |
291 | 291 |
292 const base::DictionaryValue* password_data = NULL; | 292 const base::DictionaryValue* password_data = NULL; |
293 SupervisedUserSharedSettingsService* shared_settings_service = | 293 SupervisedUserSharedSettingsService* shared_settings_service = |
294 SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext( | 294 SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext( |
295 controller_->GetManagerProfile()); | 295 controller_->GetManagerProfile()); |
296 const base::Value* value = shared_settings_service->GetValue( | 296 const base::Value* value = shared_settings_service->GetValue( |
297 user_id, supervised_users::kChromeOSPasswordData); | 297 user_id.GetUserEmail(), supervised_users::kChromeOSPasswordData); |
298 | 298 |
299 bool password_right_here = value && value->GetAsDictionary(&password_data) && | 299 bool password_right_here = value && value->GetAsDictionary(&password_data) && |
300 !password_data->empty(); | 300 !password_data->empty(); |
301 | 301 |
302 if (password_right_here) { | 302 if (password_right_here) { |
303 controller_->StartImport(display_name, | 303 controller_->StartImport(display_name, |
304 avatar_index, | 304 avatar_index, |
305 user_id, | 305 user_id.GetUserEmail(), |
306 master_key, | 306 master_key, |
307 password_data, | 307 password_data, |
308 encryption_key, | 308 encryption_key, |
309 signature_key); | 309 signature_key); |
310 } else { | 310 } else { |
311 NOTREACHED() << " Oops, no password"; | 311 NOTREACHED() << " Oops, no password"; |
312 } | 312 } |
313 } | 313 } |
314 | 314 |
315 // TODO(antrim): Code duplication with previous method will be removed once | 315 // TODO(antrim): Code duplication with previous method will be removed once |
316 // password sync is implemented. | 316 // password sync is implemented. |
317 void SupervisedUserCreationScreen::ImportSupervisedUserWithPassword( | 317 void SupervisedUserCreationScreen::ImportSupervisedUserWithPassword( |
318 const std::string& user_id, | 318 const user_manager::UserID& user_id, |
319 const std::string& password) { | 319 const std::string& password) { |
320 DCHECK(controller_.get()); | 320 DCHECK(controller_.get()); |
321 DCHECK(existing_users_.get()); | 321 DCHECK(existing_users_.get()); |
322 VLOG(1) << "Importing user " << user_id; | 322 VLOG(1) << "Importing user " << user_id.GetUserEmail(); |
323 base::DictionaryValue* user_info; | 323 base::DictionaryValue* user_info; |
324 if (!existing_users_->GetDictionary(user_id, &user_info)) { | 324 if (!existing_users_->GetDictionary(user_id.GetUserEmail(), &user_info)) { |
325 LOG(ERROR) << "Can not import non-existing user " << user_id; | 325 LOG(ERROR) << "Can not import non-existing user " << user_id.GetUserEmail(); |
326 return; | 326 return; |
327 } | 327 } |
328 base::string16 display_name; | 328 base::string16 display_name; |
329 std::string master_key; | 329 std::string master_key; |
330 std::string avatar; | 330 std::string avatar; |
331 bool exists; | 331 bool exists; |
332 int avatar_index = SupervisedUserCreationController::kDummyAvatarIndex; | 332 int avatar_index = SupervisedUserCreationController::kDummyAvatarIndex; |
333 user_info->GetString(SupervisedUserSyncService::kName, &display_name); | 333 user_info->GetString(SupervisedUserSyncService::kName, &display_name); |
334 user_info->GetString(SupervisedUserSyncService::kMasterKey, &master_key); | 334 user_info->GetString(SupervisedUserSyncService::kMasterKey, &master_key); |
335 user_info->GetString(SupervisedUserSyncService::kChromeOsAvatar, &avatar); | 335 user_info->GetString(SupervisedUserSyncService::kChromeOsAvatar, &avatar); |
336 user_info->GetBoolean(kUserExists, &exists); | 336 user_info->GetBoolean(kUserExists, &exists); |
337 | 337 |
338 // We should not get here with existing user selected, so just display error. | 338 // We should not get here with existing user selected, so just display error. |
339 if (exists) { | 339 if (exists) { |
340 actor_->ShowErrorPage( | 340 actor_->ShowErrorPage( |
341 l10n_util::GetStringUTF16( | 341 l10n_util::GetStringUTF16( |
342 IDS_CREATE_SUPERVISED_USER_GENERIC_ERROR_TITLE), | 342 IDS_CREATE_SUPERVISED_USER_GENERIC_ERROR_TITLE), |
343 l10n_util::GetStringUTF16( | 343 l10n_util::GetStringUTF16( |
344 IDS_CREATE_SUPERVISED_USER_GENERIC_ERROR), | 344 IDS_CREATE_SUPERVISED_USER_GENERIC_ERROR), |
345 l10n_util::GetStringUTF16( | 345 l10n_util::GetStringUTF16( |
346 IDS_CREATE_SUPERVISED_USER_GENERIC_ERROR_BUTTON)); | 346 IDS_CREATE_SUPERVISED_USER_GENERIC_ERROR_BUTTON)); |
347 return; | 347 return; |
348 } | 348 } |
349 | 349 |
350 SupervisedUserSyncService::GetAvatarIndex(avatar, &avatar_index); | 350 SupervisedUserSyncService::GetAvatarIndex(avatar, &avatar_index); |
351 | 351 |
352 controller_->StartImport(display_name, | 352 controller_->StartImport(display_name, |
353 password, | 353 password, |
354 avatar_index, | 354 avatar_index, |
355 user_id, | 355 user_id.GetUserEmail(), |
356 master_key); | 356 master_key); |
357 } | 357 } |
358 | 358 |
359 void SupervisedUserCreationScreen::OnManagerLoginFailure() { | 359 void SupervisedUserCreationScreen::OnManagerLoginFailure() { |
360 manager_signin_in_progress_ = false; | 360 manager_signin_in_progress_ = false; |
361 if (actor_) | 361 if (actor_) |
362 actor_->ShowManagerPasswordError(); | 362 actor_->ShowManagerPasswordError(); |
363 } | 363 } |
364 | 364 |
365 void SupervisedUserCreationScreen::OnManagerFullyAuthenticated( | 365 void SupervisedUserCreationScreen::OnManagerFullyAuthenticated( |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 | 451 |
452 void SupervisedUserCreationScreen::OnLongCreationWarning() { | 452 void SupervisedUserCreationScreen::OnLongCreationWarning() { |
453 if (actor_) { | 453 if (actor_) { |
454 actor_->ShowStatusMessage(true /* progress */, l10n_util::GetStringUTF16( | 454 actor_->ShowStatusMessage(true /* progress */, l10n_util::GetStringUTF16( |
455 IDS_PROFILES_CREATE_SUPERVISED_JUST_SIGNED_IN)); | 455 IDS_PROFILES_CREATE_SUPERVISED_JUST_SIGNED_IN)); |
456 } | 456 } |
457 } | 457 } |
458 | 458 |
459 bool SupervisedUserCreationScreen::FindUserByDisplayName( | 459 bool SupervisedUserCreationScreen::FindUserByDisplayName( |
460 const base::string16& display_name, | 460 const base::string16& display_name, |
461 std::string *out_id) const { | 461 std::string *out_email) const { |
462 if (!existing_users_.get()) | 462 if (!existing_users_.get()) |
463 return false; | 463 return false; |
464 for (base::DictionaryValue::Iterator it(*existing_users_.get()); | 464 for (base::DictionaryValue::Iterator it(*existing_users_.get()); |
465 !it.IsAtEnd(); it.Advance()) { | 465 !it.IsAtEnd(); it.Advance()) { |
466 const base::DictionaryValue* user_info = | 466 const base::DictionaryValue* user_info = |
467 static_cast<const base::DictionaryValue*>(&it.value()); | 467 static_cast<const base::DictionaryValue*>(&it.value()); |
468 base::string16 user_display_name; | 468 base::string16 user_display_name; |
469 if (user_info->GetString(SupervisedUserSyncService::kName, | 469 if (user_info->GetString(SupervisedUserSyncService::kName, |
470 &user_display_name)) { | 470 &user_display_name)) { |
471 if (display_name == user_display_name) { | 471 if (display_name == user_display_name) { |
472 if (out_id) | 472 if (out_email) |
473 *out_id = it.key(); | 473 *out_email = it.key(); |
474 return true; | 474 return true; |
475 } | 475 } |
476 } | 476 } |
477 } | 477 } |
478 return false; | 478 return false; |
479 } | 479 } |
480 | 480 |
481 // TODO(antrim) : this is an explicit code duplications with UserImageScreen. | 481 // TODO(antrim) : this is an explicit code duplications with UserImageScreen. |
482 // It should be removed by issue 251179. | 482 // It should be removed by issue 251179. |
483 | 483 |
484 void SupervisedUserCreationScreen::ApplyPicture() { | 484 void SupervisedUserCreationScreen::ApplyPicture() { |
485 std::string user_id = controller_->GetSupervisedUserId(); | 485 user_manager::UserID user_id = controller_->GetSupervisedUserId(); |
486 UserImageManager* image_manager = | 486 UserImageManager* image_manager = |
487 ChromeUserManager::Get()->GetUserImageManager(user_id); | 487 ChromeUserManager::Get()->GetUserImageManager(user_id); |
488 switch (selected_image_) { | 488 switch (selected_image_) { |
489 case user_manager::User::USER_IMAGE_EXTERNAL: | 489 case user_manager::User::USER_IMAGE_EXTERNAL: |
490 // Photo decoding may not have been finished yet. | 490 // Photo decoding may not have been finished yet. |
491 if (user_photo_.isNull()) { | 491 if (user_photo_.isNull()) { |
492 apply_photo_after_decoding_ = true; | 492 apply_photo_after_decoding_ = true; |
493 return; | 493 return; |
494 } | 494 } |
495 image_manager->SaveUserImage( | 495 image_manager->SaveUserImage( |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 selected_image_ = user_manager::User::USER_IMAGE_EXTERNAL; | 622 selected_image_ = user_manager::User::USER_IMAGE_EXTERNAL; |
623 } else { | 623 } else { |
624 NOTREACHED() << "Unexpected image type: " << image_type; | 624 NOTREACHED() << "Unexpected image type: " << image_type; |
625 } | 625 } |
626 } | 626 } |
627 | 627 |
628 void SupervisedUserCreationScreen::OnImageAccepted() { | 628 void SupervisedUserCreationScreen::OnImageAccepted() { |
629 } | 629 } |
630 | 630 |
631 } // namespace chromeos | 631 } // namespace chromeos |
OLD | NEW |