Commit dac108e9 authored by Yicheng Li's avatar Yicheng Li Committed by Commit Bot

ash: Add InSessionAuthDialogClient for in-session auth

In-session auth dialog controller needs a way to authenticate
the user upon user interaction with the dialog. This client
class is responsible for handling the authentication by talking
to chromeos::ExtendedAuthenticator.

Bug: b:156258540
Change-Id: Ibd0b9ddc0d8bad01580afc8d56edcb354e2ab72e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2337540Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Yicheng Li <yichengli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#795248}
parent 80071bc9
......@@ -4,6 +4,8 @@
#include "ash/in_session_auth/in_session_auth_dialog_controller_impl.h"
#include "ash/public/cpp/in_session_auth_dialog_client.h"
namespace ash {
InSessionAuthDialogControllerImpl::InSessionAuthDialogControllerImpl() =
......@@ -12,6 +14,11 @@ InSessionAuthDialogControllerImpl::InSessionAuthDialogControllerImpl() =
InSessionAuthDialogControllerImpl::~InSessionAuthDialogControllerImpl() =
default;
void InSessionAuthDialogControllerImpl::SetClient(
InSessionAuthDialogClient* client) {
client_ = client;
}
void InSessionAuthDialogControllerImpl::ShowAuthenticationDialog() {
dialog_ = std::make_unique<InSessionAuthDialog>();
}
......
......@@ -12,6 +12,8 @@
namespace ash {
class InSessionAuthDialogClient;
// InSessionAuthDialogControllerImpl persists as long as UI is running.
class InSessionAuthDialogControllerImpl : public InSessionAuthDialogController {
public:
......@@ -23,10 +25,13 @@ class InSessionAuthDialogControllerImpl : public InSessionAuthDialogController {
~InSessionAuthDialogControllerImpl() override;
// InSessionAuthDialogController overrides
void SetClient(InSessionAuthDialogClient* client) override;
void ShowAuthenticationDialog() override;
void DestroyAuthenticationDialog() override;
private:
InSessionAuthDialogClient* client_ = nullptr;
std::unique_ptr<InSessionAuthDialog> dialog_;
};
......
......@@ -146,6 +146,7 @@ component("cpp") {
"immersive/immersive_fullscreen_controller_delegate.h",
"immersive/immersive_revealed_lock.cc",
"immersive/immersive_revealed_lock.h",
"in_session_auth_dialog_client.h",
"in_session_auth_dialog_controller.cc",
"in_session_auth_dialog_controller.h",
"keyboard/arc/arc_input_method_bounds_tracker.cc",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_PUBLIC_CPP_IN_SESSION_AUTH_DIALOG_CLIENT_H_
#define ASH_PUBLIC_CPP_IN_SESSION_AUTH_DIALOG_CLIENT_H_
#include <string>
#include "ash/public/cpp/ash_public_export.h"
#include "base/callback_forward.h"
namespace ash {
// An interface that allows Ash to trigger authentication steps that ChromeOS
// is responsible for.
class ASH_PUBLIC_EXPORT InSessionAuthDialogClient {
public:
// Attempt to authenticate the current session user with a password or PIN.
// |password|: The submitted password.
// |authenticated_by_pin|: True if we are using pin to authenticate.
// |callback|: the callback to run on auth complete.
virtual void AuthenticateUserWithPasswordOrPin(
const std::string& password,
bool authenticated_by_pin,
base::OnceCallback<void(bool)> callback) = 0;
protected:
virtual ~InSessionAuthDialogClient() = default;
};
} // namespace ash
#endif // ASH_PUBLIC_CPP_IN_SESSION_AUTH_DIALOG_CLIENT_H_
......@@ -6,6 +6,7 @@
#define ASH_PUBLIC_CPP_IN_SESSION_AUTH_DIALOG_CONTROLLER_H_
#include "ash/public/cpp/ash_public_export.h"
#include "ash/public/cpp/in_session_auth_dialog_client.h"
namespace ash {
......@@ -15,6 +16,9 @@ class ASH_PUBLIC_EXPORT InSessionAuthDialogController {
// Return the singleton instance.
static InSessionAuthDialogController* Get();
// Sets the client that will handle authentication.
virtual void SetClient(InSessionAuthDialogClient* client) = 0;
// Displays the authentication dialog.
virtual void ShowAuthenticationDialog() = 0;
......
......@@ -1857,6 +1857,8 @@ static_library("ui") {
"ash/image_downloader_impl.h",
"ash/ime_controller_client.cc",
"ash/ime_controller_client.h",
"ash/in_session_auth_dialog_client.cc",
"ash/in_session_auth_dialog_client.h",
"ash/keyboard/chrome_keyboard_bounds_observer.cc",
"ash/keyboard/chrome_keyboard_bounds_observer.h",
"ash/keyboard/chrome_keyboard_controller_client.cc",
......
......@@ -31,6 +31,7 @@
#include "chrome/browser/ui/ash/cast_config_controller_media_router.h"
#include "chrome/browser/ui/ash/chrome_new_window_client.h"
#include "chrome/browser/ui/ash/ime_controller_client.h"
#include "chrome/browser/ui/ash/in_session_auth_dialog_client.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
#include "chrome/browser/ui/ash/login_screen_client.h"
#include "chrome/browser/ui/ash/media_client_impl.h"
......@@ -135,6 +136,9 @@ void ChromeBrowserMainExtraPartsAsh::PreProfileInit() {
chromeos::input_method::InputMethodManager::Get());
ime_controller_client_->Init();
in_session_auth_dialog_client_ =
std::make_unique<InSessionAuthDialogClient>();
// NOTE: The WallpaperControllerClient must be initialized before the
// session controller, because the session controller triggers the loading
// of users, which itself calls a code path which eventually reaches the
......@@ -235,6 +239,7 @@ void ChromeBrowserMainExtraPartsAsh::PostMainMessageLoopRun() {
system_tray_client_.reset();
session_controller_client_.reset();
ime_controller_client_.reset();
in_session_auth_dialog_client_.reset();
chrome_new_window_client_.reset();
accessibility_controller_client_.reset();
// AppListClientImpl indirectly holds WebContents for answer card and
......
......@@ -27,6 +27,7 @@ class AshShellInit;
class CastConfigControllerMediaRouter;
class ChromeNewWindowClient;
class ImeControllerClient;
class InSessionAuthDialogClient;
class LoginScreenClient;
class MediaClientImpl;
class MobileDataNotifications;
......@@ -80,6 +81,7 @@ class ChromeBrowserMainExtraPartsAsh : public ChromeBrowserMainExtraParts {
std::unique_ptr<ArcChromeActionsClient> arc_chrome_actions_client_;
std::unique_ptr<ChromeNewWindowClient> chrome_new_window_client_;
std::unique_ptr<ImeControllerClient> ime_controller_client_;
std::unique_ptr<InSessionAuthDialogClient> in_session_auth_dialog_client_;
std::unique_ptr<ScreenOrientationDelegateChromeos>
screen_orientation_delegate_;
std::unique_ptr<SessionControllerClientImpl> session_controller_client_;
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/ash/in_session_auth_dialog_client.h"
#include <utility>
#include "ash/public/cpp/in_session_auth_dialog_controller.h"
#include "base/callback.h"
namespace {
InSessionAuthDialogClient* g_auth_dialog_client_instance = nullptr;
} // namespace
InSessionAuthDialogClient::InSessionAuthDialogClient() {
// Register this object as the client interface implementation.
ash::InSessionAuthDialogController::Get()->SetClient(this);
DCHECK(!g_auth_dialog_client_instance);
g_auth_dialog_client_instance = this;
}
InSessionAuthDialogClient::~InSessionAuthDialogClient() {
ash::InSessionAuthDialogController::Get()->SetClient(nullptr);
DCHECK_EQ(this, g_auth_dialog_client_instance);
g_auth_dialog_client_instance = nullptr;
}
// static
bool InSessionAuthDialogClient::HasInstance() {
return !!g_auth_dialog_client_instance;
}
// static
InSessionAuthDialogClient* InSessionAuthDialogClient::Get() {
DCHECK(g_auth_dialog_client_instance);
return g_auth_dialog_client_instance;
}
void InSessionAuthDialogClient::AuthenticateUserWithPasswordOrPin(
const std::string& password,
bool authenticated_by_pin,
base::OnceCallback<void(bool)> callback) {
// TODO(yichengli): Implement.
std::move(callback).Run(false);
}
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_ASH_IN_SESSION_AUTH_DIALOG_CLIENT_H_
#define CHROME_BROWSER_UI_ASH_IN_SESSION_AUTH_DIALOG_CLIENT_H_
#include "ash/public/cpp/in_session_auth_dialog_client.h"
// Handles method calls sent from Ash to ChromeOS.
class InSessionAuthDialogClient : public ash::InSessionAuthDialogClient {
public:
InSessionAuthDialogClient();
InSessionAuthDialogClient(const InSessionAuthDialogClient&) = delete;
InSessionAuthDialogClient& operator=(const InSessionAuthDialogClient&) =
delete;
~InSessionAuthDialogClient() override;
static bool HasInstance();
static InSessionAuthDialogClient* Get();
// ash::InSessionAuthDialogClient:
void AuthenticateUserWithPasswordOrPin(
const std::string& password,
bool authenticated_by_pin,
base::OnceCallback<void(bool)> callback) override;
};
#endif // CHROME_BROWSER_UI_ASH_IN_SESSION_AUTH_DIALOG_CLIENT_H_
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