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

Side by Side Diff: chrome/browser/chromeos/login/existing_user_controller.cc

Issue 9286003: Remove AsyncSetOwnerUser() from cryptohome library (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Ready to go. Created 8 years, 10 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/existing_user_controller.h" 5 #include "chrome/browser/chromeos/login/existing_user_controller.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/message_loop.h" 13 #include "base/message_loop.h"
14 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 #include "base/string_util.h" 15 #include "base/string_util.h"
16 #include "base/stringprintf.h" 16 #include "base/stringprintf.h"
17 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" 20 #include "chrome/browser/chromeos/accessibility/accessibility_util.h"
21 #include "chrome/browser/chromeos/boot_times_loader.h" 21 #include "chrome/browser/chromeos/boot_times_loader.h"
22 #include "chrome/browser/chromeos/cros_settings.h" 22 #include "chrome/browser/chromeos/cros_settings.h"
23 #include "chrome/browser/chromeos/cros/cros_library.h" 23 #include "chrome/browser/chromeos/cros/cros_library.h"
24 #include "chrome/browser/chromeos/cros/cryptohome_library.h"
25 #include "chrome/browser/chromeos/cros/network_library.h" 24 #include "chrome/browser/chromeos/cros/network_library.h"
26 #include "chrome/browser/chromeos/customization_document.h" 25 #include "chrome/browser/chromeos/customization_document.h"
27 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" 26 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h"
28 #include "chrome/browser/chromeos/dbus/session_manager_client.h" 27 #include "chrome/browser/chromeos/dbus/session_manager_client.h"
29 #include "chrome/browser/chromeos/login/helper.h" 28 #include "chrome/browser/chromeos/login/helper.h"
30 #include "chrome/browser/chromeos/login/login_display_host.h" 29 #include "chrome/browser/chromeos/login/login_display_host.h"
31 #include "chrome/browser/chromeos/login/login_utils.h" 30 #include "chrome/browser/chromeos/login/login_utils.h"
32 #include "chrome/browser/chromeos/login/user_manager.h" 31 #include "chrome/browser/chromeos/login/user_manager.h"
33 #include "chrome/browser/chromeos/login/wizard_controller.h" 32 #include "chrome/browser/chromeos/login/wizard_controller.h"
34 #include "chrome/browser/chromeos/system/statistics_provider.h" 33 #include "chrome/browser/chromeos/system/statistics_provider.h"
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 ShowEnrollmentScreen(true, username); 310 ShowEnrollmentScreen(true, username);
312 } else { 311 } else {
313 CompleteLoginInternal(username, password); 312 CompleteLoginInternal(username, password);
314 } 313 }
315 } 314 }
316 315
317 void ExistingUserController::CompleteLoginInternal(std::string username, 316 void ExistingUserController::CompleteLoginInternal(std::string username,
318 std::string password) { 317 std::string password) {
319 resume_login_callback_.Reset(); 318 resume_login_callback_.Reset();
320 319
321 SetOwnerUserInCryptohome();
322
323 GaiaAuthConsumer::ClientLoginResult credentials; 320 GaiaAuthConsumer::ClientLoginResult credentials;
324 if (!login_performer_.get()) { 321 if (!login_performer_.get()) {
325 LoginPerformer::Delegate* delegate = this; 322 LoginPerformer::Delegate* delegate = this;
326 if (login_performer_delegate_.get()) 323 if (login_performer_delegate_.get())
327 delegate = login_performer_delegate_.get(); 324 delegate = login_performer_delegate_.get();
328 // Only one instance of LoginPerformer should exist at a time. 325 // Only one instance of LoginPerformer should exist at a time.
329 login_performer_.reset(new LoginPerformer(delegate)); 326 login_performer_.reset(new LoginPerformer(delegate));
330 } 327 }
331 328
332 // If the device is not owned yet, successfully logged in user will be owner. 329 // If the device is not owned yet, successfully logged in user will be owner.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 is_login_in_progress_ = true; 372 is_login_in_progress_ = true;
376 login_performer_->Login(username, password); 373 login_performer_->Login(username, password);
377 accessibility::MaybeSpeak( 374 accessibility::MaybeSpeak(
378 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN)); 375 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN));
379 } 376 }
380 377
381 void ExistingUserController::LoginAsGuest() { 378 void ExistingUserController::LoginAsGuest() {
382 SetStatusAreaEnabled(false); 379 SetStatusAreaEnabled(false);
383 // Disable clicking on other windows. 380 // Disable clicking on other windows.
384 login_display_->SetUIEnabled(false); 381 login_display_->SetUIEnabled(false);
385 SetOwnerUserInCryptohome();
386 382
387 // Check allow_guest in case this call is fired from key accelerator. 383 // Check allow_guest in case this call is fired from key accelerator.
388 // Must not proceed without signature verification. 384 // Must not proceed without signature verification.
389 bool trusted_setting_available = cros_settings_->GetTrusted( 385 bool trusted_setting_available = cros_settings_->GetTrusted(
390 kAccountsPrefAllowGuest, 386 kAccountsPrefAllowGuest,
391 base::Bind(&ExistingUserController::LoginAsGuest, 387 base::Bind(&ExistingUserController::LoginAsGuest,
392 weak_factory_.GetWeakPtr())); 388 weak_factory_.GetWeakPtr()));
393 if (!trusted_setting_available) { 389 if (!trusted_setting_available) {
394 // Value of AllowGuest setting is still not verified. 390 // Value of AllowGuest setting is still not verified.
395 // Another attempt will be invoked again after verification completion. 391 // Another attempt will be invoked again after verification completion.
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 default: 774 default:
779 help_topic_id = login_performer_->login_timed_out() ? 775 help_topic_id = login_performer_->login_timed_out() ?
780 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT_OFFLINE : 776 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT_OFFLINE :
781 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT; 777 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT;
782 break; 778 break;
783 } 779 }
784 780
785 login_display_->ShowError(error_id, num_login_attempts_, help_topic_id); 781 login_display_->ShowError(error_id, num_login_attempts_, help_topic_id);
786 } 782 }
787 783
788 void ExistingUserController::SetOwnerUserInCryptohome() {
789 bool trusted_owner_available = cros_settings_->GetTrusted(
790 kDeviceOwner,
791 base::Bind(&ExistingUserController::SetOwnerUserInCryptohome,
792 weak_factory_.GetWeakPtr()));
793 if (!trusted_owner_available) {
794 // Value of owner email is still not verified.
795 // Another attempt will be invoked after verification completion.
796 return;
797 }
798 CryptohomeLibrary* cryptohomed = CrosLibrary::Get()->GetCryptohomeLibrary();
799 std::string owner;
800 cros_settings_->GetString(kDeviceOwner, &owner);
801 cryptohomed->AsyncSetOwnerUser(owner, NULL);
802
803 // Do not invoke AsyncDoAutomaticFreeDiskSpaceControl(NULL) here
804 // so it does not delay the following mount. Cleanup will be
805 // started in Cryptohomed by timer.
806 }
807
808 void ExistingUserController::ShowGaiaPasswordChanged( 784 void ExistingUserController::ShowGaiaPasswordChanged(
809 const std::string& username) { 785 const std::string& username) {
810 // Invalidate OAuth token, since it can't be correct after password is 786 // Invalidate OAuth token, since it can't be correct after password is
811 // changed. 787 // changed.
812 UserManager::Get()->SaveUserOAuthStatus(username, 788 UserManager::Get()->SaveUserOAuthStatus(username,
813 User::OAUTH_TOKEN_STATUS_INVALID); 789 User::OAUTH_TOKEN_STATUS_INVALID);
814 790
815 login_display_->SetUIEnabled(true); 791 login_display_->SetUIEnabled(true);
816 SetStatusAreaEnabled(true); 792 SetStatusAreaEnabled(true);
817 login_display_->ShowGaiaPasswordChanged(username); 793 login_display_->ShowGaiaPasswordChanged(username);
818 } 794 }
819 795
820 } // namespace chromeos 796 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698