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

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

Issue 2835473002: Chromad: Allow offline login. (Closed)
Patch Set: Created 3 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
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 <memory> 7 #include <memory>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 #include "chrome/browser/ui/aura/accessibility/automation_manager_aura.h" 50 #include "chrome/browser/ui/aura/accessibility/automation_manager_aura.h"
51 #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h" 51 #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h"
52 #include "chrome/common/channel_info.h" 52 #include "chrome/common/channel_info.h"
53 #include "chrome/common/chrome_switches.h" 53 #include "chrome/common/chrome_switches.h"
54 #include "chrome/common/url_constants.h" 54 #include "chrome/common/url_constants.h"
55 #include "chrome/grit/generated_resources.h" 55 #include "chrome/grit/generated_resources.h"
56 #include "chromeos/chromeos_switches.h" 56 #include "chromeos/chromeos_switches.h"
57 #include "chromeos/dbus/dbus_thread_manager.h" 57 #include "chromeos/dbus/dbus_thread_manager.h"
58 #include "chromeos/dbus/power_manager_client.h" 58 #include "chromeos/dbus/power_manager_client.h"
59 #include "chromeos/dbus/session_manager_client.h" 59 #include "chromeos/dbus/session_manager_client.h"
60 #include "chromeos/login/auth/authpolicy_login_helper.h"
60 #include "chromeos/settings/cros_settings_names.h" 61 #include "chromeos/settings/cros_settings_names.h"
61 #include "components/arc/arc_util.h" 62 #include "components/arc/arc_util.h"
62 #include "components/google/core/browser/google_util.h" 63 #include "components/google/core/browser/google_util.h"
63 #include "components/policy/core/common/cloud/cloud_policy_core.h" 64 #include "components/policy/core/common/cloud/cloud_policy_core.h"
64 #include "components/policy/core/common/cloud/cloud_policy_store.h" 65 #include "components/policy/core/common/cloud/cloud_policy_store.h"
65 #include "components/policy/core/common/policy_map.h" 66 #include "components/policy/core/common/policy_map.h"
66 #include "components/policy/core/common/policy_service.h" 67 #include "components/policy/core/common/policy_service.h"
67 #include "components/policy/core/common/policy_types.h" 68 #include "components/policy/core/common/policy_types.h"
68 #include "components/policy/policy_constants.h" 69 #include "components/policy/policy_constants.h"
69 #include "components/prefs/pref_service.h" 70 #include "components/prefs/pref_service.h"
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 } 376 }
376 DCHECK(login_display_.get()); 377 DCHECK(login_display_.get());
377 } 378 }
378 379
379 //////////////////////////////////////////////////////////////////////////////// 380 ////////////////////////////////////////////////////////////////////////////////
380 // ExistingUserController, LoginDisplay::Delegate implementation: 381 // ExistingUserController, LoginDisplay::Delegate implementation:
381 // 382 //
382 383
383 void ExistingUserController::CancelPasswordChangedFlow() { 384 void ExistingUserController::CancelPasswordChangedFlow() {
384 login_performer_.reset(nullptr); 385 login_performer_.reset(nullptr);
386 if (authpolicy_login_helper_)
387 authpolicy_login_helper_->CancelRequestsAndRestart();
385 PerformLoginFinishedActions(true /* start auto login timer */); 388 PerformLoginFinishedActions(true /* start auto login timer */);
386 } 389 }
387 390
388 void ExistingUserController::CompleteLogin(const UserContext& user_context) { 391 void ExistingUserController::CompleteLogin(const UserContext& user_context) {
389 if (!host_) { 392 if (!host_) {
390 // Complete login event was generated already from UI. Ignore notification. 393 // Complete login event was generated already from UI. Ignore notification.
391 return; 394 return;
392 } 395 }
393 396
394 if (is_login_in_progress_) 397 if (is_login_in_progress_)
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 // Use the same LoginPerformer for subsequent login as it has state 453 // Use the same LoginPerformer for subsequent login as it has state
451 // such as Authenticator instance. 454 // such as Authenticator instance.
452 if (!login_performer_.get() || num_login_attempts_ <= 1) { 455 if (!login_performer_.get() || num_login_attempts_ <= 1) {
453 // Only one instance of LoginPerformer should exist at a time. 456 // Only one instance of LoginPerformer should exist at a time.
454 login_performer_.reset(nullptr); 457 login_performer_.reset(nullptr);
455 login_performer_.reset(new ChromeLoginPerformer(this)); 458 login_performer_.reset(new ChromeLoginPerformer(this));
456 } 459 }
457 policy::BrowserPolicyConnectorChromeOS* connector = 460 policy::BrowserPolicyConnectorChromeOS* connector =
458 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 461 g_browser_process->platform_part()->browser_policy_connector_chromeos();
459 if (connector->IsActiveDirectoryManaged() && 462 if (connector->IsActiveDirectoryManaged() &&
460 user_context.GetAuthFlow() != UserContext::AUTH_FLOW_ACTIVE_DIRECTORY) { 463 user_context.GetUserType() != user_manager::USER_TYPE_ACTIVE_DIRECTORY) {
461 PerformLoginFinishedActions(false /* don't start auto login timer */); 464 PerformLoginFinishedActions(false /* don't start auto login timer */);
462 ShowError(IDS_LOGIN_ERROR_GOOGLE_ACCOUNT_NOT_ALLOWED, 465 ShowError(IDS_LOGIN_ERROR_GOOGLE_ACCOUNT_NOT_ALLOWED,
463 "Google accounts are not allowed on this device"); 466 "Google accounts are not allowed on this device");
464 return; 467 return;
465 } 468 }
469 if (user_context.GetAccountId().GetAccountType() ==
470 AccountType::ACTIVE_DIRECTORY) {
471 DCHECK(user_context.GetKey()->GetKeyType() == Key::KEY_TYPE_PASSWORD_PLAIN);
472 if (!authpolicy_login_helper_)
473 authpolicy_login_helper_ = base::MakeUnique<AuthPolicyLoginHelper>();
474 authpolicy_login_helper_->AuthenticateUser(
475 user_context.GetAccountId().GetUserEmail(),
476 user_context.GetAccountId().GetObjGuid(),
477 user_context.GetKey()->GetSecret(),
478 base::Bind(&ExistingUserController::OnActiveDirectoryAuth,
479 weak_factory_.GetWeakPtr()));
480 }
466 481
467 if (gaia::ExtractDomainName(user_context.GetAccountId().GetUserEmail()) == 482 if (gaia::ExtractDomainName(user_context.GetAccountId().GetUserEmail()) ==
468 user_manager::kSupervisedUserDomain) { 483 user_manager::kSupervisedUserDomain) {
469 login_performer_->LoginAsSupervisedUser(user_context); 484 login_performer_->LoginAsSupervisedUser(user_context);
470 } else { 485 } else {
471 // If a regular user log in to a device which supports ARC, we should make 486 // If a regular user log in to a device which supports ARC, we should make
472 // sure that the user's cryptohome is encrypted in ext4 dircrypto to run the 487 // sure that the user's cryptohome is encrypted in ext4 dircrypto to run the
473 // latest Android runtime. 488 // latest Android runtime.
474 UserContext new_user_context = user_context; 489 UserContext new_user_context = user_context;
475 new_user_context.SetIsForcingDircrypto(ShouldForceDircrypto()); 490 new_user_context.SetIsForcingDircrypto(ShouldForceDircrypto());
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 StartAutoLoginTimer(); 726 StartAutoLoginTimer();
712 } 727 }
713 728
714 // Reset user flow to default, so that special flow will not affect next 729 // Reset user flow to default, so that special flow will not affect next
715 // attempt. 730 // attempt.
716 ChromeUserManager::Get()->ResetUserFlow(last_login_attempt_account_id_); 731 ChromeUserManager::Get()->ResetUserFlow(last_login_attempt_account_id_);
717 732
718 if (auth_status_consumer_) 733 if (auth_status_consumer_)
719 auth_status_consumer_->OnAuthFailure(failure); 734 auth_status_consumer_->OnAuthFailure(failure);
720 735
736 if (authpolicy_login_helper_)
737 authpolicy_login_helper_->CancelRequestsAndRestart();
721 ClearRecordedNames(); 738 ClearRecordedNames();
722 739
723 // TODO(ginkage): Fix this case once crbug.com/469990 is ready. 740 // TODO(ginkage): Fix this case once crbug.com/469990 is ready.
724 /* 741 /*
725 if (failure.reason() == AuthFailure::COULD_NOT_MOUNT_CRYPTOHOME) { 742 if (failure.reason() == AuthFailure::COULD_NOT_MOUNT_CRYPTOHOME) {
726 RecordReauthReason(last_login_attempt_account_id_, 743 RecordReauthReason(last_login_attempt_account_id_,
727 ReauthReason::MISSING_CRYPTOHOME); 744 ReauthReason::MISSING_CRYPTOHOME);
728 } 745 }
729 */ 746 */
730 } 747 }
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 void ExistingUserController::WhiteListCheckFailed(const std::string& email) { 896 void ExistingUserController::WhiteListCheckFailed(const std::string& email) {
880 PerformLoginFinishedActions(true /* start auto login timer */); 897 PerformLoginFinishedActions(true /* start auto login timer */);
881 898
882 login_display_->ShowWhitelistCheckFailedError(); 899 login_display_->ShowWhitelistCheckFailedError();
883 900
884 if (auth_status_consumer_) { 901 if (auth_status_consumer_) {
885 auth_status_consumer_->OnAuthFailure( 902 auth_status_consumer_->OnAuthFailure(
886 AuthFailure(AuthFailure::WHITELIST_CHECK_FAILED)); 903 AuthFailure(AuthFailure::WHITELIST_CHECK_FAILED));
887 } 904 }
888 905
906 if (authpolicy_login_helper_)
907 authpolicy_login_helper_->CancelRequestsAndRestart();
889 ClearRecordedNames(); 908 ClearRecordedNames();
890 } 909 }
891 910
892 void ExistingUserController::PolicyLoadFailed() { 911 void ExistingUserController::PolicyLoadFailed() {
893 ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, ""); 912 ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, "");
894 913
895 PerformLoginFinishedActions(false /* don't start auto login timer */); 914 PerformLoginFinishedActions(false /* don't start auto login timer */);
915 if (authpolicy_login_helper_)
916 authpolicy_login_helper_->CancelRequestsAndRestart();
896 ClearRecordedNames(); 917 ClearRecordedNames();
897 } 918 }
898 919
899 void ExistingUserController::SetAuthFlowOffline(bool offline) { 920 void ExistingUserController::SetAuthFlowOffline(bool offline) {
900 auth_flow_offline_ = offline; 921 auth_flow_offline_ = offline;
901 } 922 }
902 923
903 //////////////////////////////////////////////////////////////////////////////// 924 ////////////////////////////////////////////////////////////////////////////////
904 // ExistingUserController, private: 925 // ExistingUserController, private:
905 926
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
1434 VLOG(1) << "Show unrecoverable cryptohome error dialog."; 1455 VLOG(1) << "Show unrecoverable cryptohome error dialog.";
1435 login_display_->ShowUnrecoverableCrypthomeErrorDialog(); 1456 login_display_->ShowUnrecoverableCrypthomeErrorDialog();
1436 } 1457 }
1437 1458
1438 void ExistingUserController::ClearRecordedNames() { 1459 void ExistingUserController::ClearRecordedNames() {
1439 display_email_.clear(); 1460 display_email_.clear();
1440 display_name_.clear(); 1461 display_name_.clear();
1441 given_name_.clear(); 1462 given_name_.clear();
1442 } 1463 }
1443 1464
1465 void ExistingUserController::OnActiveDirectoryAuth(
1466 authpolicy::ErrorType error,
1467 const authpolicy::ActiveDirectoryAccountData& account_data) {
1468 if (error != authpolicy::ERROR_NONE)
xiyuan 2017/04/20 17:03:24 We would do nothing on auth error?
Roman Sorokin (ftl) 2017/04/21 09:07:34 KeyedService in the follow-up CL would handle that
xiyuan 2017/04/21 14:48:14 Please put the relevant part in CL description. It
Roman Sorokin (ftl) 2017/04/24 16:21:28 Done.
1469 return;
1470 SetDisplayAndGivenName(account_data.display_name(),
xiyuan 2017/04/20 17:03:24 How would we handle the race between OnAuthSuccess
Roman Sorokin (ftl) 2017/04/21 09:07:34 We're actually OK if this won't be called. I added
xiyuan 2017/04/21 14:48:14 ExistingUserController is owned by LoginDisplayHos
Roman Sorokin (ftl) 2017/04/24 16:21:28 Done.
1471 account_data.given_name());
1472 }
1473
1444 } // namespace chromeos 1474 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698