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

Side by Side Diff: chrome/browser/chromeos/login/lock/screen_locker.cc

Issue 2903353003: Adding mojo calls for easy unlock service (Closed)
Patch Set: clean up and trybot 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/lock/screen_locker.h" 5 #include "chrome/browser/chromeos/login/lock/screen_locker.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/login/ui/lock_screen.h" 10 #include "ash/login/ui/lock_screen.h"
(...skipping 11 matching lines...) Expand all
22 #include "base/memory/weak_ptr.h" 22 #include "base/memory/weak_ptr.h"
23 #include "base/message_loop/message_loop.h" 23 #include "base/message_loop/message_loop.h"
24 #include "base/metrics/histogram_macros.h" 24 #include "base/metrics/histogram_macros.h"
25 #include "base/metrics/user_metrics.h" 25 #include "base/metrics/user_metrics.h"
26 #include "base/single_thread_task_runner.h" 26 #include "base/single_thread_task_runner.h"
27 #include "base/strings/string_number_conversions.h" 27 #include "base/strings/string_number_conversions.h"
28 #include "base/strings/string_util.h" 28 #include "base/strings/string_util.h"
29 #include "base/threading/thread_task_runner_handle.h" 29 #include "base/threading/thread_task_runner_handle.h"
30 #include "chrome/browser/chrome_notification_types.h" 30 #include "chrome/browser/chrome_notification_types.h"
31 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" 31 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
32 #include "chrome/browser/chromeos/login/lock/view_screen_locker.h"
32 #include "chrome/browser/chromeos/login/lock/webui_screen_locker.h" 33 #include "chrome/browser/chromeos/login/lock/webui_screen_locker.h"
33 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_factory.h" 34 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_factory.h"
34 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_storage.h" 35 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_storage.h"
35 #include "chrome/browser/chromeos/login/session/user_session_manager.h" 36 #include "chrome/browser/chromeos/login/session/user_session_manager.h"
36 #include "chrome/browser/chromeos/login/supervised/supervised_user_authenticatio n.h" 37 #include "chrome/browser/chromeos/login/supervised/supervised_user_authenticatio n.h"
37 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" 38 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h"
38 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" 39 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
39 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" 40 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
40 #include "chrome/browser/lifetime/application_lifetime.h" 41 #include "chrome/browser/lifetime/application_lifetime.h"
41 #include "chrome/browser/signin/easy_unlock_service.h" 42 #include "chrome/browser/signin/easy_unlock_service.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 ScreenLocker::HandleLockScreenRequest(); 159 ScreenLocker::HandleLockScreenRequest();
159 } 160 }
160 161
161 private: 162 private:
162 bool session_started_; 163 bool session_started_;
163 content::NotificationRegistrar registrar_; 164 content::NotificationRegistrar registrar_;
164 165
165 DISALLOW_COPY_AND_ASSIGN(ScreenLockObserver); 166 DISALLOW_COPY_AND_ASSIGN(ScreenLockObserver);
166 }; 167 };
167 168
168 // Mojo delegate that calls into the views-based lock screen via mojo.
169 class MojoDelegate : public ScreenLocker::Delegate {
170 public:
171 MojoDelegate() = default;
172 ~MojoDelegate() override = default;
173
174 // ScreenLocker::Delegate:
175 void SetPasswordInputEnabled(bool enabled) override { NOTIMPLEMENTED(); }
176 void ShowErrorMessage(int error_msg_id,
177 HelpAppLauncher::HelpTopic help_topic_id) override {
178 // TODO(xiaoyinh): Complete the implementation here.
179 LockScreenClient::Get()->ShowErrorMessage(0 /* login_attempts */,
180 std::string(), std::string(),
181 static_cast<int>(help_topic_id));
182 }
183 void ClearErrors() override { LockScreenClient::Get()->ClearErrors(); }
184 void AnimateAuthenticationSuccess() override { NOTIMPLEMENTED(); }
185 void OnLockWebUIReady() override { NOTIMPLEMENTED(); }
186 void OnLockBackgroundDisplayed() override { NOTIMPLEMENTED(); }
187 void OnHeaderBarVisible() override { NOTIMPLEMENTED(); }
188 void OnAshLockAnimationFinished() override { NOTIMPLEMENTED(); }
189 void SetFingerprintState(const AccountId& account_id,
190 ScreenLocker::FingerprintState state) override {
191 NOTIMPLEMENTED();
192 }
193 content::WebContents* GetWebContents() override { return nullptr; }
194
195 private:
196 DISALLOW_COPY_AND_ASSIGN(MojoDelegate);
197 };
198
199 ScreenLockObserver* g_screen_lock_observer = nullptr; 169 ScreenLockObserver* g_screen_lock_observer = nullptr;
200 170
201 } // namespace 171 } // namespace
202 172
203 // static 173 // static
204 ScreenLocker* ScreenLocker::screen_locker_ = nullptr; 174 ScreenLocker* ScreenLocker::screen_locker_ = nullptr;
205 175
206 ////////////////////////////////////////////////////////////////////////////// 176 //////////////////////////////////////////////////////////////////////////////
207 // ScreenLocker::Delegate, public: 177 // ScreenLocker::Delegate, public:
208 178
(...skipping 24 matching lines...) Expand all
233 void ScreenLocker::Init() { 203 void ScreenLocker::Init() {
234 input_method::InputMethodManager* imm = 204 input_method::InputMethodManager* imm =
235 input_method::InputMethodManager::Get(); 205 input_method::InputMethodManager::Get();
236 saved_ime_state_ = imm->GetActiveIMEState(); 206 saved_ime_state_ = imm->GetActiveIMEState();
237 imm->SetState(saved_ime_state_->Clone()); 207 imm->SetState(saved_ime_state_->Clone());
238 208
239 authenticator_ = UserSessionManager::GetInstance()->CreateAuthenticator(this); 209 authenticator_ = UserSessionManager::GetInstance()->CreateAuthenticator(this);
240 extended_authenticator_ = ExtendedAuthenticator::Create(this); 210 extended_authenticator_ = ExtendedAuthenticator::Create(this);
241 if (IsUsingMdLogin()) { 211 if (IsUsingMdLogin()) {
242 // Create delegate that calls into the views-based lock screen via mojo. 212 // Create delegate that calls into the views-based lock screen via mojo.
243 delegate_ = new MojoDelegate(); 213 view_screen_locker_.reset(new ViewScreenLocker(this));
244 owns_delegate_ = true; 214 delegate_ = view_screen_locker_.get();
215 view_screen_locker_->Init();
245 216
246 // Create and display lock screen. 217 // Create and display lock screen.
247 // TODO(jdufault): Calling ash::ShowLockScreenInWidget should be a mojo 218 // TODO(jdufault): Calling ash::ShowLockScreenInWidget should be a mojo
248 // call. We should only set the session state to locked after the mojo call 219 // call. We should only set the session state to locked after the mojo call
249 // has completed. 220 // has completed.
250 if (ash::ShowLockScreen()) { 221 if (ash::ShowLockScreen()) {
251 session_manager::SessionManager::Get()->SetSessionState( 222 session_manager::SessionManager::Get()->SetSessionState(
252 session_manager::SessionState::LOCKED); 223 session_manager::SessionState::LOCKED);
224 view_screen_locker_->OnLockScreenReady();
jdufault 2017/05/26 18:59:10 Instead of calling directly into view_screen_locke
xiaoyinh(OOO Sep 11-29) 2017/05/30 22:23:50 ViewScreenLocker::OnLockScreenReady will call into
253 } 225 }
254 } else { 226 } else {
255 web_ui_.reset(new WebUIScreenLocker(this)); 227 web_ui_.reset(new WebUIScreenLocker(this));
256 delegate_ = web_ui_.get(); 228 delegate_ = web_ui_.get();
257 owns_delegate_ = false;
258 web_ui_->LockScreen(); 229 web_ui_->LockScreen();
259 230
260 // Ownership of |icon_image_source| is passed. 231 // Ownership of |icon_image_source| is passed.
261 screenlock_icon_provider_ = base::MakeUnique<ScreenlockIconProvider>(); 232 screenlock_icon_provider_ = base::MakeUnique<ScreenlockIconProvider>();
262 ScreenlockIconSource* screenlock_icon_source = 233 ScreenlockIconSource* screenlock_icon_source =
263 new ScreenlockIconSource(screenlock_icon_provider_->AsWeakPtr()); 234 new ScreenlockIconSource(screenlock_icon_provider_->AsWeakPtr());
264 content::URLDataSource::Add(web_ui_->web_contents()->GetBrowserContext(), 235 content::URLDataSource::Add(web_ui_->web_contents()->GetBrowserContext(),
265 screenlock_icon_source); 236 screenlock_icon_source);
266 } 237 }
267 238
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 VLOG(1) << "Calling session manager's HandleLockScreenDismissed D-Bus method"; 583 VLOG(1) << "Calling session manager's HandleLockScreenDismissed D-Bus method";
613 DBusThreadManager::Get()->GetSessionManagerClient()-> 584 DBusThreadManager::Get()->GetSessionManagerClient()->
614 NotifyLockScreenDismissed(); 585 NotifyLockScreenDismissed();
615 586
616 session_manager::SessionManager::Get()->SetSessionState( 587 session_manager::SessionManager::Get()->SetSessionState(
617 session_manager::SessionState::ACTIVE); 588 session_manager::SessionState::ACTIVE);
618 589
619 if (saved_ime_state_.get()) { 590 if (saved_ime_state_.get()) {
620 input_method::InputMethodManager::Get()->SetState(saved_ime_state_); 591 input_method::InputMethodManager::Get()->SetState(saved_ime_state_);
621 } 592 }
622
623 if (owns_delegate_) {
624 owns_delegate_ = false;
625 delete delegate_;
626 delegate_ = nullptr;
627 }
628 } 593 }
629 594
630 void ScreenLocker::SetAuthenticator(Authenticator* authenticator) { 595 void ScreenLocker::SetAuthenticator(Authenticator* authenticator) {
631 authenticator_ = authenticator; 596 authenticator_ = authenticator;
632 } 597 }
633 598
634 void ScreenLocker::ScreenLockReady() { 599 void ScreenLocker::ScreenLockReady() {
635 locked_ = true; 600 locked_ = true;
636 base::TimeDelta delta = base::Time::Now() - start_time_; 601 base::TimeDelta delta = base::Time::Now() - start_time_;
637 VLOG(1) << "ScreenLocker " << this << " is ready after " 602 VLOG(1) << "ScreenLocker " << this << " is ready after "
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 } 683 }
719 } 684 }
720 685
721 if (auth_status_consumer_) { 686 if (auth_status_consumer_) {
722 AuthFailure failure(AuthFailure::UNLOCK_FAILED); 687 AuthFailure failure(AuthFailure::UNLOCK_FAILED);
723 auth_status_consumer_->OnAuthFailure(failure); 688 auth_status_consumer_->OnAuthFailure(failure);
724 } 689 }
725 } 690 }
726 691
727 } // namespace chromeos 692 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698