Commit 21c9b738 authored by sandromaggi's avatar sandromaggi Committed by Commit Bot

[Autofill Assistant] Do not revive when switching from CCT to Browser

Before this change, when the Autofill Assistant was dismissed with the
cancel button showing the Snackbar, and changing from CCT to Browser
during the time the Snackbar was open, Autofill Assistant would revive
in the browser.

This happens, because the UI gets destroyed and recreated, losing all
knowledge about the Snackbar.

Now, if a Snackbar is showing when the switch happens, we execute the
callback immediately, which might shut down Autofill Assistant.

Bug: b/159784978
Change-Id: I600bc0de4796c9f65533d1627030963a83b02865
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2302196Reviewed-by: default avatarClemens Arbesser <arbesser@google.com>
Commit-Queue: Sandro Maggi <sandromaggi@google.com>
Cr-Commit-Position: refs/heads/master@{#789447}
parent ec2ae2d4
...@@ -179,6 +179,12 @@ public class AutofillAssistantUiController { ...@@ -179,6 +179,12 @@ public class AutofillAssistantUiController {
safeNativeStop(DropOutReason.TAB_DETACHED); safeNativeStop(DropOutReason.TAB_DETACHED);
return; return;
} }
// If we have an open snackbar, execute the callback immediately. This
// may shut down the Autofill Assistant.
if (mSnackbarController != null) {
mSnackbarController.onDismissNoAction(/* actionData= */ null);
}
AutofillAssistantClient.fromWebContents(mWebContents).destroyUi(); AutofillAssistantClient.fromWebContents(mWebContents).destroyUi();
} }
} }
...@@ -382,9 +388,10 @@ public class AutofillAssistantUiController { ...@@ -382,9 +388,10 @@ public class AutofillAssistantUiController {
// Native methods. // Native methods.
private void safeSnackbarResult(boolean undo) { private void safeSnackbarResult(boolean undo) {
if (mNativeUiController != 0) { if (mSnackbarController != null && mNativeUiController != 0) {
AutofillAssistantUiControllerJni.get().snackbarResult( AutofillAssistantUiControllerJni.get().snackbarResult(
mNativeUiController, AutofillAssistantUiController.this, undo); mNativeUiController, AutofillAssistantUiController.this, undo);
mSnackbarController = null;
} }
} }
......
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