Skip to content

Commit

Permalink
[VCN] Fix enrollment dialog closes when links are clicked
Browse files Browse the repository at this point in the history
The virtual card enrollment dialog closes when users navigate away from the page by clicking on links. Reopen the dialog when users returns to the tab.

(cherry picked from commit 54faa52)

Bug: 1323751
Change-Id: I0a129eeac1b8451b008e367b84d747eae64cc08f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3653035
Reviewed-by: Siyu An <siyua@chromium.org>
Commit-Queue: Vishwas Uppoor <vishwasuppoor@chromium.org>
Reviewed-by: Evan Stade <estade@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1004855}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3656097
Auto-Submit: Vishwas Uppoor <vishwasuppoor@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Evan Stade <estade@chromium.org>
Cr-Commit-Position: refs/branch-heads/5060@{#118}
Cr-Branched-From: b83393d-refs/heads/main@{#1002911}
  • Loading branch information
Vishwas Uppoor authored and Chromium LUCI CQ committed May 19, 2022
1 parent b320e9a commit fdcd4d9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,17 @@ void VirtualCardEnrollBubbleControllerImpl::OnDeclined(JNIEnv* env) {
}

void VirtualCardEnrollBubbleControllerImpl::OnDismissed(JNIEnv* env) {
// If the dialog is to be shown again because user clicked on links, do not
// log metrics.
if (reprompt_required_)
return;
OnBubbleClosed(PaymentsBubbleClosedReason::kNotInteracted);
}

void VirtualCardEnrollBubbleControllerImpl::OnLinkClicked(JNIEnv* env,
jstring url,
jint link_type) {
reprompt_required_ = true;
OnLinkClicked(static_cast<autofill::VirtualCardEnrollmentLinkType>(link_type),
GURL(base::android::ConvertJavaStringToUTF16(env, url)));
}
Expand All @@ -238,7 +243,12 @@ bool VirtualCardEnrollBubbleControllerImpl::IsIconVisible() const {
void VirtualCardEnrollBubbleControllerImpl::OnVisibilityChanged(
content::Visibility visibility) {
#if BUILDFLAG(IS_ANDROID)
AutofillBubbleControllerBase::OnVisibilityChanged(visibility);
if (visibility == content::Visibility::VISIBLE && !bubble_view() &&
reprompt_required_ && messages::IsSaveCardMessagesUiEnabled()) {
Show();
} else if (visibility == content::Visibility::HIDDEN) {
HideBubble();
}
#else
if (visibility == content::Visibility::VISIBLE && !bubble_view() &&
bubble_state_ == BubbleState::kShowingIconAndBubble) {
Expand All @@ -262,6 +272,7 @@ void VirtualCardEnrollBubbleControllerImpl::DoShowBubble() {
GetVirtualCardEnrollmentBubbleSource() ==
VirtualCardEnrollmentBubbleSource::
VIRTUAL_CARD_ENROLLMENT_UPSTREAM_SOURCE) {
reprompt_required_ = false;
DCHECK(!bubble_view());

set_bubble_view(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,14 @@ class VirtualCardEnrollBubbleControllerImpl
// Contains more details regarding the sort of bubble to show the users.
VirtualCardEnrollmentFields virtual_card_enrollment_fields_;

#if !BUILDFLAG(IS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
// Whether we should re-show the dialog when users return to the tab.
bool reprompt_required_ = false;
#else
// Returns whether the web content associated with this controller is active.
virtual bool IsWebContentsActive();

// True if the icon should be showing on the webpage
// Represents the current state of icon and bubble.
BubbleState bubble_state_ = BubbleState::kHidden;
#endif

Expand Down

0 comments on commit fdcd4d9

Please sign in to comment.