Skip to content

Commit

Permalink
[M100 Merge] Hide icon if it is visible when beginning virtual card e…
Browse files Browse the repository at this point in the history
…nrollment for a new card.

This is so that if a new enrollment bubble is shown when a previous one is still available, the user can't open the bubble through the icon before the legal messages have been rendered.

(cherry picked from commit ee3e8f4)

Change-Id: Ifb2590044f4dfb798df7189576850f13c892b7e0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3518361
Reviewed-by: Siyu An <siyua@chromium.org>
Reviewed-by: Mohamed Amir Yosef <mamir@chromium.org>
Commit-Queue: Alexander Tekle <alexandertekle@google.com>
Cr-Original-Commit-Position: refs/heads/main@{#982832}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3540708
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Krishna Govind <govind@chromium.org>
Commit-Queue: Krishna Govind <govind@chromium.org>
Owners-Override: Krishna Govind <govind@chromium.org>
Cr-Commit-Position: refs/branch-heads/4896@{#751}
Cr-Branched-From: 1f63ff4-refs/heads/main@{#972766}
  • Loading branch information
Alexander Tekle authored and Chromium LUCI CQ committed Mar 21, 2022
1 parent b11d850 commit eb2c031
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 0 deletions.
11 changes: 11 additions & 0 deletions chrome/browser/ui/autofill/chrome_autofill_client.cc
Expand Up @@ -391,6 +391,17 @@ void ChromeAutofillClient::ShowVirtualCardEnrollDialog(
std::move(decline_virtual_card_callback));
}

#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
void ChromeAutofillClient::HideVirtualCardEnrollBubbleAndIconIfVisible() {
VirtualCardEnrollBubbleControllerImpl::CreateForWebContents(web_contents());
VirtualCardEnrollBubbleControllerImpl* controller =
VirtualCardEnrollBubbleControllerImpl::FromWebContents(web_contents());

if (controller && controller->IsIconVisible())
controller->HideIconAndBubble();
}
#endif

#if !BUILDFLAG(IS_ANDROID)
std::vector<std::string>
ChromeAutofillClient::GetAllowedMerchantsForVirtualCards() {
Expand Down
3 changes: 3 additions & 0 deletions chrome/browser/ui/autofill/chrome_autofill_client.h
Expand Up @@ -104,6 +104,9 @@ class ChromeAutofillClient
const VirtualCardEnrollmentFields& virtual_card_enrollment_fields,
base::OnceClosure accept_virtual_card_callback,
base::OnceClosure decline_virtual_card_callback) override;
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
void HideVirtualCardEnrollBubbleAndIconIfVisible() override;
#endif
#if !BUILDFLAG(IS_ANDROID)
std::vector<std::string> GetAllowedMerchantsForVirtualCards() override;
std::vector<std::string> GetAllowedBinRangesForVirtualCards() override;
Expand Down
Expand Up @@ -109,6 +109,14 @@ VirtualCardEnrollBubbleControllerImpl::GetVirtualCardEnrollBubbleView() const {
return bubble_view();
}

#if !BUILDFLAG(IS_ANDROID)
void VirtualCardEnrollBubbleControllerImpl::HideIconAndBubble() {
HideBubble();
bubble_state_ = BubbleState::kHidden;
UpdatePageActionIcon();
}
#endif

void VirtualCardEnrollBubbleControllerImpl::OnAcceptButton() {
std::move(accept_virtual_card_callback_).Run();
decline_virtual_card_callback_.Reset();
Expand Down
Expand Up @@ -48,6 +48,10 @@ class VirtualCardEnrollBubbleControllerImpl
const override;
AutofillBubbleBase* GetVirtualCardEnrollBubbleView() const override;

#if !BUILDFLAG(IS_ANDROID)
void HideIconAndBubble() override;
#endif

void OnAcceptButton() override;
void OnDeclineButton() override;
void OnLinkClicked(const GURL& url) override;
Expand Down
7 changes: 7 additions & 0 deletions components/autofill/core/browser/autofill_client.cc
Expand Up @@ -91,6 +91,13 @@ void AutofillClient::ShowVirtualCardEnrollDialog(
// ChromeAutofillClient (Chrome Desktop and Clank) implements this.
}

#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
void AutofillClient::HideVirtualCardEnrollBubbleAndIconIfVisible() {
// This is overridden by platform subclasses. Currently only
// ChromeAutofillClient (Chrome Desktop) implements this.
}
#endif

#if !BUILDFLAG(IS_IOS)
std::unique_ptr<webauthn::InternalAuthenticator>
AutofillClient::CreateCreditCardInternalAuthenticator(
Expand Down
3 changes: 3 additions & 0 deletions components/autofill/core/browser/autofill_client.h
Expand Up @@ -427,6 +427,9 @@ class AutofillClient : public RiskDataLoader {
base::OnceClosure decline_virtual_card_callback);

#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
// Hides the virtual card enroll bubble and icon if it is visible.
virtual void HideVirtualCardEnrollBubbleAndIconIfVisible();

// Returns the list of allowed merchants and BIN ranges for virtual cards.
virtual std::vector<std::string> GetAllowedMerchantsForVirtualCards() = 0;
virtual std::vector<std::string> GetAllowedBinRangesForVirtualCards() = 0;
Expand Down
Expand Up @@ -59,6 +59,12 @@ void VirtualCardEnrollmentManager::OfferVirtualCardEnroll(
virtual_card_enrollment_fields_loaded_callback) {
Reset();
DCHECK_NE(virtual_card_enrollment_source, VirtualCardEnrollmentSource::kNone);
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
// Hide the bubble and icon if it is already showing for a previous enrollment
// bubble.
DCHECK(autofill_client_);
autofill_client_->HideVirtualCardEnrollBubbleAndIconIfVisible();
#endif
state_.virtual_card_enrollment_fields.credit_card = credit_card;
risk_assessment_function_ = std::move(risk_assessment_function);
virtual_card_enrollment_fields_loaded_callback_ =
Expand Down
Expand Up @@ -53,6 +53,11 @@ class VirtualCardEnrollBubbleController {
// nullptr if no bubble is visible.
virtual AutofillBubbleBase* GetVirtualCardEnrollBubbleView() const = 0;

#if !BUILDFLAG(IS_ANDROID)
// Hides the bubble and icon if it is showing.
virtual void HideIconAndBubble() = 0;
#endif

// Virtual card enroll button takes card information to enroll into a VCN.
virtual void OnAcceptButton() = 0;
virtual void OnDeclineButton() = 0;
Expand Down

0 comments on commit eb2c031

Please sign in to comment.