Commit 68ae1beb authored by Yicheng Li's avatar Yicheng Li Committed by Commit Bot

ash: Support closing in-session auth dialog from dbus

The platform side may want to close the in-session auth dialog (for
example in WebAuthn when the browser issues a timeout). Expose a
DBus API for dismissing the dialog. This will have the same effect
as if the user clicks the Cancel button.

Change-Id: I9ab2456967d08c382302ee528b0aa6cc2a0d01c5
Bug: b/167574666
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2499180Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Yicheng Li <yichengli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827370}
parent 86bf28a1
......@@ -29,6 +29,13 @@ void UserAuthenticationServiceProvider::Start(
weak_ptr_factory_.GetWeakPtr()),
base::BindOnce(&UserAuthenticationServiceProvider::OnExported,
weak_ptr_factory_.GetWeakPtr()));
exported_object->ExportMethod(
chromeos::kUserAuthenticationServiceInterface,
chromeos::kUserAuthenticationServiceCancelMethod,
base::BindRepeating(&UserAuthenticationServiceProvider::Cancel,
weak_ptr_factory_.GetWeakPtr()),
base::BindOnce(&UserAuthenticationServiceProvider::OnExported,
weak_ptr_factory_.GetWeakPtr()));
}
void UserAuthenticationServiceProvider::OnExported(
......@@ -93,4 +100,13 @@ void UserAuthenticationServiceProvider::OnAuthFlowComplete(
std::move(response_sender).Run(std::move(response));
}
void UserAuthenticationServiceProvider::Cancel(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender) {
InSessionAuthDialogController::Get()->Cancel();
std::unique_ptr<dbus::Response> response =
dbus::Response::FromMethodCall(method_call);
std::move(response_sender).Run(std::move(response));
}
} // namespace ash
......@@ -46,6 +46,11 @@ class UserAuthenticationServiceProvider
dbus::ExportedObject::ResponseSender response_sender,
bool success);
// Called on UI thread in response to D-Bus requests. Dismisses the dialog if
// it's shown.
void Cancel(dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender);
// Keep this last so that all weak pointers will be invalidated at the
// beginning of destruction.
base::WeakPtrFactory<UserAuthenticationServiceProvider> weak_ptr_factory_{
......
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