Commit 0ad78f76 authored by siyua's avatar siyua Committed by Commit Bot

[Autofill Auth UI] Rename webauthn dialog flow

Reason for this CL: We did implementation review with Chrome UX and
one feedback was the verify pending dialog was too short for a modal
dialog. Therefore UX decision is for this dialog, we also reuse the
template of the webauthn dialog (adding an illustration on top). So
it makes sense to merge the separate MVCs of webauthn_offer_dialog
and verify_pending_dialog into one, and show different content for
different states (in other words, adding kVerifyPending as a new state
in WebauthnDialogModel).

This is a renaming CL which is the precursor of the major merging CL.

Includes two changes:
1. Rename all WebauthnOffer- to Webauthn- to avoid confusion;
2. In AutofillClient, move all webauthn related functions under build
flags to ensure these functions are all on desktop.

No other change on flow logic.

TBR=michaelbai@chromium.org,mahmadi@chromium.org,martinkr@google.com

Change-Id: I80ae00d219cdaf868056a04938c6968ed186ad3d
Bug: 949269
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1925761
Commit-Queue: Siyu An <siyua@chromium.org>
Reviewed-by: default avatarEvan Stade <estade@chromium.org>
Reviewed-by: default avatarJared Saul <jsaul@google.com>
Cr-Commit-Position: refs/heads/master@{#718394}
parent 82f8c066
......@@ -141,11 +141,6 @@ void AwAutofillClient::ShowLocalCardMigrationResults(
NOTIMPLEMENTED();
}
void AwAutofillClient::ShowWebauthnOfferDialog(
WebauthnOfferDialogCallback callback) {
NOTIMPLEMENTED();
}
void AwAutofillClient::ConfirmSaveAutofillProfile(
const autofill::AutofillProfile& profile,
base::OnceClosure callback) {
......
......@@ -94,7 +94,6 @@ class AwAutofillClient : public autofill::AutofillClient,
const std::vector<autofill::MigratableCreditCard>&
migratable_credit_cards,
MigrationDeleteCardCallback delete_local_card_callback) override;
void ShowWebauthnOfferDialog(WebauthnOfferDialogCallback callback) override;
void ConfirmSaveAutofillProfile(const autofill::AutofillProfile& profile,
base::OnceClosure callback) override;
void ConfirmSaveCreditCardLocally(
......
......@@ -16,8 +16,8 @@ aggregate_vector_icons("chrome_vector_icons") {
"add.icon",
"ads.icon",
"apps.icon",
"autofill/webauthn_offer_dialog_header.icon",
"autofill/webauthn_offer_dialog_header_dark.icon",
"autofill/webauthn_dialog_header.icon",
"autofill/webauthn_dialog_header_dark.icon",
"blocked_badge.icon",
"blocked_redirect.icon",
"bluetooth.icon",
......
......@@ -2031,21 +2031,21 @@ jumbo_static_library("ui") {
"autofill/payments/verify_pending_dialog_controller_impl.cc",
"autofill/payments/verify_pending_dialog_controller_impl.h",
"autofill/payments/verify_pending_dialog_view.h",
"autofill/payments/webauthn_offer_dialog_controller.h",
"autofill/payments/webauthn_offer_dialog_controller_impl.cc",
"autofill/payments/webauthn_offer_dialog_controller_impl.h",
"autofill/payments/webauthn_offer_dialog_model.cc",
"autofill/payments/webauthn_offer_dialog_model.h",
"autofill/payments/webauthn_offer_dialog_model_observer.h",
"autofill/payments/webauthn_offer_dialog_view.h",
"autofill/payments/webauthn_dialog_controller.h",
"autofill/payments/webauthn_dialog_controller_impl.cc",
"autofill/payments/webauthn_dialog_controller_impl.h",
"autofill/payments/webauthn_dialog_model.cc",
"autofill/payments/webauthn_dialog_model.h",
"autofill/payments/webauthn_dialog_model_observer.h",
"autofill/payments/webauthn_dialog_view.h",
"frame/window_frame_util.cc",
"frame/window_frame_util.h",
"tab_contents/chrome_web_contents_view_handle_drop.cc",
"tab_contents/chrome_web_contents_view_handle_drop.h",
"views/autofill/payments/verify_pending_dialog_view_impl.cc",
"views/autofill/payments/verify_pending_dialog_view_impl.h",
"views/autofill/payments/webauthn_offer_dialog_view_impl.cc",
"views/autofill/payments/webauthn_offer_dialog_view_impl.h",
"views/autofill/payments/webauthn_dialog_view_impl.cc",
"views/autofill/payments/webauthn_dialog_view_impl.h",
"views/close_bubble_on_tab_activation_helper.cc",
"views/close_bubble_on_tab_activation_helper.h",
"views/hats/hats_bubble_view.cc",
......
......@@ -84,8 +84,8 @@
#include "chrome/browser/ui/autofill/payments/save_card_bubble_controller_impl.h"
#include "chrome/browser/ui/autofill/payments/verify_pending_dialog_controller_impl.h"
#include "chrome/browser/ui/autofill/payments/verify_pending_dialog_view.h"
#include "chrome/browser/ui/autofill/payments/webauthn_offer_dialog_controller_impl.h"
#include "chrome/browser/ui/autofill/payments/webauthn_offer_dialog_view.h"
#include "chrome/browser/ui/autofill/payments/webauthn_dialog_controller_impl.h"
#include "chrome/browser/ui/autofill/payments/webauthn_dialog_view.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
......@@ -273,7 +273,30 @@ void ChromeAutofillClient::ShowLocalCardMigrationResults(
}
#if !defined(OS_ANDROID)
void ChromeAutofillClient::ShowVerifyPendingDialog(
void ChromeAutofillClient::ShowWebauthnOfferDialog(
WebauthnOfferDialogCallback offer_dialog_callback) {
autofill::WebauthnDialogControllerImpl::CreateForWebContents(web_contents());
autofill::WebauthnDialogControllerImpl::FromWebContents(web_contents())
->ShowOfferDialog(std::move(offer_dialog_callback));
}
void ChromeAutofillClient::UpdateWebauthnOfferDialogWithError() {
WebauthnDialogControllerImpl* controller =
autofill::WebauthnDialogControllerImpl::FromWebContents(web_contents());
if (controller)
controller->UpdateDialogWithError();
}
bool ChromeAutofillClient::CloseWebauthnOfferDialog() {
WebauthnDialogControllerImpl* controller =
autofill::WebauthnDialogControllerImpl::FromWebContents(web_contents());
if (controller)
return controller->CloseDialog();
return false;
}
void ChromeAutofillClient::ShowWebauthnVerifyPendingDialog(
base::OnceClosure cancel_card_verification_callback) {
autofill::VerifyPendingDialogControllerImpl::CreateForWebContents(
web_contents());
......@@ -281,7 +304,7 @@ void ChromeAutofillClient::ShowVerifyPendingDialog(
->ShowDialog(std::move(cancel_card_verification_callback));
}
void ChromeAutofillClient::CloseVerifyPendingDialog() {
void ChromeAutofillClient::CloseWebauthnVerifyPendingDialog() {
VerifyPendingDialogControllerImpl* controller =
autofill::VerifyPendingDialogControllerImpl::FromWebContents(
web_contents());
......@@ -292,37 +315,6 @@ void ChromeAutofillClient::CloseVerifyPendingDialog() {
}
#endif
void ChromeAutofillClient::ShowWebauthnOfferDialog(
WebauthnOfferDialogCallback callback) {
#if !defined(OS_ANDROID)
autofill::WebauthnOfferDialogControllerImpl::CreateForWebContents(
web_contents());
autofill::WebauthnOfferDialogControllerImpl::FromWebContents(web_contents())
->ShowOfferDialog(std::move(callback));
#endif
}
bool ChromeAutofillClient::CloseWebauthnOfferDialog() {
#if !defined(OS_ANDROID)
WebauthnOfferDialogControllerImpl* controller =
autofill::WebauthnOfferDialogControllerImpl::FromWebContents(
web_contents());
if (controller)
return controller->CloseDialog();
#endif
return false;
}
void ChromeAutofillClient::UpdateWebauthnOfferDialogWithError() {
#if !defined(OS_ANDROID)
WebauthnOfferDialogControllerImpl* controller =
autofill::WebauthnOfferDialogControllerImpl::FromWebContents(
web_contents());
if (controller)
controller->UpdateDialogWithError();
#endif
}
void ChromeAutofillClient::ConfirmSaveAutofillProfile(
const AutofillProfile& profile,
base::OnceClosure callback) {
......
......@@ -87,13 +87,14 @@ class ChromeAutofillClient
const std::vector<MigratableCreditCard>& migratable_credit_cards,
MigrationDeleteCardCallback delete_local_card_callback) override;
#if !defined(OS_ANDROID)
void ShowVerifyPendingDialog(
void ShowWebauthnOfferDialog(
WebauthnOfferDialogCallback offer_dialog_callback) override;
void UpdateWebauthnOfferDialogWithError() override;
bool CloseWebauthnOfferDialog() override;
void ShowWebauthnVerifyPendingDialog(
base::OnceClosure cancel_card_verification_callback) override;
void CloseVerifyPendingDialog() override;
void CloseWebauthnVerifyPendingDialog() override;
#endif // !defined(OS_ANDROID)
void ShowWebauthnOfferDialog(WebauthnOfferDialogCallback callback) override;
bool CloseWebauthnOfferDialog() override;
void UpdateWebauthnOfferDialogWithError() override;
void ConfirmSaveAutofillProfile(const AutofillProfile& profile,
base::OnceClosure callback) override;
void ConfirmSaveCreditCardLocally(
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_AUTOFILL_PAYMENTS_WEBAUTHN_OFFER_DIALOG_CONTROLLER_H_
#define CHROME_BROWSER_UI_AUTOFILL_PAYMENTS_WEBAUTHN_OFFER_DIALOG_CONTROLLER_H_
#ifndef CHROME_BROWSER_UI_AUTOFILL_PAYMENTS_WEBAUTHN_DIALOG_CONTROLLER_H_
#define CHROME_BROWSER_UI_AUTOFILL_PAYMENTS_WEBAUTHN_DIALOG_CONTROLLER_H_
#include "base/macros.h"
......@@ -14,11 +14,10 @@ class WebContents;
namespace autofill {
// An interface that exposes necessary controller functionality to
// WebauthnOfferDialogView.
class WebauthnOfferDialogController {
// WebauthnDialogView.
class WebauthnDialogController {
public:
WebauthnOfferDialogController() = default;
virtual ~WebauthnOfferDialogController() = default;
virtual ~WebauthnDialogController() = default;
virtual void OnOkButtonClicked() = 0;
......@@ -27,11 +26,8 @@ class WebauthnOfferDialogController {
virtual void OnDialogClosed() = 0;
virtual content::WebContents* GetWebContents() = 0;
private:
DISALLOW_COPY_AND_ASSIGN(WebauthnOfferDialogController);
};
} // namespace autofill
#endif // CHROME_BROWSER_UI_AUTOFILL_PAYMENTS_WEBAUTHN_OFFER_DIALOG_CONTROLLER_H_
#endif // CHROME_BROWSER_UI_AUTOFILL_PAYMENTS_WEBAUTHN_DIALOG_CONTROLLER_H_
......@@ -2,74 +2,70 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/autofill/payments/webauthn_offer_dialog_controller_impl.h"
#include "chrome/browser/ui/autofill/payments/webauthn_dialog_controller_impl.h"
#include "chrome/browser/ui/autofill/payments/webauthn_offer_dialog_model.h"
#include "chrome/browser/ui/autofill/payments/webauthn_offer_dialog_view.h"
#include "chrome/browser/ui/autofill/payments/webauthn_dialog_model.h"
#include "chrome/browser/ui/autofill/payments/webauthn_dialog_view.h"
namespace autofill {
WebauthnOfferDialogControllerImpl::WebauthnOfferDialogControllerImpl(
WebauthnDialogControllerImpl::WebauthnDialogControllerImpl(
content::WebContents* web_contents)
: content::WebContentsObserver(web_contents) {}
WebauthnOfferDialogControllerImpl::~WebauthnOfferDialogControllerImpl() {
WebauthnDialogControllerImpl::~WebauthnDialogControllerImpl() {
// This part of code is executed only if browser window is closed when the
// dialog is visible. In this case the controller is destroyed before
// WebauthnOfferDialogViewImpl::dtor() being called, but the reference to
// controller is not reset. Need to reset via
// WebauthnOfferDialogViewImpl::Hide() to avoid crash.
if (dialog_model_) {
dialog_model_->SetDialogState(
WebauthnOfferDialogModel::DialogState::kInactive);
}
// WebauthnDialogViewImpl::dtor() being called, but the reference to
// controller is not reset. Need to reset via WebauthnDialogViewImpl::Hide()
// to avoid crash.
if (dialog_model_)
dialog_model_->SetDialogState(WebauthnDialogModel::DialogState::kInactive);
}
void WebauthnOfferDialogControllerImpl::ShowOfferDialog(
AutofillClient::WebauthnOfferDialogCallback callback) {
void WebauthnDialogControllerImpl::ShowOfferDialog(
AutofillClient::WebauthnOfferDialogCallback offer_dialog_callback) {
DCHECK(!dialog_model_);
offer_dialog_callback_ = std::move(callback);
dialog_view_ = WebauthnOfferDialogView::CreateAndShow(this);
offer_dialog_callback_ = std::move(offer_dialog_callback);
dialog_view_ = WebauthnDialogView::CreateAndShow(this);
dialog_model_ = dialog_view_->GetDialogModel();
}
bool WebauthnOfferDialogControllerImpl::CloseDialog() {
bool WebauthnDialogControllerImpl::CloseDialog() {
if (!dialog_model_)
return false;
dialog_model_->SetDialogState(
WebauthnOfferDialogModel::DialogState::kInactive);
dialog_model_->SetDialogState(WebauthnDialogModel::DialogState::kInactive);
return true;
}
void WebauthnOfferDialogControllerImpl::UpdateDialogWithError() {
dialog_model_->SetDialogState(WebauthnOfferDialogModel::DialogState::kError);
void WebauthnDialogControllerImpl::UpdateDialogWithError() {
dialog_model_->SetDialogState(WebauthnDialogModel::DialogState::kError);
offer_dialog_callback_.Reset();
}
void WebauthnOfferDialogControllerImpl::OnDialogClosed() {
void WebauthnDialogControllerImpl::OnDialogClosed() {
dialog_model_ = nullptr;
dialog_view_ = nullptr;
offer_dialog_callback_.Reset();
}
content::WebContents* WebauthnOfferDialogControllerImpl::GetWebContents() {
content::WebContents* WebauthnDialogControllerImpl::GetWebContents() {
return web_contents();
}
void WebauthnOfferDialogControllerImpl::OnOkButtonClicked() {
void WebauthnDialogControllerImpl::OnOkButtonClicked() {
DCHECK(offer_dialog_callback_);
offer_dialog_callback_.Run(/*did_accept=*/true);
dialog_model_->SetDialogState(
WebauthnOfferDialogModel::DialogState::kPending);
dialog_model_->SetDialogState(WebauthnDialogModel::DialogState::kPending);
}
void WebauthnOfferDialogControllerImpl::OnCancelButtonClicked() {
void WebauthnDialogControllerImpl::OnCancelButtonClicked() {
DCHECK(offer_dialog_callback_);
offer_dialog_callback_.Run(/*did_accept=*/false);
}
WEB_CONTENTS_USER_DATA_KEY_IMPL(WebauthnOfferDialogControllerImpl)
WEB_CONTENTS_USER_DATA_KEY_IMPL(WebauthnDialogControllerImpl)
} // namespace autofill
......@@ -2,61 +2,61 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_AUTOFILL_PAYMENTS_WEBAUTHN_OFFER_DIALOG_CONTROLLER_IMPL_H_
#define CHROME_BROWSER_UI_AUTOFILL_PAYMENTS_WEBAUTHN_OFFER_DIALOG_CONTROLLER_IMPL_H_
#ifndef CHROME_BROWSER_UI_AUTOFILL_PAYMENTS_WEBAUTHN_DIALOG_CONTROLLER_IMPL_H_
#define CHROME_BROWSER_UI_AUTOFILL_PAYMENTS_WEBAUTHN_DIALOG_CONTROLLER_IMPL_H_
#include "base/macros.h"
#include "chrome/browser/ui/autofill/payments/webauthn_offer_dialog_controller.h"
#include "chrome/browser/ui/autofill/payments/webauthn_dialog_controller.h"
#include "components/autofill/core/browser/autofill_client.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
namespace autofill {
class WebauthnOfferDialogModel;
class WebauthnOfferDialogView;
class WebauthnDialogModel;
class WebauthnDialogView;
// Implementation of the per-tab controller to control the
// WebauthnOfferDialogView. Lazily initialized when used.
class WebauthnOfferDialogControllerImpl
: public WebauthnOfferDialogController,
// WebauthnDialogView. Lazily initialized when used.
class WebauthnDialogControllerImpl
: public WebauthnDialogController,
public content::WebContentsObserver,
public content::WebContentsUserData<WebauthnOfferDialogControllerImpl> {
public content::WebContentsUserData<WebauthnDialogControllerImpl> {
public:
~WebauthnOfferDialogControllerImpl() override;
~WebauthnDialogControllerImpl() override;
void ShowOfferDialog(AutofillClient::WebauthnOfferDialogCallback callback);
void ShowOfferDialog(
AutofillClient::WebauthnOfferDialogCallback offer_dialog_callback);
bool CloseDialog();
void UpdateDialogWithError();
// WebauthnOfferDialogController:
// WebauthnDialogController:
void OnOkButtonClicked() override;
void OnCancelButtonClicked() override;
void OnDialogClosed() override;
content::WebContents* GetWebContents() override;
WebauthnOfferDialogView* dialog_view() { return dialog_view_; }
WebauthnDialogView* dialog_view() { return dialog_view_; }
protected:
explicit WebauthnOfferDialogControllerImpl(
content::WebContents* web_contents);
explicit WebauthnDialogControllerImpl(content::WebContents* web_contents);
private:
friend class content::WebContentsUserData<WebauthnOfferDialogControllerImpl>;
friend class content::WebContentsUserData<WebauthnDialogControllerImpl>;
// Callback invoked when any button in the dialog is clicked. Note this
// Callback invoked when any button in the offer dialog is clicked. Note this
// repeating callback can be run twice, since after the accept button is
// clicked, the dialog stays and the cancel button is still clickable.
// clicked, the offer dialog stays and the cancel button is still clickable.
AutofillClient::WebauthnOfferDialogCallback offer_dialog_callback_;
WebauthnOfferDialogModel* dialog_model_ = nullptr;
WebauthnOfferDialogView* dialog_view_ = nullptr;
WebauthnDialogModel* dialog_model_ = nullptr;
WebauthnDialogView* dialog_view_ = nullptr;
WEB_CONTENTS_USER_DATA_KEY_DECL();
DISALLOW_COPY_AND_ASSIGN(WebauthnOfferDialogControllerImpl);
DISALLOW_COPY_AND_ASSIGN(WebauthnDialogControllerImpl);
};
} // namespace autofill
#endif // CHROME_BROWSER_UI_AUTOFILL_PAYMENTS_WEBAUTHN_OFFER_DIALOG_CONTROLLER_IMPL_H_
#endif // CHROME_BROWSER_UI_AUTOFILL_PAYMENTS_WEBAUTHN_DIALOG_CONTROLLER_IMPL_H_
......@@ -2,51 +2,50 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/autofill/payments/webauthn_offer_dialog_model.h"
#include "chrome/browser/ui/autofill/payments/webauthn_dialog_model.h"
#include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/ui/autofill/payments/webauthn_offer_dialog_model_observer.h"
#include "chrome/browser/ui/autofill/payments/webauthn_dialog_model_observer.h"
#include "components/strings/grit/components_strings.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/paint_vector_icon.h"
namespace autofill {
WebauthnOfferDialogModel::WebauthnOfferDialogModel() {
WebauthnDialogModel::WebauthnDialogModel() {
state_ = kOffer;
}
WebauthnOfferDialogModel::~WebauthnOfferDialogModel() = default;
WebauthnDialogModel::~WebauthnDialogModel() = default;
void WebauthnOfferDialogModel::SetDialogState(DialogState state) {
void WebauthnDialogModel::SetDialogState(DialogState state) {
state_ = state;
for (WebauthnOfferDialogModelObserver& observer : observers_)
for (WebauthnDialogModelObserver& observer : observers_)
observer.OnDialogStateChanged();
}
void WebauthnOfferDialogModel::AddObserver(
WebauthnOfferDialogModelObserver* observer) {
void WebauthnDialogModel::AddObserver(WebauthnDialogModelObserver* observer) {
observers_.AddObserver(observer);
}
void WebauthnOfferDialogModel::RemoveObserver(
WebauthnOfferDialogModelObserver* observer) {
void WebauthnDialogModel::RemoveObserver(
WebauthnDialogModelObserver* observer) {
observers_.RemoveObserver(observer);
}
bool WebauthnOfferDialogModel::IsActivityIndicatorVisible() const {
bool WebauthnDialogModel::IsActivityIndicatorVisible() const {
return state_ == DialogState::kPending;
}
bool WebauthnOfferDialogModel::IsBackButtonVisible() const {
bool WebauthnDialogModel::IsBackButtonVisible() const {
return false;
}
bool WebauthnOfferDialogModel::IsCancelButtonVisible() const {
bool WebauthnDialogModel::IsCancelButtonVisible() const {
return true;
}
base::string16 WebauthnOfferDialogModel::GetCancelButtonLabel() const {
base::string16 WebauthnDialogModel::GetCancelButtonLabel() const {
switch (state_) {
case DialogState::kOffer:
case DialogState::kPending:
......@@ -62,27 +61,27 @@ base::string16 WebauthnOfferDialogModel::GetCancelButtonLabel() const {
return base::string16();
}
bool WebauthnOfferDialogModel::IsAcceptButtonVisible() const {
bool WebauthnDialogModel::IsAcceptButtonVisible() const {
return state_ == DialogState::kOffer || state_ == DialogState::kPending;
}
bool WebauthnOfferDialogModel::IsAcceptButtonEnabled() const {
bool WebauthnDialogModel::IsAcceptButtonEnabled() const {
return state_ != DialogState::kPending;
}
base::string16 WebauthnOfferDialogModel::GetAcceptButtonLabel() const {
base::string16 WebauthnDialogModel::GetAcceptButtonLabel() const {
return l10n_util::GetStringUTF16(
IDS_AUTOFILL_WEBAUTHN_OPT_IN_DIALOG_OK_BUTTON_LABEL);
}
const gfx::VectorIcon& WebauthnOfferDialogModel::GetStepIllustration(
const gfx::VectorIcon& WebauthnDialogModel::GetStepIllustration(
ImageColorScheme color_scheme) const {
switch (state_) {
case DialogState::kOffer:
case DialogState::kPending:
return color_scheme == ImageColorScheme::kDark
? kWebauthnOfferDialogHeaderDarkIcon
: kWebauthnOfferDialogHeaderIcon;
? kWebauthnDialogHeaderDarkIcon
: kWebauthnDialogHeaderIcon;
case DialogState::kError:
return color_scheme == ImageColorScheme::kDark ? kWebauthnErrorDarkIcon
: kWebauthnErrorIcon;
......@@ -94,7 +93,7 @@ const gfx::VectorIcon& WebauthnOfferDialogModel::GetStepIllustration(
return gfx::kNoneIcon;
}
base::string16 WebauthnOfferDialogModel::GetStepTitle() const {
base::string16 WebauthnDialogModel::GetStepTitle() const {
switch (state_) {
case DialogState::kOffer:
case DialogState::kPending:
......@@ -111,7 +110,7 @@ base::string16 WebauthnOfferDialogModel::GetStepTitle() const {
return base::string16();
}
base::string16 WebauthnOfferDialogModel::GetStepDescription() const {
base::string16 WebauthnDialogModel::GetStepDescription() const {
switch (state_) {
case DialogState::kOffer:
case DialogState::kPending:
......@@ -128,12 +127,12 @@ base::string16 WebauthnOfferDialogModel::GetStepDescription() const {
return base::string16();
}
base::Optional<base::string16>
WebauthnOfferDialogModel::GetAdditionalDescription() const {
base::Optional<base::string16> WebauthnDialogModel::GetAdditionalDescription()
const {
return base::nullopt;
}
ui::MenuModel* WebauthnOfferDialogModel::GetOtherTransportsMenuModel() {
ui::MenuModel* WebauthnDialogModel::GetOtherTransportsMenuModel() {
return nullptr;
}
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_AUTOFILL_PAYMENTS_WEBAUTHN_OFFER_DIALOG_MODEL_H_
#define CHROME_BROWSER_UI_AUTOFILL_PAYMENTS_WEBAUTHN_OFFER_DIALOG_MODEL_H_
#ifndef CHROME_BROWSER_UI_AUTOFILL_PAYMENTS_WEBAUTHN_DIALOG_MODEL_H_
#define CHROME_BROWSER_UI_AUTOFILL_PAYMENTS_WEBAUTHN_DIALOG_MODEL_H_
#include "base/macros.h"
#include "base/observer_list.h"
......@@ -12,11 +12,11 @@
namespace autofill {
class WebauthnOfferDialogModelObserver;
class WebauthnDialogModelObserver;
// The model for WebauthnOfferDialogView determining what content is shown.
// The model for WebauthnDialogView determining what content is shown.
// Owned by the AuthenticatorRequestSheetView.
class WebauthnOfferDialogModel : public AuthenticatorRequestSheetModel {
class WebauthnDialogModel : public AuthenticatorRequestSheetModel {
public:
enum DialogState {
kUnknown,
......@@ -31,14 +31,14 @@ class WebauthnOfferDialogModel : public AuthenticatorRequestSheetModel {
kError,
};
WebauthnOfferDialogModel();
~WebauthnOfferDialogModel() override;
WebauthnDialogModel();
~WebauthnDialogModel() override;
void SetDialogState(DialogState state);
DialogState dialog_state() { return state_; }
void AddObserver(WebauthnOfferDialogModelObserver* observer);
void RemoveObserver(WebauthnOfferDialogModelObserver* observer);
void AddObserver(WebauthnDialogModelObserver* observer);
void RemoveObserver(WebauthnDialogModelObserver* observer);
// AuthenticatorRequestSheetModel:
bool IsActivityIndicatorVisible() const override;
......@@ -62,11 +62,11 @@ class WebauthnOfferDialogModel : public AuthenticatorRequestSheetModel {
private:
DialogState state_ = DialogState::kUnknown;
base::ObserverList<WebauthnOfferDialogModelObserver> observers_;
base::ObserverList<WebauthnDialogModelObserver> observers_;
DISALLOW_COPY_AND_ASSIGN(WebauthnOfferDialogModel);
DISALLOW_COPY_AND_ASSIGN(WebauthnDialogModel);
};
} // namespace autofill
#endif // CHROME_BROWSER_UI_AUTOFILL_PAYMENTS_WEBAUTHN_OFFER_DIALOG_MODEL_H_
#endif // CHROME_BROWSER_UI_AUTOFILL_PAYMENTS_WEBAUTHN_DIALOG_MODEL_H_
......@@ -2,19 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_AUTOFILL_PAYMENTS_WEBAUTHN_OFFER_DIALOG_MODEL_OBSERVER_H_
#define CHROME_BROWSER_UI_AUTOFILL_PAYMENTS_WEBAUTHN_OFFER_DIALOG_MODEL_OBSERVER_H_
#ifndef CHROME_BROWSER_UI_AUTOFILL_PAYMENTS_WEBAUTHN_DIALOG_MODEL_OBSERVER_H_
#define CHROME_BROWSER_UI_AUTOFILL_PAYMENTS_WEBAUTHN_DIALOG_MODEL_OBSERVER_H_
#include "base/observer_list_types.h"
namespace autofill {
// The observer for WebauthnOfferDialogModel.
class WebauthnOfferDialogModelObserver : public base::CheckedObserver {
// The observer for WebauthnDialogModel.
class WebauthnDialogModelObserver : public base::CheckedObserver {
public:
virtual void OnDialogStateChanged() = 0;
};
} // namespace autofill
#endif // CHROME_BROWSER_UI_AUTOFILL_PAYMENTS_WEBAUTHN_OFFER_DIALOG_MODEL_OBSERVER_H_
#endif // CHROME_BROWSER_UI_AUTOFILL_PAYMENTS_WEBAUTHN_DIALOG_MODEL_OBSERVER_H_
// Copyright 2019 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_AUTOFILL_PAYMENTS_WEBAUTHN_DIALOG_VIEW_H_
#define CHROME_BROWSER_UI_AUTOFILL_PAYMENTS_WEBAUTHN_DIALOG_VIEW_H_
namespace autofill {
class WebauthnDialogController;
class WebauthnDialogModel;
// The view of the dialog that offers the option to use device's platform
// authenticator. It is shown automatically after card unmasked details are
// obtained and filled into the form.
class WebauthnDialogView {
public:
static WebauthnDialogView* CreateAndShow(
WebauthnDialogController* controller);
virtual WebauthnDialogModel* GetDialogModel() const = 0;
};
} // namespace autofill
#endif // CHROME_BROWSER_UI_AUTOFILL_PAYMENTS_WEBAUTHN_DIALOG_VIEW_H_
// Copyright 2019 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_AUTOFILL_PAYMENTS_WEBAUTHN_OFFER_DIALOG_VIEW_H_
#define CHROME_BROWSER_UI_AUTOFILL_PAYMENTS_WEBAUTHN_OFFER_DIALOG_VIEW_H_
namespace autofill {
class WebauthnOfferDialogController;
class WebauthnOfferDialogModel;
// The dialog to offer the option of using device's platform authenticator
// instead of CVC to verify the card in the future. Returns the reference to the
// model of the dialog.
class WebauthnOfferDialogView {
public:
static WebauthnOfferDialogView* CreateAndShow(
WebauthnOfferDialogController* controller);
virtual WebauthnOfferDialogModel* GetDialogModel() const = 0;
};
} // namespace autofill
#endif // CHROME_BROWSER_UI_AUTOFILL_PAYMENTS_WEBAUTHN_OFFER_DIALOG_VIEW_H_
......@@ -3,61 +3,61 @@
// found in the LICENSE file.
#include "base/run_loop.h"
#include "chrome/browser/ui/autofill/payments/webauthn_offer_dialog_controller_impl.h"
#include "chrome/browser/ui/autofill/payments/webauthn_offer_dialog_view.h"
#include "chrome/browser/ui/autofill/payments/webauthn_dialog_controller_impl.h"
#include "chrome/browser/ui/autofill/payments/webauthn_dialog_view.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/test/test_browser_dialog.h"
#include "chrome/browser/ui/views/autofill/payments/webauthn_offer_dialog_view_impl.h"
#include "chrome/browser/ui/views/autofill/payments/webauthn_dialog_view_impl.h"
namespace autofill {
class WebauthnOfferDialogBrowserTest : public DialogBrowserTest {
class WebauthnDialogBrowserTest : public DialogBrowserTest {
public:
WebauthnOfferDialogBrowserTest() = default;
WebauthnDialogBrowserTest() = default;
// DialogBrowserTest:
void ShowUi(const std::string& name) override {
content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
// Do lazy initialization of WebauthnOfferDialogControllerImpl.
WebauthnOfferDialogControllerImpl::CreateForWebContents(web_contents);
// Do lazy initialization of WebauthnDialogControllerImpl.
WebauthnDialogControllerImpl::CreateForWebContents(web_contents);
DCHECK(controller());
controller()->ShowOfferDialog(base::DoNothing());
}
WebauthnOfferDialogViewImpl* GetWebauthnOfferDialog() {
WebauthnDialogViewImpl* GetWebauthnDialog() {
if (!controller())
return nullptr;
WebauthnOfferDialogView* dialog_view = controller()->dialog_view();
WebauthnDialogView* dialog_view = controller()->dialog_view();
if (!dialog_view)
return nullptr;
return static_cast<WebauthnOfferDialogViewImpl*>(dialog_view);
return static_cast<WebauthnDialogViewImpl*>(dialog_view);
}
WebauthnOfferDialogControllerImpl* controller() {
WebauthnDialogControllerImpl* controller() {
if (!browser() || !browser()->tab_strip_model() ||
!browser()->tab_strip_model()->GetActiveWebContents())
return nullptr;
return WebauthnOfferDialogControllerImpl::FromWebContents(
return WebauthnDialogControllerImpl::FromWebContents(
browser()->tab_strip_model()->GetActiveWebContents());
}
private:
DISALLOW_COPY_AND_ASSIGN(WebauthnOfferDialogBrowserTest);
DISALLOW_COPY_AND_ASSIGN(WebauthnDialogBrowserTest);
};
IN_PROC_BROWSER_TEST_F(WebauthnOfferDialogBrowserTest, InvokeUi_default) {
IN_PROC_BROWSER_TEST_F(WebauthnDialogBrowserTest, InvokeUi_default) {
ShowAndVerifyUi();
}
// Ensures closing tab while dialog being visible is correctly handled.
// RunUntilIdle() makes sure that nothing crashes after browser tab is closed.
IN_PROC_BROWSER_TEST_F(WebauthnOfferDialogBrowserTest,
IN_PROC_BROWSER_TEST_F(WebauthnDialogBrowserTest,
CanCloseTabWhileDialogShowing) {
ShowUi(std::string());
VerifyUi();
......@@ -66,7 +66,7 @@ IN_PROC_BROWSER_TEST_F(WebauthnOfferDialogBrowserTest,
}
// Ensures closing browser while dialog being visible is correctly handled.
IN_PROC_BROWSER_TEST_F(WebauthnOfferDialogBrowserTest,
IN_PROC_BROWSER_TEST_F(WebauthnDialogBrowserTest,
CanCloseBrowserWhileDialogShowing) {
ShowUi(std::string());
VerifyUi();
......@@ -75,10 +75,10 @@ IN_PROC_BROWSER_TEST_F(WebauthnOfferDialogBrowserTest,
}
// Ensures dialog is closed when cancel button is clicked.
IN_PROC_BROWSER_TEST_F(WebauthnOfferDialogBrowserTest, ClickCancelButton) {
IN_PROC_BROWSER_TEST_F(WebauthnDialogBrowserTest, ClickCancelButton) {
ShowUi(std::string());
VerifyUi();
GetWebauthnOfferDialog()->CancelDialog();
GetWebauthnDialog()->CancelDialog();
base::RunLoop().RunUntilIdle();
}
......
......@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/views/autofill/payments/webauthn_offer_dialog_view_impl.h"
#include "chrome/browser/ui/views/autofill/payments/webauthn_dialog_view_impl.h"
#include "chrome/browser/ui/autofill/payments/webauthn_offer_dialog_controller.h"
#include "chrome/browser/ui/autofill/payments/webauthn_offer_dialog_model.h"
#include "chrome/browser/ui/autofill/payments/webauthn_dialog_controller.h"
#include "chrome/browser/ui/autofill/payments/webauthn_dialog_model.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/browser/ui/views/webauthn/authenticator_request_sheet_view.h"
#include "chrome/browser/ui/views/webauthn/sheet_view_factory.h"
......@@ -18,12 +18,12 @@
namespace autofill {
WebauthnOfferDialogViewImpl::WebauthnOfferDialogViewImpl(
WebauthnOfferDialogController* controller)
WebauthnDialogViewImpl::WebauthnDialogViewImpl(
WebauthnDialogController* controller)
: controller_(controller) {
SetLayoutManager(std::make_unique<views::FillLayout>());
std::unique_ptr<WebauthnOfferDialogModel> model =
std::make_unique<WebauthnOfferDialogModel>();
std::unique_ptr<WebauthnDialogModel> model =
std::make_unique<WebauthnDialogModel>();
model_ = model.get();
model_->AddObserver(this);
sheet_view_ =
......@@ -36,7 +36,7 @@ WebauthnOfferDialogViewImpl::WebauthnOfferDialogViewImpl(
model_->GetCancelButtonLabel());
}
WebauthnOfferDialogViewImpl::~WebauthnOfferDialogViewImpl() {
WebauthnDialogViewImpl::~WebauthnDialogViewImpl() {
model_->RemoveObserver(this);
if (controller_) {
controller_->OnDialogClosed();
......@@ -45,62 +45,59 @@ WebauthnOfferDialogViewImpl::~WebauthnOfferDialogViewImpl() {
}
// static
WebauthnOfferDialogView* WebauthnOfferDialogView::CreateAndShow(
WebauthnOfferDialogController* controller) {
WebauthnOfferDialogViewImpl* dialog =
new WebauthnOfferDialogViewImpl(controller);
WebauthnDialogView* WebauthnDialogView::CreateAndShow(
WebauthnDialogController* controller) {
WebauthnDialogViewImpl* dialog = new WebauthnDialogViewImpl(controller);
constrained_window::ShowWebModalDialogViews(dialog,
controller->GetWebContents());
return dialog;
}
WebauthnOfferDialogModel* WebauthnOfferDialogViewImpl::GetDialogModel() const {
WebauthnDialogModel* WebauthnDialogViewImpl::GetDialogModel() const {
return model_;
}
void WebauthnOfferDialogViewImpl::OnDialogStateChanged() {
void WebauthnDialogViewImpl::OnDialogStateChanged() {
switch (model_->dialog_state()) {
case WebauthnOfferDialogModel::DialogState::kInactive:
case WebauthnDialogModel::DialogState::kInactive:
Hide();
break;
case WebauthnOfferDialogModel::DialogState::kPending:
case WebauthnOfferDialogModel::DialogState::kError:
case WebauthnDialogModel::DialogState::kPending:
case WebauthnDialogModel::DialogState::kError:
RefreshContent();
break;
case WebauthnOfferDialogModel::DialogState::kUnknown:
case WebauthnOfferDialogModel::DialogState::kOffer:
case WebauthnDialogModel::DialogState::kUnknown:
case WebauthnDialogModel::DialogState::kOffer:
NOTREACHED();
}
}
gfx::Size WebauthnOfferDialogViewImpl::CalculatePreferredSize() const {
gfx::Size WebauthnDialogViewImpl::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH);
return gfx::Size(width, GetHeightForWidth(width));
}
bool WebauthnOfferDialogViewImpl::Accept() {
DCHECK_EQ(model_->dialog_state(),
WebauthnOfferDialogModel::DialogState::kOffer);
bool WebauthnDialogViewImpl::Accept() {
DCHECK_EQ(model_->dialog_state(), WebauthnDialogModel::DialogState::kOffer);
controller_->OnOkButtonClicked();
return false;
}
bool WebauthnOfferDialogViewImpl::Cancel() {
if (model_->dialog_state() == WebauthnOfferDialogModel::DialogState::kOffer ||
model_->dialog_state() ==
WebauthnOfferDialogModel::DialogState::kPending) {
bool WebauthnDialogViewImpl::Cancel() {
if (model_->dialog_state() == WebauthnDialogModel::DialogState::kOffer ||
model_->dialog_state() == WebauthnDialogModel::DialogState::kPending) {
controller_->OnCancelButtonClicked();
}
return true;
}
bool WebauthnOfferDialogViewImpl::Close() {
bool WebauthnDialogViewImpl::Close() {
return true;
}
int WebauthnOfferDialogViewImpl::GetDialogButtons() const {
int WebauthnDialogViewImpl::GetDialogButtons() const {
// Cancel button is always visible but OK button depends on dialog state.
DCHECK(model_->IsCancelButtonVisible());
return model_->IsAcceptButtonVisible()
......@@ -108,29 +105,29 @@ int WebauthnOfferDialogViewImpl::GetDialogButtons() const {
: ui::DIALOG_BUTTON_CANCEL;
}
bool WebauthnOfferDialogViewImpl::IsDialogButtonEnabled(
bool WebauthnDialogViewImpl::IsDialogButtonEnabled(
ui::DialogButton button) const {
return button == ui::DIALOG_BUTTON_OK ? model_->IsAcceptButtonEnabled()
: true;
}
ui::ModalType WebauthnOfferDialogViewImpl::GetModalType() const {
ui::ModalType WebauthnDialogViewImpl::GetModalType() const {
return ui::MODAL_TYPE_CHILD;
}
base::string16 WebauthnOfferDialogViewImpl::GetWindowTitle() const {
base::string16 WebauthnDialogViewImpl::GetWindowTitle() const {
return model_->GetStepTitle();
}
bool WebauthnOfferDialogViewImpl::ShouldShowWindowTitle() const {
bool WebauthnDialogViewImpl::ShouldShowWindowTitle() const {
return false;
}
bool WebauthnOfferDialogViewImpl::ShouldShowCloseButton() const {
bool WebauthnDialogViewImpl::ShouldShowCloseButton() const {
return false;
}
void WebauthnOfferDialogViewImpl::Hide() {
void WebauthnDialogViewImpl::Hide() {
// Reset controller reference if the controller has been destroyed before the
// view being destroyed. This happens if browser window is closed when the
// dialog is visible.
......@@ -141,7 +138,7 @@ void WebauthnOfferDialogViewImpl::Hide() {
GetWidget()->Close();
}
void WebauthnOfferDialogViewImpl::RefreshContent() {
void WebauthnDialogViewImpl::RefreshContent() {
sheet_view_->ReInitChildViews();
sheet_view_->InvalidateLayout();
DialogDelegate::set_button_label(ui::DIALOG_BUTTON_OK,
......
......@@ -2,36 +2,32 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_VIEWS_AUTOFILL_PAYMENTS_WEBAUTHN_OFFER_DIALOG_VIEW_IMPL_H_
#define CHROME_BROWSER_UI_VIEWS_AUTOFILL_PAYMENTS_WEBAUTHN_OFFER_DIALOG_VIEW_IMPL_H_
#ifndef CHROME_BROWSER_UI_VIEWS_AUTOFILL_PAYMENTS_WEBAUTHN_DIALOG_VIEW_IMPL_H_
#define CHROME_BROWSER_UI_VIEWS_AUTOFILL_PAYMENTS_WEBAUTHN_DIALOG_VIEW_IMPL_H_
#include "base/macros.h"
#include "chrome/browser/ui/autofill/payments/webauthn_offer_dialog_model_observer.h"
#include "chrome/browser/ui/autofill/payments/webauthn_offer_dialog_view.h"
#include "chrome/browser/ui/autofill/payments/webauthn_dialog_model_observer.h"
#include "chrome/browser/ui/autofill/payments/webauthn_dialog_view.h"
#include "ui/views/window/dialog_delegate.h"
class AuthenticatorRequestSheetView;
namespace autofill {
class WebauthnOfferDialogController;
class WebauthnOfferDialogModel;
class WebauthnDialogController;
class WebauthnDialogModel;
// The view of the dialog that offers the option to use device's platform
// authenticator. It is shown automatically after card unmasked details are
// obtained and filled into the form.
class WebauthnOfferDialogViewImpl : public WebauthnOfferDialogView,
public WebauthnOfferDialogModelObserver,
public views::DialogDelegateView {
class WebauthnDialogViewImpl : public WebauthnDialogView,
public WebauthnDialogModelObserver,
public views::DialogDelegateView {
public:
explicit WebauthnOfferDialogViewImpl(
WebauthnOfferDialogController* controller);
~WebauthnOfferDialogViewImpl() override;
explicit WebauthnDialogViewImpl(WebauthnDialogController* controller);
~WebauthnDialogViewImpl() override;
// WebauthnOfferDialogView:
WebauthnOfferDialogModel* GetDialogModel() const override;
// WebauthnDialogView:
WebauthnDialogModel* GetDialogModel() const override;
// WebauthnOfferDialogModelObserver:
// WebauthnDialogModelObserver:
void OnDialogStateChanged() override;
// views::DialogDelegateView:
......@@ -46,7 +42,6 @@ class WebauthnOfferDialogViewImpl : public WebauthnOfferDialogView,
bool ShouldShowWindowTitle() const override;
bool ShouldShowCloseButton() const override;
private:
// Closes the dialog.
void Hide();
......@@ -54,17 +49,17 @@ class WebauthnOfferDialogViewImpl : public WebauthnOfferDialogView,
// Re-inits dialog content and resizes.
void RefreshContent();
WebauthnOfferDialogController* controller_ = nullptr;
WebauthnDialogController* controller_ = nullptr;
AuthenticatorRequestSheetView* sheet_view_ = nullptr;
// Dialog model owned by |sheet_view_|. Since this dialog owns the
// |sheet_view_|, the model_ will always be valid.
WebauthnOfferDialogModel* model_ = nullptr;
WebauthnDialogModel* model_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(WebauthnOfferDialogViewImpl);
DISALLOW_COPY_AND_ASSIGN(WebauthnDialogViewImpl);
};
} // namespace autofill
#endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_PAYMENTS_WEBAUTHN_OFFER_DIALOG_VIEW_IMPL_H_
#endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_PAYMENTS_WEBAUTHN_DIALOG_VIEW_IMPL_H_
......@@ -5,7 +5,7 @@
#include "chrome/browser/ui/views/webauthn/sheet_view_factory.h"
#include "base/logging.h"
#include "chrome/browser/ui/autofill/payments/webauthn_offer_dialog_model.h"
#include "chrome/browser/ui/autofill/payments/webauthn_dialog_model.h"
#include "chrome/browser/ui/views/webauthn/authenticator_ble_pin_entry_sheet_view.h"
#include "chrome/browser/ui/views/webauthn/authenticator_client_pin_entry_sheet_view.h"
#include "chrome/browser/ui/views/webauthn/authenticator_qr_sheet_view.h"
......@@ -196,6 +196,6 @@ std::unique_ptr<AuthenticatorRequestSheetView> CreateSheetViewForCurrentStepOf(
std::unique_ptr<AuthenticatorRequestSheetView>
CreateSheetViewForAutofillWebAuthn(
std::unique_ptr<autofill::WebauthnOfferDialogModel> model) {
std::unique_ptr<autofill::WebauthnDialogModel> model) {
return std::make_unique<AuthenticatorRequestSheetView>(std::move(model));
}
......@@ -11,7 +11,7 @@ class AuthenticatorRequestSheetView;
class AuthenticatorRequestDialogModel;
namespace autofill {
class WebauthnOfferDialogModel;
class WebauthnDialogModel;
}
// Creates the appropriate AuthenticatorRequestSheetView subclass instance,
......@@ -21,9 +21,9 @@ std::unique_ptr<AuthenticatorRequestSheetView> CreateSheetViewForCurrentStepOf(
AuthenticatorRequestDialogModel* dialog_model);
// Creates the AuthenticatorRequestSheetView instance used by
// WebauthnOfferDialogView.
// WebauthnDialogView.
std::unique_ptr<AuthenticatorRequestSheetView>
CreateSheetViewForAutofillWebAuthn(
std::unique_ptr<autofill::WebauthnOfferDialogModel> model);
std::unique_ptr<autofill::WebauthnDialogModel> model);
#endif // CHROME_BROWSER_UI_VIEWS_WEBAUTHN_SHEET_VIEW_FACTORY_H_
......@@ -1890,7 +1890,7 @@ if (!is_android) {
"../browser/ui/views/autofill/payments/card_unmask_prompt_view_tester_views.h",
"../browser/ui/views/autofill/payments/local_card_migration_browsertest.cc",
"../browser/ui/views/autofill/payments/save_card_bubble_views_browsertest.cc",
"../browser/ui/views/autofill/payments/webauthn_offer_dialog_browsertest.cc",
"../browser/ui/views/autofill/payments/webauthn_dialog_browsertest.cc",
"../browser/ui/views/bookmarks/bookmark_bubble_view_browsertest.cc",
"../browser/ui/views/bookmarks/bookmark_editor_view_browsertest.cc",
"../browser/ui/views/certificate_selector_dialog_browsertest.cc",
......
......@@ -23,8 +23,4 @@ LogManager* AutofillClient::GetLogManager() const {
return nullptr;
}
bool AutofillClient::CloseWebauthnOfferDialog() {
return false;
}
} // namespace autofill
......@@ -307,31 +307,33 @@ class AutofillClient : public RiskDataLoader {
MigrationDeleteCardCallback delete_local_card_callback) = 0;
#if !defined(OS_ANDROID) && !defined(OS_IOS)
// Will show a dialog indicating the card verification is in progress. It is
// shown after verification starts only if the WebAuthn is enabled.
// Implemented only on desktop.
virtual void ShowVerifyPendingDialog(
base::OnceClosure cancel_card_verification_callback) = 0;
// Close the verify pending dialog once the card verificiation is completed or
// verification falls back to CVC.
virtual void CloseVerifyPendingDialog() = 0;
#endif
// Will show a dialog offering the option to use device's platform
// authenticator in the future instead of CVC to verify the card being
// unmasked. Runs |callback| if the OK button or the cancel button in the
// dialog is clicked. This is only implemented on desktop.
// unmasked. Runs |offer_dialog_callback| if the OK button or the cancel
// button in the dialog is clicked. This is only implemented on desktop.
virtual void ShowWebauthnOfferDialog(
WebauthnOfferDialogCallback callback) = 0;
WebauthnOfferDialogCallback offer_dialog_callback) = 0;
// Will update the WebAuthn offer dialog content to the error state.
// Implemented only on desktop.
virtual void UpdateWebauthnOfferDialogWithError() = 0;
// TODO(crbug.com/949269): Merge CloseWebauthnOfferDialog() and
// CloseWebauthnVerifyPendingDialog() into one function.
// Will close the WebAuthn offer dialog. Returns true if dialog was visible
// and has been closed. Implemented only on desktop.
virtual bool CloseWebauthnOfferDialog();
virtual bool CloseWebauthnOfferDialog() = 0;
// Will update the WebAuthn offer dialog content to the error state.
// Will show a dialog indicating the card verification is in progress. It is
// shown after verification starts only if the WebAuthn is enabled.
// Implemented only on desktop.
virtual void UpdateWebauthnOfferDialogWithError() {}
virtual void ShowWebauthnVerifyPendingDialog(
base::OnceClosure cancel_card_verification_callback) = 0;
// Close the verify pending dialog once the card verificiation is completed or
// verification falls back to CVC.
virtual void CloseWebauthnVerifyPendingDialog() = 0;
#endif
// Runs |callback| if the |profile| should be imported as personal data.
virtual void ConfirmSaveAutofillProfile(const AutofillProfile& profile,
......
......@@ -410,7 +410,7 @@ void CreditCardAccessManager::Authenticate(bool get_unmask_details_returned) {
#if !defined(OS_ANDROID) && !defined(OS_IOS)
// Close the verify pending dialog if it enters CVC authentication flow
// since the card unmask prompt will pop up.
client_->CloseVerifyPendingDialog();
client_->CloseWebauthnVerifyPendingDialog();
#endif
GetOrCreateCVCAuthenticator()->Authenticate(
card_, weak_ptr_factory_.GetWeakPtr(), personal_data_manager_,
......@@ -495,7 +495,7 @@ void CreditCardAccessManager::OnFIDOAuthenticationComplete(
// Close the verify pending dialog. If FIDO authentication succeeded, card is
// filled to the form, otherwise fall back to CVC authentication which does
// not need the verify pending dialog either.
client_->CloseVerifyPendingDialog();
client_->CloseWebauthnVerifyPendingDialog();
#endif
if (did_succeed) {
......@@ -527,7 +527,7 @@ bool CreditCardAccessManager::AuthenticationRequiresUnmaskDetails() {
#if !defined(OS_ANDROID) && !defined(OS_IOS)
void CreditCardAccessManager::ShowVerifyPendingDialog() {
client_->ShowVerifyPendingDialog(
client_->ShowWebauthnVerifyPendingDialog(
base::BindOnce(&CreditCardAccessManager::OnDidCancelCardVerification,
weak_ptr_factory_.GetWeakPtr()));
}
......
......@@ -63,12 +63,14 @@ CreditCardFIDOAuthenticator::~CreditCardFIDOAuthenticator() {}
void CreditCardFIDOAuthenticator::ShowWebauthnOfferDialog(
std::string card_authorization_token) {
#if !defined(OS_ANDROID)
card_authorization_token_ = card_authorization_token;
autofill_client_->ShowWebauthnOfferDialog(base::BindRepeating(
&CreditCardFIDOAuthenticator::OnWebauthnOfferDialogUserResponse,
weak_ptr_factory_.GetWeakPtr()));
AutofillMetrics::LogWebauthnOptInPromoShown(
/*is_checkout_flow=*/!card_authorization_token_.empty());
#endif
}
void CreditCardFIDOAuthenticator::Authenticate(
......@@ -387,8 +389,10 @@ void CreditCardFIDOAuthenticator::OnDidGetOptChangeResult(
// End the flow if the server responded with an error.
if (result != AutofillClient::PaymentsRpcResult::SUCCESS) {
#if !defined(OS_ANDROID)
if (current_flow_ == OPT_IN_FETCH_CHALLENGE_FLOW)
autofill_client_->UpdateWebauthnOfferDialogWithError();
#endif
current_flow_ = NONE_FLOW;
return;
}
......
......@@ -108,19 +108,21 @@ void TestAutofillClient::ShowLocalCardMigrationResults(
MigrationDeleteCardCallback delete_local_card_callback) {}
#if !defined(OS_ANDROID) && !defined(OS_IOS)
void TestAutofillClient::ShowVerifyPendingDialog(
base::OnceClosure cancel_card_verification_callback) {}
void TestAutofillClient::CloseVerifyPendingDialog() {}
#endif
void TestAutofillClient::ShowWebauthnOfferDialog(
WebauthnOfferDialogCallback callback) {}
WebauthnOfferDialogCallback offer_dialog_callback) {}
void TestAutofillClient::UpdateWebauthnOfferDialogWithError() {}
bool TestAutofillClient::CloseWebauthnOfferDialog() {
return true;
}
void TestAutofillClient::ShowWebauthnVerifyPendingDialog(
base::OnceClosure cancel_card_verification_callback) {}
void TestAutofillClient::CloseWebauthnVerifyPendingDialog() {}
#endif
void TestAutofillClient::ConfirmSaveAutofillProfile(
const AutofillProfile& profile,
base::OnceClosure callback) {
......
......@@ -66,12 +66,14 @@ class TestAutofillClient : public AutofillClient {
const std::vector<MigratableCreditCard>& migratable_credit_cards,
MigrationDeleteCardCallback delete_local_card_callback) override;
#if !defined(OS_ANDROID) && !defined(OS_IOS)
void ShowVerifyPendingDialog(
void ShowWebauthnOfferDialog(
WebauthnOfferDialogCallback offer_dialog_callback) override;
void UpdateWebauthnOfferDialogWithError() override;
bool CloseWebauthnOfferDialog() override;
void ShowWebauthnVerifyPendingDialog(
base::OnceClosure cancel_card_verification_callback) override;
void CloseVerifyPendingDialog() override;
void CloseWebauthnVerifyPendingDialog() override;
#endif
void ShowWebauthnOfferDialog(WebauthnOfferDialogCallback callback) override;
bool CloseWebauthnOfferDialog() override;
void ConfirmSaveAutofillProfile(const AutofillProfile& profile,
base::OnceClosure callback) override;
void ConfirmSaveCreditCardLocally(
......
......@@ -82,7 +82,6 @@ class ChromeAutofillClientIOS : public AutofillClient {
const base::string16& tip_message,
const std::vector<MigratableCreditCard>& migratable_credit_cards,
MigrationDeleteCardCallback delete_local_card_callback) override;
void ShowWebauthnOfferDialog(WebauthnOfferDialogCallback callback) override;
void ConfirmSaveAutofillProfile(const AutofillProfile& profile,
base::OnceClosure callback) override;
void ConfirmSaveCreditCardLocally(
......
......@@ -241,11 +241,6 @@ void ChromeAutofillClientIOS::ShowLocalCardMigrationResults(
NOTIMPLEMENTED();
}
void ChromeAutofillClientIOS::ShowWebauthnOfferDialog(
WebauthnOfferDialogCallback callback) {
NOTIMPLEMENTED();
}
void ChromeAutofillClientIOS::ConfirmSaveAutofillProfile(
const AutofillProfile& profile,
base::OnceClosure callback) {
......
......@@ -73,7 +73,6 @@ class WebViewAutofillClientIOS : public AutofillClient {
const base::string16& tip_message,
const std::vector<MigratableCreditCard>& migratable_credit_cards,
MigrationDeleteCardCallback delete_local_card_callback) override;
void ShowWebauthnOfferDialog(WebauthnOfferDialogCallback callback) override;
void ConfirmSaveAutofillProfile(const AutofillProfile& profile,
base::OnceClosure callback) override;
void ConfirmSaveCreditCardLocally(
......
......@@ -163,11 +163,6 @@ void WebViewAutofillClientIOS::ShowLocalCardMigrationResults(
NOTIMPLEMENTED();
}
void WebViewAutofillClientIOS::ShowWebauthnOfferDialog(
WebauthnOfferDialogCallback callback) {
NOTIMPLEMENTED();
}
void WebViewAutofillClientIOS::ConfirmSaveAutofillProfile(
const AutofillProfile& profile,
base::OnceClosure callback) {
......
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