Commit 25668d0d authored by Clemens Arbesser's avatar Clemens Arbesser Committed by Commit Bot

[Autofill Assistant] Allow lite scripts to survive tab changes.

This is not a proper fix, but the workaround is safe and simple. There
does not appear to be a good way for listeners of the BottomSheet to
tell the difference between a swipe-down to PEEK state versus a
swipe-down to dismiss.

However, since lite scripts disable the PEEK state altogether, we can
use the onSheetClosed(SWIPE) notification to workaround this issue for
now.

Bug: b/169237887
Change-Id: Iaf8158aa01d2259f993553860cb0825ca3a76ed5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2428887Reviewed-by: default avatarMarian Fechete <marianfe@google.com>
Commit-Queue: Clemens Arbesser <arbesser@google.com>
Cr-Commit-Position: refs/heads/master@{#811716}
parent 63570ea6
...@@ -37,6 +37,7 @@ import org.chromium.chrome.browser.util.ChromeAccessibilityUtil; ...@@ -37,6 +37,7 @@ import org.chromium.chrome.browser.util.ChromeAccessibilityUtil;
import org.chromium.components.browser_ui.bottomsheet.BottomSheetContent; import org.chromium.components.browser_ui.bottomsheet.BottomSheetContent;
import org.chromium.components.browser_ui.bottomsheet.BottomSheetController; import org.chromium.components.browser_ui.bottomsheet.BottomSheetController;
import org.chromium.components.browser_ui.bottomsheet.BottomSheetController.SheetState; import org.chromium.components.browser_ui.bottomsheet.BottomSheetController.SheetState;
import org.chromium.components.browser_ui.bottomsheet.BottomSheetController.StateChangeReason;
import org.chromium.components.browser_ui.bottomsheet.BottomSheetObserver; import org.chromium.components.browser_ui.bottomsheet.BottomSheetObserver;
import org.chromium.components.browser_ui.bottomsheet.EmptyBottomSheetObserver; import org.chromium.components.browser_ui.bottomsheet.EmptyBottomSheetObserver;
import org.chromium.content_public.browser.UiThreadTaskTraits; import org.chromium.content_public.browser.UiThreadTaskTraits;
...@@ -204,13 +205,6 @@ class AssistantBottomBarCoordinator implements AssistantPeekHeightCoordinator.De ...@@ -204,13 +205,6 @@ class AssistantBottomBarCoordinator implements AssistantPeekHeightCoordinator.De
if (newState != BottomSheetController.SheetState.SCROLLING) { if (newState != BottomSheetController.SheetState.SCROLLING) {
maybeShowHeaderChips(); maybeShowHeaderChips();
} }
if (newState == BottomSheetController.SheetState.HIDDEN) {
AssistantBottomBarDelegate delegate = mModel.getBottomBarDelegate();
if (delegate != null) {
delegate.onBottomSheetDismissed();
}
}
} }
@Override @Override
...@@ -224,6 +218,14 @@ class AssistantBottomBarCoordinator implements AssistantPeekHeightCoordinator.De ...@@ -224,6 +218,14 @@ class AssistantBottomBarCoordinator implements AssistantPeekHeightCoordinator.De
public void onSheetOffsetChanged(float heightFraction, float offsetPx) { public void onSheetOffsetChanged(float heightFraction, float offsetPx) {
updateVisualViewportHeight(); updateVisualViewportHeight();
} }
@Override
public void onSheetClosed(@StateChangeReason int reason) {
AssistantBottomBarDelegate delegate = mModel.getBottomBarDelegate();
if (reason == StateChangeReason.SWIPE && delegate != null) {
delegate.onBottomSheetClosedWithSwipe();
}
}
}; };
controller.addObserver(mBottomSheetObserver); controller.addObserver(mBottomSheetObserver);
......
...@@ -13,6 +13,9 @@ public interface AssistantBottomBarDelegate { ...@@ -13,6 +13,9 @@ public interface AssistantBottomBarDelegate {
// the new bottom sheet state and have the logic to shutdown there. Currently, this would be // the new bottom sheet state and have the logic to shutdown there. Currently, this would be
// tricky to do because it would interfere with the existing Controller::SetBottomSheetState // tricky to do because it would interfere with the existing Controller::SetBottomSheetState
// method and in particular tab switching. // method and in particular tab switching.
/** The bottom sheet was dismissed. */ /**
void onBottomSheetDismissed(); * The bottom sheet was closed with a swipe gesture. Note that this will be fired both when
* going into the PEEK state as well as when dismissing the sheet altogether.
*/
void onBottomSheetClosedWithSwipe();
} }
...@@ -32,9 +32,9 @@ public class AssistantBottomBarNativeDelegate implements AssistantBottomBarDeleg ...@@ -32,9 +32,9 @@ public class AssistantBottomBarNativeDelegate implements AssistantBottomBarDeleg
} }
@Override @Override
public void onBottomSheetDismissed() { public void onBottomSheetClosedWithSwipe() {
if (mNativeAssistantBottomBarDelegate != 0) { if (mNativeAssistantBottomBarDelegate != 0) {
AssistantBottomBarNativeDelegateJni.get().onBottomSheetDismissed( AssistantBottomBarNativeDelegateJni.get().onBottomSheetClosedWithSwipe(
mNativeAssistantBottomBarDelegate, AssistantBottomBarNativeDelegate.this); mNativeAssistantBottomBarDelegate, AssistantBottomBarNativeDelegate.this);
} }
} }
...@@ -48,7 +48,7 @@ public class AssistantBottomBarNativeDelegate implements AssistantBottomBarDeleg ...@@ -48,7 +48,7 @@ public class AssistantBottomBarNativeDelegate implements AssistantBottomBarDeleg
interface Natives { interface Natives {
boolean onBackButtonClicked( boolean onBackButtonClicked(
long nativeAssistantBottomBarDelegate, AssistantBottomBarNativeDelegate caller); long nativeAssistantBottomBarDelegate, AssistantBottomBarNativeDelegate caller);
void onBottomSheetDismissed( void onBottomSheetClosedWithSwipe(
long nativeAssistantBottomBarDelegate, AssistantBottomBarNativeDelegate caller); long nativeAssistantBottomBarDelegate, AssistantBottomBarNativeDelegate caller);
} }
} }
...@@ -111,7 +111,7 @@ class AssistantOnboardingCoordinator { ...@@ -111,7 +111,7 @@ class AssistantOnboardingCoordinator {
} }
@Override @Override
public void onBottomSheetDismissed() {} public void onBottomSheetClosedWithSwipe() {}
}); });
initContent(callback); initContent(callback);
BottomSheetUtils.showContentAndMaybeExpand( BottomSheetUtils.showContentAndMaybeExpand(
......
...@@ -30,10 +30,10 @@ bool AssistantBottomBarDelegate::OnBackButtonClicked( ...@@ -30,10 +30,10 @@ bool AssistantBottomBarDelegate::OnBackButtonClicked(
return ui_controller_->OnBackButtonClicked(); return ui_controller_->OnBackButtonClicked();
} }
void AssistantBottomBarDelegate::OnBottomSheetDismissed( void AssistantBottomBarDelegate::OnBottomSheetClosedWithSwipe(
JNIEnv* env, JNIEnv* env,
const base::android::JavaParamRef<jobject>& jcaller) { const base::android::JavaParamRef<jobject>& jcaller) {
ui_controller_->OnBottomSheetDismissed(); ui_controller_->OnBottomSheetClosedWithSwipe();
} }
base::android::ScopedJavaGlobalRef<jobject> base::android::ScopedJavaGlobalRef<jobject>
......
...@@ -19,7 +19,7 @@ class AssistantBottomBarDelegate { ...@@ -19,7 +19,7 @@ class AssistantBottomBarDelegate {
bool OnBackButtonClicked(JNIEnv* env, bool OnBackButtonClicked(JNIEnv* env,
const base::android::JavaParamRef<jobject>& jcaller); const base::android::JavaParamRef<jobject>& jcaller);
void OnBottomSheetDismissed( void OnBottomSheetClosedWithSwipe(
JNIEnv* env, JNIEnv* env,
const base::android::JavaParamRef<jobject>& jcaller); const base::android::JavaParamRef<jobject>& jcaller);
......
...@@ -922,7 +922,7 @@ bool UiControllerAndroid::OnBackButtonClicked() { ...@@ -922,7 +922,7 @@ bool UiControllerAndroid::OnBackButtonClicked() {
return true; return true;
} }
void UiControllerAndroid::OnBottomSheetDismissed() { void UiControllerAndroid::OnBottomSheetClosedWithSwipe() {
if (ui_delegate_->IsTabSelected() && ui_delegate_->IsRunningLiteScript()) { if (ui_delegate_->IsTabSelected() && ui_delegate_->IsRunningLiteScript()) {
// Destroying UI here because Shutdown does not do so in all cases. // Destroying UI here because Shutdown does not do so in all cases.
DestroySelf(); DestroySelf();
......
...@@ -168,7 +168,7 @@ class UiControllerAndroid : public ControllerObserver { ...@@ -168,7 +168,7 @@ class UiControllerAndroid : public ControllerObserver {
// Called by AssistantBottomBarNativeDelegate: // Called by AssistantBottomBarNativeDelegate:
bool OnBackButtonClicked(); bool OnBackButtonClicked();
void OnBottomSheetDismissed(); void OnBottomSheetClosedWithSwipe();
// Called by Java. // Called by Java.
void SnackbarResult(JNIEnv* env, void SnackbarResult(JNIEnv* env,
......
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