| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/ui/ash/lock_screen_client.h" | 5 #include "chrome/browser/ui/ash/lock_screen_client.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "ash/public/interfaces/constants.mojom.h" | 9 #include "ash/public/interfaces/constants.mojom.h" |
| 8 #include "chrome/browser/chromeos/login/lock/screen_locker.h" | 10 #include "chrome/browser/chromeos/login/lock/screen_locker.h" |
| 11 #include "chrome/browser/chromeos/login/reauth_stats.h" |
| 12 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
| 9 #include "content/public/common/service_manager_connection.h" | 13 #include "content/public/common/service_manager_connection.h" |
| 10 #include "services/service_manager/public/cpp/connector.h" | 14 #include "services/service_manager/public/cpp/connector.h" |
| 11 | 15 |
| 12 namespace { | 16 namespace { |
| 13 LockScreenClient* g_instance = nullptr; | 17 LockScreenClient* g_instance = nullptr; |
| 14 } // namespace | 18 } // namespace |
| 15 | 19 |
| 16 LockScreenClient::Delegate::Delegate() = default; | 20 LockScreenClient::Delegate::Delegate() = default; |
| 17 LockScreenClient::Delegate::~Delegate() = default; | 21 LockScreenClient::Delegate::~Delegate() = default; |
| 18 | 22 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 36 | 40 |
| 37 // static | 41 // static |
| 38 LockScreenClient* LockScreenClient::Get() { | 42 LockScreenClient* LockScreenClient::Get() { |
| 39 return g_instance; | 43 return g_instance; |
| 40 } | 44 } |
| 41 | 45 |
| 42 void LockScreenClient::AuthenticateUser(const AccountId& account_id, | 46 void LockScreenClient::AuthenticateUser(const AccountId& account_id, |
| 43 const std::string& hashed_password, | 47 const std::string& hashed_password, |
| 44 bool authenticated_by_pin, | 48 bool authenticated_by_pin, |
| 45 AuthenticateUserCallback callback) { | 49 AuthenticateUserCallback callback) { |
| 46 // TODO(xiaoyinh): Complete the implementation below. | 50 if (delegate_) |
| 47 // It should be similar as SigninScreenHandler::HandleAuthenticateUser. | 51 delegate_->HandleAuthenticateUser(account_id, hashed_password, |
| 48 chromeos::UserContext user_context(account_id); | 52 authenticated_by_pin, std::move(callback)); |
| 49 chromeos::Key key(chromeos::Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, | |
| 50 std::string(), hashed_password); | |
| 51 user_context.SetKey(key); | |
| 52 user_context.SetIsUsingPin(authenticated_by_pin); | |
| 53 chromeos::ScreenLocker::default_screen_locker()->Authenticate( | |
| 54 user_context, std::move(callback)); | |
| 55 } | 53 } |
| 56 | 54 |
| 57 void LockScreenClient::ShowLockScreen( | 55 void LockScreenClient::ShowLockScreen( |
| 58 ash::mojom::LockScreen::ShowLockScreenCallback on_shown) { | 56 ash::mojom::LockScreen::ShowLockScreenCallback on_shown) { |
| 59 lock_screen_->ShowLockScreen(std::move(on_shown)); | 57 lock_screen_->ShowLockScreen(std::move(on_shown)); |
| 60 } | 58 } |
| 61 | 59 |
| 62 void LockScreenClient::AttemptUnlock(const AccountId& account_id) { | 60 void LockScreenClient::AttemptUnlock(const AccountId& account_id) { |
| 63 if (!delegate_) | 61 if (delegate_) |
| 64 return; | 62 delegate_->HandleAttemptUnlock(account_id); |
| 65 delegate_->HandleAttemptUnlock(account_id); | |
| 66 } | 63 } |
| 67 | 64 |
| 68 void LockScreenClient::HardlockPod(const AccountId& account_id) { | 65 void LockScreenClient::HardlockPod(const AccountId& account_id) { |
| 69 if (!delegate_) | 66 if (delegate_) |
| 70 return; | 67 delegate_->HandleHardlockPod(account_id); |
| 71 delegate_->HandleHardlockPod(account_id); | |
| 72 } | 68 } |
| 73 | 69 |
| 74 void LockScreenClient::RecordClickOnLockIcon(const AccountId& account_id) { | 70 void LockScreenClient::RecordClickOnLockIcon(const AccountId& account_id) { |
| 75 if (!delegate_) | 71 if (delegate_) |
| 76 return; | 72 delegate_->HandleRecordClickOnLockIcon(account_id); |
| 77 delegate_->HandleRecordClickOnLockIcon(account_id); | 73 } |
| 74 |
| 75 void LockScreenClient::OnFocusPod(const AccountId& account_id) { |
| 76 if (delegate_) |
| 77 delegate_->HandleOnFocusPod(account_id); |
| 78 } |
| 79 |
| 80 void LockScreenClient::OnNoPodFocused() { |
| 81 if (delegate_) |
| 82 delegate_->HandleOnNoPodFocused(); |
| 83 } |
| 84 |
| 85 void LockScreenClient::LoadWallpaper(const AccountId& account_id) { |
| 86 chromeos::WallpaperManager::Get()->SetUserWallpaperDelayed(account_id); |
| 87 } |
| 88 |
| 89 void LockScreenClient::SignOutUser() { |
| 90 chromeos::ScreenLocker::default_screen_locker()->Signout(); |
| 91 } |
| 92 |
| 93 void LockScreenClient::OnMaxIncorrectPasswordAttempted( |
| 94 const AccountId& account_id) { |
| 95 RecordReauthReason(account_id, |
| 96 chromeos::ReauthReason::INCORRECT_PASSWORD_ENTERED); |
| 78 } | 97 } |
| 79 | 98 |
| 80 void LockScreenClient::ShowErrorMessage(int32_t login_attempts, | 99 void LockScreenClient::ShowErrorMessage(int32_t login_attempts, |
| 81 const std::string& error_text, | 100 const std::string& error_text, |
| 82 const std::string& help_link_text, | 101 const std::string& help_link_text, |
| 83 int32_t help_topic_id) { | 102 int32_t help_topic_id) { |
| 84 lock_screen_->ShowErrorMessage(login_attempts, error_text, help_link_text, | 103 lock_screen_->ShowErrorMessage(login_attempts, error_text, help_link_text, |
| 85 help_topic_id); | 104 help_topic_id); |
| 86 } | 105 } |
| 87 | 106 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 103 ash::mojom::AuthType auth_type, | 122 ash::mojom::AuthType auth_type, |
| 104 const base::string16& initial_value) { | 123 const base::string16& initial_value) { |
| 105 lock_screen_->SetAuthType(account_id, auth_type, initial_value); | 124 lock_screen_->SetAuthType(account_id, auth_type, initial_value); |
| 106 } | 125 } |
| 107 | 126 |
| 108 void LockScreenClient::LoadUsers(std::unique_ptr<base::ListValue> users_list, | 127 void LockScreenClient::LoadUsers(std::unique_ptr<base::ListValue> users_list, |
| 109 bool show_guest) { | 128 bool show_guest) { |
| 110 lock_screen_->LoadUsers(std::move(users_list), show_guest); | 129 lock_screen_->LoadUsers(std::move(users_list), show_guest); |
| 111 } | 130 } |
| 112 | 131 |
| 132 void LockScreenClient::SetPinEnabledForUser(const AccountId& account_id, |
| 133 bool is_enabled) { |
| 134 lock_screen_->SetPinEnabledForUser(account_id, is_enabled); |
| 135 } |
| 136 |
| 113 void LockScreenClient::SetDelegate(Delegate* delegate) { | 137 void LockScreenClient::SetDelegate(Delegate* delegate) { |
| 114 delegate_ = delegate; | 138 delegate_ = delegate; |
| 115 } | 139 } |
| OLD | NEW |