Commit 9697017e authored by Quan Nguyen's avatar Quan Nguyen Committed by Commit Bot

cros: Auto-retry external binary auth within a timeout

Bug: 890912
Change-Id: Idc11767c37580c540cbb741a4cce5cabc3a0f29f
Reviewed-on: https://chromium-review.googlesource.com/c/1277989
Commit-Queue: Quan Nguyen <qnnguyen@chromium.org>
Reviewed-by: default avatarJacob Dufault <jdufault@chromium.org>
Cr-Commit-Position: refs/heads/master@{#599337}
parent 80bf4b17
...@@ -777,6 +777,7 @@ void LoginAuthUserView::ButtonPressed(views::Button* sender, ...@@ -777,6 +777,7 @@ void LoginAuthUserView::ButtonPressed(views::Button* sender,
OnOnlineSignInMessageTap(); OnOnlineSignInMessageTap();
} else if (sender == external_binary_auth_button_) { } else if (sender == external_binary_auth_button_) {
password_view_->SetReadOnly(true); password_view_->SetReadOnly(true);
external_binary_auth_button_->SetEnabled(false);
Shell::Get()->login_screen_controller()->AuthenticateUserWithExternalBinary( Shell::Get()->login_screen_controller()->AuthenticateUserWithExternalBinary(
current_user()->basic_user_info->account_id, current_user()->basic_user_info->account_id,
base::BindOnce(&LoginAuthUserView::OnAuthComplete, base::BindOnce(&LoginAuthUserView::OnAuthComplete,
...@@ -812,6 +813,7 @@ void LoginAuthUserView::OnAuthComplete(base::Optional<bool> auth_success) { ...@@ -812,6 +813,7 @@ void LoginAuthUserView::OnAuthComplete(base::Optional<bool> auth_success) {
if (!auth_success.value()) { if (!auth_success.value()) {
password_view_->Clear(); password_view_->Clear();
password_view_->SetReadOnly(false); password_view_->SetReadOnly(false);
external_binary_auth_button_->SetEnabled(true);
} }
on_auth_.Run(auth_success.value()); on_auth_.Run(auth_success.value());
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/i18n/time_formatting.h" #include "base/i18n/time_formatting.h"
#include "base/location.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
...@@ -44,6 +45,8 @@ namespace { ...@@ -44,6 +45,8 @@ namespace {
constexpr char kLockDisplay[] = "lock"; constexpr char kLockDisplay[] = "lock";
constexpr char kExternalBinaryAuth[] = "external_binary_auth"; constexpr char kExternalBinaryAuth[] = "external_binary_auth";
constexpr char kWebCameraDeviceContext[] = "WebCamera: WebCamera"; constexpr char kWebCameraDeviceContext[] = "WebCamera: WebCamera";
constexpr base::TimeDelta kExternalBinaryAuthTimeout =
base::TimeDelta::FromSeconds(2);
ash::mojom::FingerprintUnlockState ConvertFromFingerprintState( ash::mojom::FingerprintUnlockState ConvertFromFingerprintState(
ScreenLocker::FingerprintState state) { ScreenLocker::FingerprintState state) {
...@@ -233,6 +236,10 @@ void ViewsScreenLocker::HandleAuthenticateUserWithExternalBinary( ...@@ -233,6 +236,10 @@ void ViewsScreenLocker::HandleAuthenticateUserWithExternalBinary(
const AccountId& account_id, const AccountId& account_id,
AuthenticateUserWithExternalBinaryCallback callback) { AuthenticateUserWithExternalBinaryCallback callback) {
authenticate_with_external_binary_callback_ = std::move(callback); authenticate_with_external_binary_callback_ = std::move(callback);
external_binary_auth_timer_.Start(
FROM_HERE, kExternalBinaryAuthTimeout,
base::BindOnce(&ViewsScreenLocker::OnExternalBinaryAuthTimeout,
weak_factory_.GetWeakPtr()));
media_analytics_client_->GetState(base::BindOnce( media_analytics_client_->GetState(base::BindOnce(
&StartGraphIfNeeded, media_analytics_client_, kExternalBinaryAuth)); &StartGraphIfNeeded, media_analytics_client_, kExternalBinaryAuth));
} }
...@@ -335,17 +342,14 @@ void ViewsScreenLocker::OnDetectionSignal( ...@@ -335,17 +342,14 @@ void ViewsScreenLocker::OnDetectionSignal(
return; return;
const mri::FramePerception& frame = media_perception.frame_perception(0); const mri::FramePerception& frame = media_perception.frame_perception(0);
if (frame.frame_id() != 1) { if (frame.frame_id() != 1)
// TODO: implement some sort of auto-retry logic.
std::move(authenticate_with_external_binary_callback_)
.Run(false /*auth_success*/);
return; return;
}
mri::State new_state; mri::State new_state;
new_state.set_status(mri::State::SUSPENDED); new_state.set_status(mri::State::SUSPENDED);
media_analytics_client_->SetState(new_state, base::DoNothing()); media_analytics_client_->SetState(new_state, base::DoNothing());
external_binary_auth_timer_.Stop();
std::move(authenticate_with_external_binary_callback_) std::move(authenticate_with_external_binary_callback_)
.Run(true /*auth_success*/); .Run(true /*auth_success*/);
ScreenLocker::Hide(); ScreenLocker::Hide();
...@@ -376,4 +380,12 @@ void ViewsScreenLocker::OnPinCanAuthenticate(const AccountId& account_id, ...@@ -376,4 +380,12 @@ void ViewsScreenLocker::OnPinCanAuthenticate(const AccountId& account_id,
account_id, can_authenticate); account_id, can_authenticate);
} }
void ViewsScreenLocker::OnExternalBinaryAuthTimeout() {
std::move(authenticate_with_external_binary_callback_)
.Run(false /*auth_success*/);
mri::State new_state;
new_state.set_status(mri::State::SUSPENDED);
media_analytics_client_->SetState(new_state, base::DoNothing());
}
} // namespace chromeos } // namespace chromeos
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/scoped_observer.h" #include "base/scoped_observer.h"
#include "base/timer/timer.h"
#include "chrome/browser/chromeos/lock_screen_apps/focus_cycler_delegate.h" #include "chrome/browser/chromeos/lock_screen_apps/focus_cycler_delegate.h"
#include "chrome/browser/chromeos/login/lock/screen_locker.h" #include "chrome/browser/chromeos/login/lock/screen_locker.h"
#include "chrome/browser/chromeos/settings/cros_settings.h" #include "chrome/browser/chromeos/settings/cros_settings.h"
...@@ -89,6 +90,7 @@ class ViewsScreenLocker : public LoginScreenClient::Delegate, ...@@ -89,6 +90,7 @@ class ViewsScreenLocker : public LoginScreenClient::Delegate,
void UpdatePinKeyboardState(const AccountId& account_id); void UpdatePinKeyboardState(const AccountId& account_id);
void OnAllowedInputMethodsChanged(); void OnAllowedInputMethodsChanged();
void OnPinCanAuthenticate(const AccountId& account_id, bool can_authenticate); void OnPinCanAuthenticate(const AccountId& account_id, bool can_authenticate);
void OnExternalBinaryAuthTimeout();
std::unique_ptr<UserBoardViewMojo> user_board_view_mojo_; std::unique_ptr<UserBoardViewMojo> user_board_view_mojo_;
std::unique_ptr<UserSelectionScreen> user_selection_screen_; std::unique_ptr<UserSelectionScreen> user_selection_screen_;
...@@ -121,6 +123,10 @@ class ViewsScreenLocker : public LoginScreenClient::Delegate, ...@@ -121,6 +123,10 @@ class ViewsScreenLocker : public LoginScreenClient::Delegate,
chromeos::MediaAnalyticsClient* media_analytics_client_; chromeos::MediaAnalyticsClient* media_analytics_client_;
// Timer for external binary auth attempt. Allows repeated auth attempts up to
// a specific timeout.
base::OneShotTimer external_binary_auth_timer_;
ScopedObserver<chromeos::MediaAnalyticsClient, ViewsScreenLocker> ScopedObserver<chromeos::MediaAnalyticsClient, ViewsScreenLocker>
scoped_observer_{this}; scoped_observer_{this};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment