Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(338)

Side by Side Diff: chrome/browser/chromeos/login/managed/locally_managed_user_creation_screen.cc

Issue 335833003: Rename "managed (mode|user)" to "supervised user" (part 2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments (+ a few other cleanups) Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/chromeos/login/managed/locally_managed_user_creation_sc reen.h" 5 #include "chrome/browser/chromeos/login/managed/locally_managed_user_creation_sc reen.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"
11 #include "chrome/browser/chromeos/camera_detector.h" 11 #include "chrome/browser/chromeos/camera_detector.h"
12 #include "chrome/browser/chromeos/login/auth/key.h" 12 #include "chrome/browser/chromeos/login/auth/key.h"
13 #include "chrome/browser/chromeos/login/auth/user_context.h" 13 #include "chrome/browser/chromeos/login/auth/user_context.h"
14 #include "chrome/browser/chromeos/login/existing_user_controller.h" 14 #include "chrome/browser/chromeos/login/existing_user_controller.h"
15 #include "chrome/browser/chromeos/login/managed/managed_user_creation_controller .h" 15 #include "chrome/browser/chromeos/login/managed/managed_user_creation_controller .h"
16 #include "chrome/browser/chromeos/login/managed/managed_user_creation_controller _new.h" 16 #include "chrome/browser/chromeos/login/managed/managed_user_creation_controller _new.h"
17 #include "chrome/browser/chromeos/login/managed/managed_user_creation_controller _old.h" 17 #include "chrome/browser/chromeos/login/managed/managed_user_creation_controller _old.h"
18 #include "chrome/browser/chromeos/login/managed/supervised_user_authentication.h " 18 #include "chrome/browser/chromeos/login/managed/supervised_user_authentication.h "
19 #include "chrome/browser/chromeos/login/screens/error_screen.h" 19 #include "chrome/browser/chromeos/login/screens/error_screen.h"
20 #include "chrome/browser/chromeos/login/screens/screen_observer.h" 20 #include "chrome/browser/chromeos/login/screens/screen_observer.h"
21 #include "chrome/browser/chromeos/login/users/avatar/user_image.h" 21 #include "chrome/browser/chromeos/login/users/avatar/user_image.h"
22 #include "chrome/browser/chromeos/login/users/avatar/user_image_manager.h" 22 #include "chrome/browser/chromeos/login/users/avatar/user_image_manager.h"
23 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" 23 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
24 #include "chrome/browser/chromeos/login/wizard_controller.h" 24 #include "chrome/browser/chromeos/login/wizard_controller.h"
25 #include "chrome/browser/managed_mode/managed_user_constants.h" 25 #include "chrome/browser/supervised_user/supervised_user_constants.h"
26 #include "chrome/browser/managed_mode/managed_user_shared_settings_service.h" 26 #include "chrome/browser/supervised_user/supervised_user_shared_settings_service .h"
27 #include "chrome/browser/managed_mode/managed_user_shared_settings_service_facto ry.h" 27 #include "chrome/browser/supervised_user/supervised_user_shared_settings_service _factory.h"
28 #include "chrome/browser/managed_mode/managed_user_sync_service.h" 28 #include "chrome/browser/supervised_user/supervised_user_sync_service.h"
29 #include "chrome/browser/managed_mode/managed_user_sync_service_factory.h" 29 #include "chrome/browser/supervised_user/supervised_user_sync_service_factory.h"
30 #include "chromeos/network/network_state.h" 30 #include "chromeos/network/network_state.h"
31 #include "content/public/browser/browser_thread.h" 31 #include "content/public/browser/browser_thread.h"
32 #include "grit/generated_resources.h" 32 #include "grit/generated_resources.h"
33 #include "third_party/skia/include/core/SkBitmap.h" 33 #include "third_party/skia/include/core/SkBitmap.h"
34 #include "ui/base/l10n/l10n_util.h" 34 #include "ui/base/l10n/l10n_util.h"
35 #include "ui/gfx/image/image_skia.h" 35 #include "ui/gfx/image/image_skia.h"
36 36
37 namespace chromeos { 37 namespace chromeos {
38 38
39 namespace { 39 namespace {
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 LOG(ERROR) << "Can not import non-existing user " << user_id; 232 LOG(ERROR) << "Can not import non-existing user " << user_id;
233 return; 233 return;
234 } 234 }
235 base::string16 display_name; 235 base::string16 display_name;
236 std::string master_key; 236 std::string master_key;
237 std::string signature_key; 237 std::string signature_key;
238 std::string encryption_key; 238 std::string encryption_key;
239 std::string avatar; 239 std::string avatar;
240 bool exists; 240 bool exists;
241 int avatar_index = ManagedUserCreationController::kDummyAvatarIndex; 241 int avatar_index = ManagedUserCreationController::kDummyAvatarIndex;
242 user_info->GetString(ManagedUserSyncService::kName, &display_name); 242 user_info->GetString(SupervisedUserSyncService::kName, &display_name);
243 user_info->GetString(ManagedUserSyncService::kMasterKey, &master_key); 243 user_info->GetString(SupervisedUserSyncService::kMasterKey, &master_key);
244 user_info->GetString(ManagedUserSyncService::kPasswordSignatureKey, 244 user_info->GetString(SupervisedUserSyncService::kPasswordSignatureKey,
245 &signature_key); 245 &signature_key);
246 user_info->GetString(ManagedUserSyncService::kPasswordEncryptionKey, 246 user_info->GetString(SupervisedUserSyncService::kPasswordEncryptionKey,
247 &encryption_key); 247 &encryption_key);
248 user_info->GetString(ManagedUserSyncService::kChromeOsAvatar, &avatar); 248 user_info->GetString(SupervisedUserSyncService::kChromeOsAvatar, &avatar);
249 user_info->GetBoolean(kUserExists, &exists); 249 user_info->GetBoolean(kUserExists, &exists);
250 250
251 // We should not get here with existing user selected, so just display error. 251 // We should not get here with existing user selected, so just display error.
252 if (exists) { 252 if (exists) {
253 actor_->ShowErrorPage( 253 actor_->ShowErrorPage(
254 l10n_util::GetStringUTF16( 254 l10n_util::GetStringUTF16(
255 IDS_CREATE_LOCALLY_MANAGED_USER_GENERIC_ERROR_TITLE), 255 IDS_CREATE_LOCALLY_MANAGED_USER_GENERIC_ERROR_TITLE),
256 l10n_util::GetStringUTF16( 256 l10n_util::GetStringUTF16(
257 IDS_CREATE_LOCALLY_MANAGED_USER_GENERIC_ERROR), 257 IDS_CREATE_LOCALLY_MANAGED_USER_GENERIC_ERROR),
258 l10n_util::GetStringUTF16( 258 l10n_util::GetStringUTF16(
259 IDS_CREATE_LOCALLY_MANAGED_USER_GENERIC_ERROR_BUTTON)); 259 IDS_CREATE_LOCALLY_MANAGED_USER_GENERIC_ERROR_BUTTON));
260 return; 260 return;
261 } 261 }
262 262
263 ManagedUserSyncService::GetAvatarIndex(avatar, &avatar_index); 263 SupervisedUserSyncService::GetAvatarIndex(avatar, &avatar_index);
264 264
265 const base::DictionaryValue* password_data = NULL; 265 const base::DictionaryValue* password_data = NULL;
266 ManagedUserSharedSettingsService* shared_settings_service = 266 SupervisedUserSharedSettingsService* shared_settings_service =
267 ManagedUserSharedSettingsServiceFactory::GetForBrowserContext( 267 SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext(
268 controller_->GetManagerProfile()); 268 controller_->GetManagerProfile());
269 const base::Value* value = shared_settings_service->GetValue( 269 const base::Value* value = shared_settings_service->GetValue(
270 user_id, managed_users::kChromeOSPasswordData); 270 user_id, supervised_users::kChromeOSPasswordData);
271 271
272 bool password_right_here = value && value->GetAsDictionary(&password_data) && 272 bool password_right_here = value && value->GetAsDictionary(&password_data) &&
273 !password_data->empty(); 273 !password_data->empty();
274 274
275 if (password_right_here) { 275 if (password_right_here) {
276 controller_->StartImport(display_name, 276 controller_->StartImport(display_name,
277 avatar_index, 277 avatar_index,
278 user_id, 278 user_id,
279 master_key, 279 master_key,
280 password_data, 280 password_data,
(...skipping 15 matching lines...) Expand all
296 base::DictionaryValue* user_info; 296 base::DictionaryValue* user_info;
297 if (!existing_users_->GetDictionary(user_id, &user_info)) { 297 if (!existing_users_->GetDictionary(user_id, &user_info)) {
298 LOG(ERROR) << "Can not import non-existing user " << user_id; 298 LOG(ERROR) << "Can not import non-existing user " << user_id;
299 return; 299 return;
300 } 300 }
301 base::string16 display_name; 301 base::string16 display_name;
302 std::string master_key; 302 std::string master_key;
303 std::string avatar; 303 std::string avatar;
304 bool exists; 304 bool exists;
305 int avatar_index = ManagedUserCreationController::kDummyAvatarIndex; 305 int avatar_index = ManagedUserCreationController::kDummyAvatarIndex;
306 user_info->GetString(ManagedUserSyncService::kName, &display_name); 306 user_info->GetString(SupervisedUserSyncService::kName, &display_name);
307 user_info->GetString(ManagedUserSyncService::kMasterKey, &master_key); 307 user_info->GetString(SupervisedUserSyncService::kMasterKey, &master_key);
308 user_info->GetString(ManagedUserSyncService::kChromeOsAvatar, &avatar); 308 user_info->GetString(SupervisedUserSyncService::kChromeOsAvatar, &avatar);
309 user_info->GetBoolean(kUserExists, &exists); 309 user_info->GetBoolean(kUserExists, &exists);
310 310
311 // We should not get here with existing user selected, so just display error. 311 // We should not get here with existing user selected, so just display error.
312 if (exists) { 312 if (exists) {
313 actor_->ShowErrorPage( 313 actor_->ShowErrorPage(
314 l10n_util::GetStringUTF16( 314 l10n_util::GetStringUTF16(
315 IDS_CREATE_LOCALLY_MANAGED_USER_GENERIC_ERROR_TITLE), 315 IDS_CREATE_LOCALLY_MANAGED_USER_GENERIC_ERROR_TITLE),
316 l10n_util::GetStringUTF16( 316 l10n_util::GetStringUTF16(
317 IDS_CREATE_LOCALLY_MANAGED_USER_GENERIC_ERROR), 317 IDS_CREATE_LOCALLY_MANAGED_USER_GENERIC_ERROR),
318 l10n_util::GetStringUTF16( 318 l10n_util::GetStringUTF16(
319 IDS_CREATE_LOCALLY_MANAGED_USER_GENERIC_ERROR_BUTTON)); 319 IDS_CREATE_LOCALLY_MANAGED_USER_GENERIC_ERROR_BUTTON));
320 return; 320 return;
321 } 321 }
322 322
323 ManagedUserSyncService::GetAvatarIndex(avatar, &avatar_index); 323 SupervisedUserSyncService::GetAvatarIndex(avatar, &avatar_index);
324 324
325 controller_->StartImport(display_name, 325 controller_->StartImport(display_name,
326 password, 326 password,
327 avatar_index, 327 avatar_index,
328 user_id, 328 user_id,
329 master_key); 329 master_key);
330 } 330 }
331 331
332 void LocallyManagedUserCreationScreen::OnManagerLoginFailure() { 332 void LocallyManagedUserCreationScreen::OnManagerLoginFailure() {
333 if (actor_) 333 if (actor_)
334 actor_->ShowManagerPasswordError(); 334 actor_->ShowManagerPasswordError();
335 } 335 }
336 336
337 void LocallyManagedUserCreationScreen::OnManagerFullyAuthenticated( 337 void LocallyManagedUserCreationScreen::OnManagerFullyAuthenticated(
338 Profile* manager_profile) { 338 Profile* manager_profile) {
339 DCHECK(controller_.get()); 339 DCHECK(controller_.get());
340 // For manager user, move desktop to locked container so that windows created 340 // For manager user, move desktop to locked container so that windows created
341 // during the user image picker step are below it. 341 // during the user image picker step are below it.
342 ash::Shell::GetInstance()-> 342 ash::Shell::GetInstance()->
343 desktop_background_controller()->MoveDesktopToLockedContainer(); 343 desktop_background_controller()->MoveDesktopToLockedContainer();
344 344
345 controller_->SetManagerProfile(manager_profile); 345 controller_->SetManagerProfile(manager_profile);
346 if (actor_) 346 if (actor_)
347 actor_->ShowUsernamePage(); 347 actor_->ShowUsernamePage();
348 348
349 last_page_ = kNameOfNewUserParametersScreen; 349 last_page_ = kNameOfNewUserParametersScreen;
350 CHECK(!sync_service_); 350 CHECK(!sync_service_);
351 sync_service_ = ManagedUserSyncServiceFactory::GetForProfile(manager_profile); 351 sync_service_ = SupervisedUserSyncServiceFactory::GetForProfile(
352 manager_profile);
352 sync_service_->AddObserver(this); 353 sync_service_->AddObserver(this);
353 OnManagedUsersChanged(); 354 OnSupervisedUsersChanged();
354 } 355 }
355 356
356 void LocallyManagedUserCreationScreen::OnManagedUsersChanged() { 357 void LocallyManagedUserCreationScreen::OnSupervisedUsersChanged() {
357 CHECK(sync_service_); 358 CHECK(sync_service_);
358 sync_service_->GetManagedUsersAsync( 359 sync_service_->GetSupervisedUsersAsync(
359 base::Bind(&LocallyManagedUserCreationScreen::OnGetManagedUsers, 360 base::Bind(&LocallyManagedUserCreationScreen::OnGetManagedUsers,
360 weak_factory_.GetWeakPtr())); 361 weak_factory_.GetWeakPtr()));
361 } 362 }
362 363
363 void LocallyManagedUserCreationScreen::OnManagerCryptohomeAuthenticated() { 364 void LocallyManagedUserCreationScreen::OnManagerCryptohomeAuthenticated() {
364 if (actor_) { 365 if (actor_) {
365 actor_->ShowStatusMessage(true /* progress */, l10n_util::GetStringUTF16( 366 actor_->ShowStatusMessage(true /* progress */, l10n_util::GetStringUTF16(
366 IDS_CREATE_LOCALLY_MANAGED_USER_CREATION_AUTH_PROGRESS_MESSAGE)); 367 IDS_CREATE_LOCALLY_MANAGED_USER_CREATION_AUTH_PROGRESS_MESSAGE));
367 } 368 }
368 } 369 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 bool LocallyManagedUserCreationScreen::FindUserByDisplayName( 425 bool LocallyManagedUserCreationScreen::FindUserByDisplayName(
425 const base::string16& display_name, 426 const base::string16& display_name,
426 std::string *out_id) const { 427 std::string *out_id) const {
427 if (!existing_users_.get()) 428 if (!existing_users_.get())
428 return false; 429 return false;
429 for (base::DictionaryValue::Iterator it(*existing_users_.get()); 430 for (base::DictionaryValue::Iterator it(*existing_users_.get());
430 !it.IsAtEnd(); it.Advance()) { 431 !it.IsAtEnd(); it.Advance()) {
431 const base::DictionaryValue* user_info = 432 const base::DictionaryValue* user_info =
432 static_cast<const base::DictionaryValue*>(&it.value()); 433 static_cast<const base::DictionaryValue*>(&it.value());
433 base::string16 user_display_name; 434 base::string16 user_display_name;
434 if (user_info->GetString(ManagedUserSyncService::kName, 435 if (user_info->GetString(SupervisedUserSyncService::kName,
435 &user_display_name)) { 436 &user_display_name)) {
436 if (display_name == user_display_name) { 437 if (display_name == user_display_name) {
437 if (out_id) 438 if (out_id)
438 *out_id = it.key(); 439 *out_id = it.key();
439 return true; 440 return true;
440 } 441 }
441 } 442 }
442 } 443 }
443 return false; 444 return false;
444 } 445 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 // Copy that would be stored in this class. 496 // Copy that would be stored in this class.
496 base::DictionaryValue* local_copy = 497 base::DictionaryValue* local_copy =
497 static_cast<base::DictionaryValue*>(it.value().DeepCopy()); 498 static_cast<base::DictionaryValue*>(it.value().DeepCopy());
498 // Copy that would be passed to WebUI. It has some extra values for 499 // Copy that would be passed to WebUI. It has some extra values for
499 // displaying, but does not contain sensitive data, such as master password. 500 // displaying, but does not contain sensitive data, such as master password.
500 base::DictionaryValue* ui_copy = 501 base::DictionaryValue* ui_copy =
501 static_cast<base::DictionaryValue*>(new base::DictionaryValue()); 502 static_cast<base::DictionaryValue*>(new base::DictionaryValue());
502 503
503 int avatar_index = ManagedUserCreationController::kDummyAvatarIndex; 504 int avatar_index = ManagedUserCreationController::kDummyAvatarIndex;
504 std::string chromeos_avatar; 505 std::string chromeos_avatar;
505 if (local_copy->GetString(ManagedUserSyncService::kChromeOsAvatar, 506 if (local_copy->GetString(SupervisedUserSyncService::kChromeOsAvatar,
506 &chromeos_avatar) && 507 &chromeos_avatar) &&
507 !chromeos_avatar.empty() && 508 !chromeos_avatar.empty() &&
508 ManagedUserSyncService::GetAvatarIndex( 509 SupervisedUserSyncService::GetAvatarIndex(
509 chromeos_avatar, &avatar_index)) { 510 chromeos_avatar, &avatar_index)) {
510 ui_copy->SetString(kAvatarURLKey, GetDefaultImageUrl(avatar_index)); 511 ui_copy->SetString(kAvatarURLKey, GetDefaultImageUrl(avatar_index));
511 } else { 512 } else {
512 int i = base::RandInt(kFirstDefaultImageIndex, kDefaultImagesCount - 1); 513 int i = base::RandInt(kFirstDefaultImageIndex, kDefaultImagesCount - 1);
513 local_copy->SetString( 514 local_copy->SetString(
514 ManagedUserSyncService::kChromeOsAvatar, 515 SupervisedUserSyncService::kChromeOsAvatar,
515 ManagedUserSyncService::BuildAvatarString(i)); 516 SupervisedUserSyncService::BuildAvatarString(i));
516 local_copy->SetBoolean(kRandomAvatarKey, true); 517 local_copy->SetBoolean(kRandomAvatarKey, true);
517 ui_copy->SetString(kAvatarURLKey, GetDefaultImageUrl(i)); 518 ui_copy->SetString(kAvatarURLKey, GetDefaultImageUrl(i));
518 } 519 }
519 520
520 local_copy->SetBoolean(kUserExists, false); 521 local_copy->SetBoolean(kUserExists, false);
521 ui_copy->SetBoolean(kUserExists, false); 522 ui_copy->SetBoolean(kUserExists, false);
522 523
523 base::string16 display_name; 524 base::string16 display_name;
524 local_copy->GetString(ManagedUserSyncService::kName, &display_name); 525 local_copy->GetString(SupervisedUserSyncService::kName, &display_name);
525 526
526 if (supervised_user_manager->FindBySyncId(it.key())) { 527 if (supervised_user_manager->FindBySyncId(it.key())) {
527 local_copy->SetBoolean(kUserExists, true); 528 local_copy->SetBoolean(kUserExists, true);
528 ui_copy->SetBoolean(kUserExists, true); 529 ui_copy->SetBoolean(kUserExists, true);
529 local_copy->SetString(kUserConflict, kUserConflictImported); 530 local_copy->SetString(kUserConflict, kUserConflictImported);
530 ui_copy->SetString(kUserConflict, kUserConflictImported); 531 ui_copy->SetString(kUserConflict, kUserConflictImported);
531 } else if (supervised_user_manager->FindByDisplayName(display_name)) { 532 } else if (supervised_user_manager->FindByDisplayName(display_name)) {
532 local_copy->SetBoolean(kUserExists, true); 533 local_copy->SetBoolean(kUserExists, true);
533 ui_copy->SetBoolean(kUserExists, true); 534 ui_copy->SetBoolean(kUserExists, true);
534 local_copy->SetString(kUserConflict, kUserConflictName); 535 local_copy->SetString(kUserConflict, kUserConflictName);
535 ui_copy->SetString(kUserConflict, kUserConflictName); 536 ui_copy->SetString(kUserConflict, kUserConflictName);
536 } 537 }
537 ui_copy->SetString(ManagedUserSyncService::kName, display_name); 538 ui_copy->SetString(SupervisedUserSyncService::kName, display_name);
538 539
539 std::string signature_key; 540 std::string signature_key;
540 bool has_password = 541 bool has_password =
541 local_copy->GetString(ManagedUserSyncService::kPasswordSignatureKey, 542 local_copy->GetString(SupervisedUserSyncService::kPasswordSignatureKey,
542 &signature_key) && 543 &signature_key) &&
543 !signature_key.empty(); 544 !signature_key.empty();
544 545
545 ui_copy->SetBoolean(kUserNeedPassword, !has_password); 546 ui_copy->SetBoolean(kUserNeedPassword, !has_password);
546 ui_copy->SetString("id", it.key()); 547 ui_copy->SetString("id", it.key());
547 548
548 existing_users_->Set(it.key(), local_copy); 549 existing_users_->Set(it.key(), local_copy);
549 ui_users->Append(ui_copy); 550 ui_users->Append(ui_copy);
550 } 551 }
551 actor_->ShowExistingManagedUsers(ui_users.get()); 552 actor_->ShowExistingManagedUsers(ui_users.get());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 selected_image_ = User::kExternalImageIndex; 593 selected_image_ = User::kExternalImageIndex;
593 } else { 594 } else {
594 NOTREACHED() << "Unexpected image type: " << image_type; 595 NOTREACHED() << "Unexpected image type: " << image_type;
595 } 596 }
596 } 597 }
597 598
598 void LocallyManagedUserCreationScreen::OnImageAccepted() { 599 void LocallyManagedUserCreationScreen::OnImageAccepted() {
599 } 600 }
600 601
601 } // namespace chromeos 602 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698