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

Side by Side Diff: chrome/browser/ui/ash/lock_screen_client.cc

Issue 2923773003: Adding mojo calls for several lock screen related operations. (Closed)
Patch Set: comments+rebase 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 "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
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 return;
48 chromeos::UserContext user_context(account_id); 52 delegate_->HandleAuthenticateUser(account_id, hashed_password,
49 chromeos::Key key(chromeos::Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, 53 authenticated_by_pin, std::move(callback));
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 } 54 }
56 55
57 void LockScreenClient::ShowLockScreen( 56 void LockScreenClient::ShowLockScreen(
58 ash::mojom::LockScreen::ShowLockScreenCallback on_shown) { 57 ash::mojom::LockScreen::ShowLockScreenCallback on_shown) {
59 lock_screen_->ShowLockScreen(std::move(on_shown)); 58 lock_screen_->ShowLockScreen(std::move(on_shown));
60 } 59 }
61 60
62 void LockScreenClient::AttemptUnlock(const AccountId& account_id) { 61 void LockScreenClient::AttemptUnlock(const AccountId& account_id) {
63 if (!delegate_) 62 if (!delegate_)
64 return; 63 return;
65 delegate_->HandleAttemptUnlock(account_id); 64 delegate_->HandleAttemptUnlock(account_id);
66 } 65 }
67 66
68 void LockScreenClient::HardlockPod(const AccountId& account_id) { 67 void LockScreenClient::HardlockPod(const AccountId& account_id) {
69 if (!delegate_) 68 if (!delegate_)
70 return; 69 return;
71 delegate_->HandleHardlockPod(account_id); 70 delegate_->HandleHardlockPod(account_id);
72 } 71 }
73 72
74 void LockScreenClient::RecordClickOnLockIcon(const AccountId& account_id) { 73 void LockScreenClient::RecordClickOnLockIcon(const AccountId& account_id) {
75 if (!delegate_) 74 if (!delegate_)
76 return; 75 return;
77 delegate_->HandleRecordClickOnLockIcon(account_id); 76 delegate_->HandleRecordClickOnLockIcon(account_id);
78 } 77 }
79 78
79 void LockScreenClient::OnFocusPod(const AccountId& account_id) {
80 if (!delegate_)
James Cook 2017/06/13 00:58:04 optional: If all these methods do is forward thing
xiaoyinh(OOO Sep 11-29) 2017/06/13 18:36:56 Done.
81 return;
82 delegate_->HandleOnFocusPod(account_id);
83 }
84
85 void LockScreenClient::OnNoPodFocused() {
86 if (!delegate_)
87 return;
88 delegate_->HandleOnNoPodFocused();
89 }
James Cook 2017/06/13 00:58:04 It's a little odd that every mojo method here just
xiaoyinh(OOO Sep 11-29) 2017/06/13 18:36:56 Thanks for the suggestion. Do you mean to have 2 s
James Cook 2017/06/13 20:38:34 It's just something to think about. I established
90
91 void LockScreenClient::LoadWallpaper(const AccountId& account_id) {
92 chromeos::WallpaperManager::Get()->SetUserWallpaperDelayed(account_id);
93 }
94
95 void LockScreenClient::SignOutUser() {
96 chromeos::ScreenLocker::default_screen_locker()->Signout();
97 }
98
99 void LockScreenClient::OnMaxIncorrectPasswordAttempted(
100 const AccountId& account_id) {
101 RecordReauthReason(account_id,
102 chromeos::ReauthReason::INCORRECT_PASSWORD_ENTERED);
103 }
104
80 void LockScreenClient::ShowErrorMessage(int32_t login_attempts, 105 void LockScreenClient::ShowErrorMessage(int32_t login_attempts,
81 const std::string& error_text, 106 const std::string& error_text,
82 const std::string& help_link_text, 107 const std::string& help_link_text,
83 int32_t help_topic_id) { 108 int32_t help_topic_id) {
84 lock_screen_->ShowErrorMessage(login_attempts, error_text, help_link_text, 109 lock_screen_->ShowErrorMessage(login_attempts, error_text, help_link_text,
85 help_topic_id); 110 help_topic_id);
86 } 111 }
87 112
88 void LockScreenClient::ClearErrors() { 113 void LockScreenClient::ClearErrors() {
89 lock_screen_->ClearErrors(); 114 lock_screen_->ClearErrors();
(...skipping 13 matching lines...) Expand all
103 ash::mojom::AuthType auth_type, 128 ash::mojom::AuthType auth_type,
104 const base::string16& initial_value) { 129 const base::string16& initial_value) {
105 lock_screen_->SetAuthType(account_id, auth_type, initial_value); 130 lock_screen_->SetAuthType(account_id, auth_type, initial_value);
106 } 131 }
107 132
108 void LockScreenClient::LoadUsers(std::unique_ptr<base::ListValue> users_list, 133 void LockScreenClient::LoadUsers(std::unique_ptr<base::ListValue> users_list,
109 bool show_guest) { 134 bool show_guest) {
110 lock_screen_->LoadUsers(std::move(users_list), show_guest); 135 lock_screen_->LoadUsers(std::move(users_list), show_guest);
111 } 136 }
112 137
138 void LockScreenClient::SetPinEnabledForUser(const AccountId& account_id,
139 bool is_enabled) {
140 lock_screen_->SetPinEnabledForUser(account_id, is_enabled);
141 }
142
113 void LockScreenClient::SetDelegate(Delegate* delegate) { 143 void LockScreenClient::SetDelegate(Delegate* delegate) {
114 delegate_ = delegate; 144 delegate_ = delegate;
115 } 145 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698