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

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

Issue 2903353003: Adding mojo calls for easy unlock service (Closed)
Patch Set: incoporate 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 "chrome/browser/ui/ash/lock_screen_client.h" 5 #include "chrome/browser/ui/ash/lock_screen_client.h"
6 6
7 #include "ash/public/interfaces/constants.mojom.h" 7 #include "ash/public/interfaces/constants.mojom.h"
8 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/chromeos/login/lock/screen_locker.h" 9 #include "chrome/browser/chromeos/login/lock/screen_locker.h"
9 #include "content/public/common/service_manager_connection.h" 10 #include "content/public/common/service_manager_connection.h"
10 #include "services/service_manager/public/cpp/connector.h" 11 #include "services/service_manager/public/cpp/connector.h"
11 12
12 namespace { 13 namespace {
13 LockScreenClient* g_instance = nullptr; 14 LockScreenClient* g_instance = nullptr;
14 } // namespace 15 } // namespace
15 16
17 LockScreenClient::Delegate::Delegate() = default;
18 LockScreenClient::Delegate::~Delegate() = default;
19
16 LockScreenClient::LockScreenClient() : binding_(this) { 20 LockScreenClient::LockScreenClient() : binding_(this) {
17 content::ServiceManagerConnection::GetForProcess() 21 content::ServiceManagerConnection::GetForProcess()
18 ->GetConnector() 22 ->GetConnector()
19 ->BindInterface(ash::mojom::kServiceName, &lock_screen_); 23 ->BindInterface(ash::mojom::kServiceName, &lock_screen_);
20 // Register this object as the client interface implementation. 24 // Register this object as the client interface implementation.
21 lock_screen_->SetClient(binding_.CreateInterfacePtrAndBind()); 25 lock_screen_->SetClient(binding_.CreateInterfacePtrAndBind());
22 26
23 DCHECK(!g_instance); 27 DCHECK(!g_instance);
24 g_instance = this; 28 g_instance = this;
25 } 29 }
(...skipping 14 matching lines...) Expand all
40 // TODO(xiaoyinh): Complete the implementation below. 44 // TODO(xiaoyinh): Complete the implementation below.
41 // It should be similar as SigninScreenHandler::HandleAuthenticateUser. 45 // It should be similar as SigninScreenHandler::HandleAuthenticateUser.
42 chromeos::UserContext user_context(account_id); 46 chromeos::UserContext user_context(account_id);
43 chromeos::Key key(chromeos::Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, 47 chromeos::Key key(chromeos::Key::KEY_TYPE_SALTED_SHA256_TOP_HALF,
44 std::string(), hashed_password); 48 std::string(), hashed_password);
45 user_context.SetKey(key); 49 user_context.SetKey(key);
46 user_context.SetIsUsingPin(authenticated_by_pin); 50 user_context.SetIsUsingPin(authenticated_by_pin);
47 chromeos::ScreenLocker::default_screen_locker()->Authenticate(user_context); 51 chromeos::ScreenLocker::default_screen_locker()->Authenticate(user_context);
48 } 52 }
49 53
54 void LockScreenClient::AttemptUnlock(const AccountId& account_id) {
55 if (!delegate_)
56 return;
57 delegate_->HandleAttemptUnlock(account_id);
58 }
59
60 void LockScreenClient::HardlockPod(const AccountId& account_id) {
61 if (!delegate_)
62 return;
63 delegate_->HandleHardlockPod(account_id);
64 }
65
66 void LockScreenClient::RecordClickOnLockIcon(const AccountId& account_id) {
67 if (!delegate_)
68 return;
69 delegate_->HandleRecordClickOnLockIcon(account_id);
70 }
71
50 void LockScreenClient::ShowErrorMessage(int32_t login_attempts, 72 void LockScreenClient::ShowErrorMessage(int32_t login_attempts,
51 const std::string& error_text, 73 const std::string& error_text,
52 const std::string& help_link_text, 74 const std::string& help_link_text,
53 int32_t help_topic_id) { 75 int32_t help_topic_id) {
54 lock_screen_->ShowErrorMessage(login_attempts, error_text, help_link_text, 76 lock_screen_->ShowErrorMessage(login_attempts, error_text, help_link_text,
55 help_topic_id); 77 help_topic_id);
56 } 78 }
57 79
58 void LockScreenClient::ClearErrors() { 80 void LockScreenClient::ClearErrors() {
59 lock_screen_->ClearErrors(); 81 lock_screen_->ClearErrors();
60 } 82 }
83
84 void LockScreenClient::LoadUsers(const base::ListValue& users_list,
85 bool show_guest) {
86 lock_screen_->LoadUsers(base::MakeUnique<base::ListValue>(users_list),
87 show_guest);
88 }
89
90 void LockScreenClient::SetDelegate(Delegate* delegate) {
91 delegate_ = delegate;
92 }
93
94 void LockScreenClient::ShowUserPodCustomIcon(
95 const AccountId& account_id,
96 const base::DictionaryValue& icon) {
97 lock_screen_->ShowUserPodCustomIcon(
98 account_id, base::MakeUnique<base::DictionaryValue>(icon));
99 }
100 void LockScreenClient::HideUserPodCustomIcon(const AccountId& account_id) {
101 lock_screen_->HideUserPodCustomIcon(account_id);
102 }
103
104 void LockScreenClient::SetAuthType(
105 const AccountId& account_id,
106 proximity_auth::ScreenlockBridge::LockHandler::AuthType auth_type,
107 const base::string16& initial_value) {
108 lock_screen_->SetAuthType(account_id, static_cast<int>(auth_type),
109 base::UTF16ToUTF8(initial_value));
110 }
111
112 base::WeakPtr<chromeos::UserBoardView> LockScreenClient::GetWeakPtr() {
113 return base::WeakPtr<chromeos::UserBoardView>();
114 }
OLDNEW
« chrome/browser/ui/ash/lock_screen_client.h ('K') | « chrome/browser/ui/ash/lock_screen_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698