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

Side by Side Diff: ash/login/lock_screen_controller.cc

Issue 2896093003: cros: Make sure views-based lock screen is destroyed after it is dismissed. (Closed)
Patch Set: Address comments Created 3 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
OLDNEW
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 "ash/login/lock_screen_controller.h" 5 #include "ash/login/lock_screen_controller.h"
6 6
7 #include "ash/login/ui/lock_screen.h"
7 #include "chromeos/cryptohome/system_salt_getter.h" 8 #include "chromeos/cryptohome/system_salt_getter.h"
8 #include "chromeos/login/auth/user_context.h" 9 #include "chromeos/login/auth/user_context.h"
9 10
10 namespace ash { 11 namespace ash {
11 12
12 LockScreenController::LockScreenController() = default; 13 LockScreenController::LockScreenController() = default;
13 14
14 LockScreenController::~LockScreenController() = default; 15 LockScreenController::~LockScreenController() = default;
15 16
16 void LockScreenController::BindRequest(mojom::LockScreenRequest request) { 17 void LockScreenController::BindRequest(mojom::LockScreenRequest request) {
17 bindings_.AddBinding(this, std::move(request)); 18 bindings_.AddBinding(this, std::move(request));
18 } 19 }
19 20
20 void LockScreenController::AuthenticateUser(const AccountId& account_id, 21 void LockScreenController::AuthenticateUser(
21 const std::string& password, 22 const AccountId& account_id,
22 bool authenticated_by_pin) { 23 const std::string& password,
24 bool authenticated_by_pin,
25 mojom::LockScreenClient::AuthenticateUserCallback callback) {
23 if (!lock_screen_client_) 26 if (!lock_screen_client_)
24 return; 27 return;
25 28
29 // We cannot execute auth requests directly via GetSystemSalt because it
30 // expects a base::Callback instance, but |callback| is a base::OnceCallback.
31 // Instead, we store |callback| on this object and invoke it locally once we
32 // have the system salt.
33 DCHECK(!pending_user_auth_) << "More than one concurrent auth attempt";
34 pending_user_auth_ = base::BindOnce(
35 &LockScreenController::DoAuthenticateUser, base::Unretained(this),
36 account_id, password, authenticated_by_pin, std::move(callback));
26 chromeos::SystemSaltGetter::Get()->GetSystemSalt(base::Bind( 37 chromeos::SystemSaltGetter::Get()->GetSystemSalt(base::Bind(
27 &LockScreenController::DoAuthenticateUser, base::Unretained(this), 38 &LockScreenController::OnGetSystemSalt, base::Unretained(this)));
28 account_id, password, authenticated_by_pin)); 39 }
40
41 void LockScreenController::ShowLockScreen(ShowLockScreenCallback on_shown) {
42 ::ash::ShowLockScreen();
43 std::move(on_shown).Run(true);
29 } 44 }
30 45
31 void LockScreenController::SetClient(mojom::LockScreenClientPtr client) { 46 void LockScreenController::SetClient(mojom::LockScreenClientPtr client) {
32 lock_screen_client_ = std::move(client); 47 lock_screen_client_ = std::move(client);
33 } 48 }
34 49
35 void LockScreenController::ShowErrorMessage(int32_t login_attempts, 50 void LockScreenController::ShowErrorMessage(int32_t login_attempts,
36 const std::string& error_text, 51 const std::string& error_text,
37 const std::string& help_link_text, 52 const std::string& help_link_text,
38 int32_t help_topic_id) { 53 int32_t help_topic_id) {
39 NOTIMPLEMENTED(); 54 NOTIMPLEMENTED();
40 } 55 }
41 56
42 void LockScreenController::ClearErrors() { 57 void LockScreenController::ClearErrors() {
43 NOTIMPLEMENTED(); 58 NOTIMPLEMENTED();
44 } 59 }
45 60
46 void LockScreenController::DoAuthenticateUser(const AccountId& account_id, 61 void LockScreenController::DoAuthenticateUser(
47 const std::string& password, 62 const AccountId& account_id,
48 bool authenticated_by_pin, 63 const std::string& password,
49 const std::string& system_salt) { 64 bool authenticated_by_pin,
65 mojom::LockScreenClient::AuthenticateUserCallback callback,
66 const std::string& system_salt) {
50 // Hash password before sending through mojo. 67 // Hash password before sending through mojo.
51 // TODO(xiaoyinh): Pin is hashed differently by using a different salt and 68 // TODO(xiaoyinh): Pin is hashed differently by using a different salt and
52 // a different hash algorithm. Update this part in PinStorage. 69 // a different hash algorithm. Update this part in PinStorage.
53 chromeos::Key key(password); 70 chromeos::Key key(password);
54 key.Transform(chromeos::Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, system_salt); 71 key.Transform(chromeos::Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, system_salt);
55 lock_screen_client_->AuthenticateUser(account_id, key.GetSecret(), 72 lock_screen_client_->AuthenticateUser(
56 authenticated_by_pin); 73 account_id, key.GetSecret(), authenticated_by_pin, std::move(callback));
74 }
75
76 void LockScreenController::OnGetSystemSalt(const std::string& system_salt) {
77 std::move(pending_user_auth_).Run(system_salt);
57 } 78 }
58 79
59 } // namespace ash 80 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698