Commit e1e96d4a authored by Quan Nguyen's avatar Quan Nguyen Committed by Commit Bot

cros: Add callouts to DBUS in external binary auth handler.

Full handling of authentication response as well as enrollment will
arrive in later CLs.

Bug: 890912
Change-Id: I9c55403462494d3c188b8ba07fc2d210b2a97a9e
Reviewed-on: https://chromium-review.googlesource.com/c/1255023
Commit-Queue: Quan Nguyen <qnnguyen@chromium.org>
Reviewed-by: default avatarJacob Dufault <jdufault@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596343}
parent 89b09b9c
......@@ -83,6 +83,7 @@ source_set("chromeos") {
"//chromeos:cryptohome_proto",
"//chromeos:cryptohome_signkey_proto",
"//chromeos:login_manager_proto",
"//chromeos:media_perception_proto",
"//chromeos:metrics_event_proto",
"//chromeos:oobe_config_proto",
"//chromeos/assistant:buildflags",
......
......@@ -8,6 +8,7 @@
#include <string>
#include <utility>
#include "ash/public/cpp/ash_features.h"
#include "ash/public/interfaces/login_user_info.mojom.h"
#include "base/bind.h"
#include "base/i18n/time_formatting.h"
......@@ -28,6 +29,7 @@
#include "chrome/browser/ui/ash/wallpaper_controller_client.h"
#include "chrome/common/pref_names.h"
#include "chromeos/components/proximity_auth/screenlock_bridge.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/login/auth/authpolicy_login_helper.h"
#include "components/user_manager/known_user.h"
#include "components/user_manager/user_manager.h"
......@@ -38,6 +40,7 @@ namespace chromeos {
namespace {
constexpr char kLockDisplay[] = "lock";
constexpr char kExternalBinaryAuth[] = "external_binary_auth";
ash::mojom::FingerprintUnlockState ConvertFromFingerprintState(
ScreenLocker::FingerprintState state) {
......@@ -57,11 +60,40 @@ ash::mojom::FingerprintUnlockState ConvertFromFingerprintState(
}
}
void OnSetState(base::Optional<mri::State> maybe_state) {
// TODO/FIXME: add handling for starting the graph process.
NOTIMPLEMENTED();
}
// Starts the graph specified by |configuration| if the current graph
// is SUSPENDED or if the current configuration is different.
void StartGraphIfNeeded(chromeos::MediaAnalyticsClient* client,
const std::string& configuration,
base::Optional<mri::State> maybe_state) {
if (!maybe_state)
return;
if (maybe_state->status() == mri::State::SUSPENDED) {
mri::State new_state;
new_state.set_status(mri::State::RUNNING);
new_state.set_configuration(configuration);
client->SetState(new_state, base::BindOnce(&OnSetState));
} else if (maybe_state->configuration() != configuration) {
mri::State suspend_state;
suspend_state.set_status(mri::State::SUSPENDED);
suspend_state.set_configuration(configuration);
client->SetState(suspend_state, base::BindOnce(&StartGraphIfNeeded, client,
configuration));
}
}
} // namespace
ViewsScreenLocker::ViewsScreenLocker(ScreenLocker* screen_locker)
: screen_locker_(screen_locker),
version_info_updater_(std::make_unique<MojoVersionInfoDispatcher>()),
media_analytics_client_(
chromeos::DBusThreadManager::Get()->GetMediaAnalyticsClient()),
weak_factory_(this) {
LoginScreenClient::Get()->SetDelegate(this);
user_board_view_mojo_ = std::make_unique<UserBoardViewMojo>();
......@@ -74,6 +106,9 @@ ViewsScreenLocker::ViewsScreenLocker(ScreenLocker* screen_locker)
kDeviceLoginScreenInputMethods,
base::Bind(&ViewsScreenLocker::OnAllowedInputMethodsChanged,
base::Unretained(this)));
if (base::FeatureList::IsEnabled(ash::features::kUnlockWithExternalBinary))
scoped_observer_.Add(media_analytics_client_);
}
ViewsScreenLocker::~ViewsScreenLocker() {
......@@ -198,6 +233,8 @@ void ViewsScreenLocker::HandleAuthenticateUserWithPasswordOrPin(
void ViewsScreenLocker::HandleAuthenticateUserWithExternalBinary(
const AccountId& account_id,
AuthenticateUserWithExternalBinaryCallback callback) {
media_analytics_client_->GetState(base::BindOnce(
&StartGraphIfNeeded, media_analytics_client_, kExternalBinaryAuth));
// TODO/FIXME: implement the actual external binary auth check.
bool auth_success = false;
NOTIMPLEMENTED();
......@@ -299,6 +336,13 @@ void ViewsScreenLocker::HandleLockScreenAppFocusOut(bool reverse) {
reverse);
}
void ViewsScreenLocker::OnDetectionSignal(
const mri::MediaPerception& media_perception) {
// TODO/FIXME: respond to positive/negative signal from external binary
// auth service.
NOTIMPLEMENTED();
}
void ViewsScreenLocker::UpdatePinKeyboardState(const AccountId& account_id) {
quick_unlock::PinBackend::GetInstance()->CanAuthenticate(
account_id, base::BindOnce(&ViewsScreenLocker::OnPinCanAuthenticate,
......
......@@ -6,10 +6,13 @@
#define CHROME_BROWSER_CHROMEOS_LOGIN_LOCK_VIEWS_SCREEN_LOCKER_H_
#include "base/memory/weak_ptr.h"
#include "base/scoped_observer.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/settings/cros_settings.h"
#include "chrome/browser/ui/ash/login_screen_client.h"
#include "chromeos/dbus/media_analytics_client.h"
#include "chromeos/dbus/media_perception/media_perception.pb.h"
#include "chromeos/dbus/power_manager_client.h"
namespace chromeos {
......@@ -25,7 +28,8 @@ class MojoVersionInfoDispatcher;
class ViewsScreenLocker : public LoginScreenClient::Delegate,
public ScreenLocker::Delegate,
public PowerManagerClient::Observer,
public lock_screen_apps::FocusCyclerDelegate {
public lock_screen_apps::FocusCyclerDelegate,
public chromeos::MediaAnalyticsClient::Observer {
public:
explicit ViewsScreenLocker(ScreenLocker* screen_locker);
~ViewsScreenLocker() override;
......@@ -78,6 +82,9 @@ class ViewsScreenLocker : public LoginScreenClient::Delegate,
void UnregisterLockScreenAppFocusHandler() override;
void HandleLockScreenAppFocusOut(bool reverse) override;
// chromeos::MediaAnalyticsClient::Observer
void OnDetectionSignal(const mri::MediaPerception& media_perception) override;
private:
void UpdatePinKeyboardState(const AccountId& account_id);
void OnAllowedInputMethodsChanged();
......@@ -109,6 +116,11 @@ class ViewsScreenLocker : public LoginScreenClient::Delegate,
// Updates UI when version info is changed.
std::unique_ptr<MojoVersionInfoDispatcher> version_info_updater_;
chromeos::MediaAnalyticsClient* media_analytics_client_;
ScopedObserver<chromeos::MediaAnalyticsClient, ViewsScreenLocker>
scoped_observer_{this};
base::WeakPtrFactory<ViewsScreenLocker> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(ViewsScreenLocker);
......
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