Commit 5e0b4b4f authored by Jan Krcal's avatar Jan Krcal Committed by Chromium LUCI CQ

[Profile creation] Support webauthn in the sign-in flow

This CL adds WebContentsModalDialogManager to the sign-in flow web
contents and implements its delegates. This is needed by the webauthn
modal dialog which is in turn needed by the Gaia sign-in flow with
security keys.

Bug: 1167887
Change-Id: Ief107bf16056c5a8ceb3ed7b192b22497957e09c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2636399
Commit-Queue: David Roger <droger@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#844696}
parent bedb24da
......@@ -54,6 +54,7 @@
#include "components/signin/public/identity_manager/account_info.h"
#include "components/startup_metric_utils/browser/startup_metric_utils.h"
#include "components/vector_icons/vector_icons.h"
#include "components/web_modal/web_contents_modal_dialog_manager.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/context_menu_params.h"
#include "content/public/browser/render_frame_host.h"
......@@ -524,6 +525,13 @@ void ProfilePickerView::OnProfileForSigninCreated(
content::WebContents::CreateParams(signed_in_profile_being_created_));
new_profile_contents_->SetDelegate(this);
// Create a manager that supports modal dialogs, such as for webauthn.
web_modal::WebContentsModalDialogManager::CreateForWebContents(
new_profile_contents_.get());
web_modal::WebContentsModalDialogManager::FromWebContents(
new_profile_contents_.get())
->SetDelegate(this);
// Make sure the web contents used for sign-in has proper background to match
// the toolbar (for dark mode).
views::WebContentsSetBackgroundColor::CreateForWebContentsWithColor(
......@@ -819,6 +827,30 @@ void ProfilePickerView::OnExtendedAccountInfoUpdated(
extended_account_info_timeout_closure_.Cancel();
}
web_modal::WebContentsModalDialogHost*
ProfilePickerView::GetWebContentsModalDialogHost() {
return this;
}
gfx::NativeView ProfilePickerView::GetHostView() const {
return GetWidget()->GetNativeView();
}
gfx::Point ProfilePickerView::GetDialogPosition(const gfx::Size& size) {
gfx::Size widget_size = GetWidget()->GetWindowBoundsInScreen().size();
return gfx::Point(std::max(0, (widget_size.width() - size.width()) / 2), 0);
}
gfx::Size ProfilePickerView::GetMaximumDialogSize() {
return GetWidget()->GetWindowBoundsInScreen().size();
}
void ProfilePickerView::AddObserver(
web_modal::ModalDialogHostObserver* observer) {}
void ProfilePickerView::RemoveObserver(
web_modal::ModalDialogHostObserver* observer) {}
void ProfilePickerView::SetExtendedAccountInfoTimeoutForTesting(
base::TimeDelta timeout) {
extended_account_info_timeout_ = timeout;
......
......@@ -8,10 +8,12 @@
#include "base/cancelable_callback.h"
#include "base/time/time.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/chrome_web_modal_dialog_manager_delegate.h"
#include "chrome/browser/ui/profile_picker.h"
#include "chrome/browser/ui/views/profiles/user_manager_profile_dialog_host.h"
#include "components/keep_alive_registry/scoped_keep_alive.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "components/web_modal/web_contents_modal_dialog_host.h"
#include "content/public/browser/web_contents_delegate.h"
#include "ui/views/controls/webview/unhandled_keyboard_event_handler.h"
#include "ui/views/controls/webview/webview.h"
......@@ -34,7 +36,9 @@ class WebContents;
// Dialog widget that contains the Desktop Profile picker webui.
class ProfilePickerView : public views::WidgetDelegateView,
public content::WebContentsDelegate,
public signin::IdentityManager::Observer {
public signin::IdentityManager::Observer,
public ChromeWebModalDialogManagerDelegate,
public web_modal::WebContentsModalDialogHost {
public:
using BrowserOpenedCallback = base::OnceCallback<void(Browser*)>;
......@@ -108,6 +112,17 @@ class ProfilePickerView : public views::WidgetDelegateView,
const CoreAccountInfo& account_info) override;
void OnExtendedAccountInfoUpdated(const AccountInfo& account_info) override;
// ChromeWebModalDialogManagerDelegate
web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost()
override;
// web_modal::WebContentsModalDialogHost
gfx::NativeView GetHostView() const override;
gfx::Point GetDialogPosition(const gfx::Size& size) override;
gfx::Size GetMaximumDialogSize() override;
void AddObserver(web_modal::ModalDialogHostObserver* observer) override;
void RemoveObserver(web_modal::ModalDialogHostObserver* observer) override;
// Builds the views hieararchy.
void BuildLayout();
......
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