Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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)); |
|
xiyuan
2017/05/31 17:51:18
nit: view_screen_locker_ = base::MakeUnique<ViewSc
xiaoyinh(OOO Sep 11-29)
2017/06/02 23:42:28
Done.
| |
| 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 view_screen_locker_->OnLockScreenReady(); |
| 252 session_manager::SessionState::LOCKED); | |
| 253 } | |
| 254 } else { | 223 } else { |
| 255 web_ui_.reset(new WebUIScreenLocker(this)); | 224 web_ui_.reset(new WebUIScreenLocker(this)); |
| 256 delegate_ = web_ui_.get(); | 225 delegate_ = web_ui_.get(); |
| 257 owns_delegate_ = false; | |
| 258 web_ui_->LockScreen(); | 226 web_ui_->LockScreen(); |
| 259 | 227 |
| 260 // Ownership of |icon_image_source| is passed. | 228 // Ownership of |icon_image_source| is passed. |
| 261 screenlock_icon_provider_ = base::MakeUnique<ScreenlockIconProvider>(); | 229 screenlock_icon_provider_ = base::MakeUnique<ScreenlockIconProvider>(); |
| 262 ScreenlockIconSource* screenlock_icon_source = | 230 ScreenlockIconSource* screenlock_icon_source = |
| 263 new ScreenlockIconSource(screenlock_icon_provider_->AsWeakPtr()); | 231 new ScreenlockIconSource(screenlock_icon_provider_->AsWeakPtr()); |
| 264 content::URLDataSource::Add(web_ui_->web_contents()->GetBrowserContext(), | 232 content::URLDataSource::Add(web_ui_->web_contents()->GetBrowserContext(), |
| 265 screenlock_icon_source); | 233 screenlock_icon_source); |
| 266 } | 234 } |
| 267 | 235 |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 612 VLOG(1) << "Calling session manager's HandleLockScreenDismissed D-Bus method"; | 580 VLOG(1) << "Calling session manager's HandleLockScreenDismissed D-Bus method"; |
| 613 DBusThreadManager::Get()->GetSessionManagerClient()-> | 581 DBusThreadManager::Get()->GetSessionManagerClient()-> |
| 614 NotifyLockScreenDismissed(); | 582 NotifyLockScreenDismissed(); |
| 615 | 583 |
| 616 session_manager::SessionManager::Get()->SetSessionState( | 584 session_manager::SessionManager::Get()->SetSessionState( |
| 617 session_manager::SessionState::ACTIVE); | 585 session_manager::SessionState::ACTIVE); |
| 618 | 586 |
| 619 if (saved_ime_state_.get()) { | 587 if (saved_ime_state_.get()) { |
| 620 input_method::InputMethodManager::Get()->SetState(saved_ime_state_); | 588 input_method::InputMethodManager::Get()->SetState(saved_ime_state_); |
| 621 } | 589 } |
| 622 | |
| 623 if (owns_delegate_) { | |
| 624 owns_delegate_ = false; | |
| 625 delete delegate_; | |
| 626 delegate_ = nullptr; | |
| 627 } | |
| 628 } | 590 } |
| 629 | 591 |
| 630 void ScreenLocker::SetAuthenticator(Authenticator* authenticator) { | 592 void ScreenLocker::SetAuthenticator(Authenticator* authenticator) { |
| 631 authenticator_ = authenticator; | 593 authenticator_ = authenticator; |
| 632 } | 594 } |
| 633 | 595 |
| 634 void ScreenLocker::ScreenLockReady() { | 596 void ScreenLocker::ScreenLockReady() { |
| 635 locked_ = true; | 597 locked_ = true; |
| 636 base::TimeDelta delta = base::Time::Now() - start_time_; | 598 base::TimeDelta delta = base::Time::Now() - start_time_; |
| 637 VLOG(1) << "ScreenLocker " << this << " is ready after " | 599 VLOG(1) << "ScreenLocker " << this << " is ready after " |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 718 } | 680 } |
| 719 } | 681 } |
| 720 | 682 |
| 721 if (auth_status_consumer_) { | 683 if (auth_status_consumer_) { |
| 722 AuthFailure failure(AuthFailure::UNLOCK_FAILED); | 684 AuthFailure failure(AuthFailure::UNLOCK_FAILED); |
| 723 auth_status_consumer_->OnAuthFailure(failure); | 685 auth_status_consumer_->OnAuthFailure(failure); |
| 724 } | 686 } |
| 725 } | 687 } |
| 726 | 688 |
| 727 } // namespace chromeos | 689 } // namespace chromeos |
| OLD | NEW |