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

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

Issue 220913003: Make supervised user ChromeOS import aware of new password schema. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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/command_line.h" 9 #include "base/command_line.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/chromeos/camera_detector.h" 12 #include "chrome/browser/chromeos/camera_detector.h"
13 #include "chrome/browser/chromeos/login/existing_user_controller.h" 13 #include "chrome/browser/chromeos/login/existing_user_controller.h"
14 #include "chrome/browser/chromeos/login/managed/managed_user_creation_controller .h" 14 #include "chrome/browser/chromeos/login/managed/managed_user_creation_controller .h"
15 #include "chrome/browser/chromeos/login/managed/managed_user_creation_controller _new.h" 15 #include "chrome/browser/chromeos/login/managed/managed_user_creation_controller _new.h"
16 #include "chrome/browser/chromeos/login/managed/managed_user_creation_controller _old.h" 16 #include "chrome/browser/chromeos/login/managed/managed_user_creation_controller _old.h"
17 #include "chrome/browser/chromeos/login/managed/supervised_user_authentication.h " 17 #include "chrome/browser/chromeos/login/managed/supervised_user_authentication.h "
18 #include "chrome/browser/chromeos/login/screens/error_screen.h" 18 #include "chrome/browser/chromeos/login/screens/error_screen.h"
19 #include "chrome/browser/chromeos/login/screens/screen_observer.h" 19 #include "chrome/browser/chromeos/login/screens/screen_observer.h"
20 #include "chrome/browser/chromeos/login/supervised_user_manager.h" 20 #include "chrome/browser/chromeos/login/supervised_user_manager.h"
21 #include "chrome/browser/chromeos/login/user_image.h" 21 #include "chrome/browser/chromeos/login/user_image.h"
22 #include "chrome/browser/chromeos/login/user_image_manager.h" 22 #include "chrome/browser/chromeos/login/user_image_manager.h"
23 #include "chrome/browser/chromeos/login/wizard_controller.h" 23 #include "chrome/browser/chromeos/login/wizard_controller.h"
24 #include "chrome/browser/managed_mode/managed_user_constants.h"
25 #include "chrome/browser/managed_mode/managed_user_shared_settings_service.h"
26 #include "chrome/browser/managed_mode/managed_user_shared_settings_service_facto ry.h"
24 #include "chrome/browser/managed_mode/managed_user_sync_service.h" 27 #include "chrome/browser/managed_mode/managed_user_sync_service.h"
25 #include "chrome/browser/managed_mode/managed_user_sync_service_factory.h" 28 #include "chrome/browser/managed_mode/managed_user_sync_service_factory.h"
26 #include "chrome/common/chrome_switches.h" 29 #include "chrome/common/chrome_switches.h"
27 #include "chromeos/network/network_state.h" 30 #include "chromeos/network/network_state.h"
28 #include "content/public/browser/browser_thread.h" 31 #include "content/public/browser/browser_thread.h"
29 #include "grit/generated_resources.h" 32 #include "grit/generated_resources.h"
30 #include "third_party/skia/include/core/SkBitmap.h" 33 #include "third_party/skia/include/core/SkBitmap.h"
31 #include "ui/base/l10n/l10n_util.h" 34 #include "ui/base/l10n/l10n_util.h"
32 #include "ui/gfx/image/image_skia.h" 35 #include "ui/gfx/image/image_skia.h"
33 36
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 DCHECK(controller_.get()); 222 DCHECK(controller_.get());
220 DCHECK(existing_users_.get()); 223 DCHECK(existing_users_.get());
221 VLOG(1) << "Importing user " << user_id; 224 VLOG(1) << "Importing user " << user_id;
222 base::DictionaryValue* user_info; 225 base::DictionaryValue* user_info;
223 if (!existing_users_->GetDictionary(user_id, &user_info)) { 226 if (!existing_users_->GetDictionary(user_id, &user_info)) {
224 LOG(ERROR) << "Can not import non-existing user " << user_id; 227 LOG(ERROR) << "Can not import non-existing user " << user_id;
225 return; 228 return;
226 } 229 }
227 base::string16 display_name; 230 base::string16 display_name;
228 std::string master_key; 231 std::string master_key;
232 std::string signature_key;
233 std::string encryption_key;
229 std::string avatar; 234 std::string avatar;
230 bool exists; 235 bool exists;
231 int avatar_index = ManagedUserCreationController::kDummyAvatarIndex; 236 int avatar_index = ManagedUserCreationController::kDummyAvatarIndex;
232 user_info->GetString(ManagedUserSyncService::kName, &display_name); 237 user_info->GetString(ManagedUserSyncService::kName, &display_name);
233 user_info->GetString(ManagedUserSyncService::kMasterKey, &master_key); 238 user_info->GetString(ManagedUserSyncService::kMasterKey, &master_key);
239 user_info->GetString(ManagedUserSyncService::kPasswordSignatureKey,
240 &signature_key);
241 user_info->GetString(ManagedUserSyncService::kPasswordEncryptionKey,
242 &encryption_key);
234 user_info->GetString(ManagedUserSyncService::kChromeOsAvatar, &avatar); 243 user_info->GetString(ManagedUserSyncService::kChromeOsAvatar, &avatar);
235 user_info->GetBoolean(kUserExists, &exists); 244 user_info->GetBoolean(kUserExists, &exists);
236 245
237 // We should not get here with existing user selected, so just display error. 246 // We should not get here with existing user selected, so just display error.
238 if (exists) { 247 if (exists) {
239 actor_->ShowErrorPage( 248 actor_->ShowErrorPage(
240 l10n_util::GetStringUTF16( 249 l10n_util::GetStringUTF16(
241 IDS_CREATE_LOCALLY_MANAGED_USER_GENERIC_ERROR_TITLE), 250 IDS_CREATE_LOCALLY_MANAGED_USER_GENERIC_ERROR_TITLE),
242 l10n_util::GetStringUTF16( 251 l10n_util::GetStringUTF16(
243 IDS_CREATE_LOCALLY_MANAGED_USER_GENERIC_ERROR), 252 IDS_CREATE_LOCALLY_MANAGED_USER_GENERIC_ERROR),
244 l10n_util::GetStringUTF16( 253 l10n_util::GetStringUTF16(
245 IDS_CREATE_LOCALLY_MANAGED_USER_GENERIC_ERROR_BUTTON)); 254 IDS_CREATE_LOCALLY_MANAGED_USER_GENERIC_ERROR_BUTTON));
246 return; 255 return;
247 } 256 }
248 257
249 ManagedUserSyncService::GetAvatarIndex(avatar, &avatar_index); 258 ManagedUserSyncService::GetAvatarIndex(avatar, &avatar_index);
250 259
251 controller_->StartImport(display_name, 260 const base::DictionaryValue* password_data = NULL;
252 std::string(), 261 ManagedUserSharedSettingsService* shared_settings_service =
253 avatar_index, 262 ManagedUserSharedSettingsServiceFactory::GetForBrowserContext(
254 user_id, 263 controller_->GetManagerProfile());
255 master_key); 264 const base::Value* value = shared_settings_service->GetValue(
265 user_id, managed_users::kChromeOSPasswordData);
266
267 bool password_right_here = value && value->GetAsDictionary(&password_data) &&
Nikita (slow) 2014/04/03 09:13:08 nit: rename password_right_here to have_password
268 !password_data->empty();
269
270 if (password_right_here) {
271 controller_->StartImport(display_name,
272 avatar_index,
273 user_id,
274 master_key,
275 password_data,
276 encryption_key,
277 signature_key);
278 } else {
279 NOTREACHED() << " Oops, no password";
280 }
256 } 281 }
257 282
258 // TODO(antrim): Code duplication with previous method will be removed once 283 // TODO(antrim): Code duplication with previous method will be removed once
259 // password sync is implemented. 284 // password sync is implemented.
260 void LocallyManagedUserCreationScreen::ImportManagedUserWithPassword( 285 void LocallyManagedUserCreationScreen::ImportManagedUserWithPassword(
261 const std::string& user_id, 286 const std::string& user_id,
262 const std::string& password) { 287 const std::string& password) {
263 DCHECK(controller_.get()); 288 DCHECK(controller_.get());
264 DCHECK(existing_users_.get()); 289 DCHECK(existing_users_.get());
265 VLOG(1) << "Importing user " << user_id; 290 VLOG(1) << "Importing user " << user_id;
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 ui_copy->SetBoolean(kUserExists, true); 521 ui_copy->SetBoolean(kUserExists, true);
497 local_copy->SetString(kUserConflict, kUserConflictImported); 522 local_copy->SetString(kUserConflict, kUserConflictImported);
498 ui_copy->SetString(kUserConflict, kUserConflictImported); 523 ui_copy->SetString(kUserConflict, kUserConflictImported);
499 } else if (supervised_user_manager->FindByDisplayName(display_name)) { 524 } else if (supervised_user_manager->FindByDisplayName(display_name)) {
500 local_copy->SetBoolean(kUserExists, true); 525 local_copy->SetBoolean(kUserExists, true);
501 ui_copy->SetBoolean(kUserExists, true); 526 ui_copy->SetBoolean(kUserExists, true);
502 local_copy->SetString(kUserConflict, kUserConflictName); 527 local_copy->SetString(kUserConflict, kUserConflictName);
503 ui_copy->SetString(kUserConflict, kUserConflictName); 528 ui_copy->SetString(kUserConflict, kUserConflictName);
504 } 529 }
505 ui_copy->SetString(ManagedUserSyncService::kName, display_name); 530 ui_copy->SetString(ManagedUserSyncService::kName, display_name);
506 // TODO(antrim): For now mark all users as having no password. 531
507 ui_copy->SetBoolean(kUserNeedPassword, true); 532 std::string signature_key;
533 bool has_password =
Nikita (slow) 2014/04/03 09:13:08 nit: Not quite clear why variable is called has_pa
534 local_copy->GetString(ManagedUserSyncService::kPasswordSignatureKey,
535 &signature_key) &&
536 !signature_key.empty();
537
538 ui_copy->SetBoolean(kUserNeedPassword, !has_password);
508 ui_copy->SetString("id", it.key()); 539 ui_copy->SetString("id", it.key());
509 540
510 existing_users_->Set(it.key(), local_copy); 541 existing_users_->Set(it.key(), local_copy);
511 ui_users->Append(ui_copy); 542 ui_users->Append(ui_copy);
512 } 543 }
513 actor_->ShowExistingManagedUsers(ui_users.get()); 544 actor_->ShowExistingManagedUsers(ui_users.get());
514 } 545 }
515 546
516 void LocallyManagedUserCreationScreen::OnPhotoTaken( 547 void LocallyManagedUserCreationScreen::OnPhotoTaken(
517 const std::string& raw_data) { 548 const std::string& raw_data) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 selected_image_ = User::kExternalImageIndex; 585 selected_image_ = User::kExternalImageIndex;
555 } else { 586 } else {
556 NOTREACHED() << "Unexpected image type: " << image_type; 587 NOTREACHED() << "Unexpected image type: " << image_type;
557 } 588 }
558 } 589 }
559 590
560 void LocallyManagedUserCreationScreen::OnImageAccepted() { 591 void LocallyManagedUserCreationScreen::OnImageAccepted() {
561 } 592 }
562 593
563 } // namespace chromeos 594 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698