Commit 9b3041c0 authored by Clemens Arbesser's avatar Clemens Arbesser Committed by Commit Bot

[Autofill Assistant] Disable lite scripts when transitioning from CCT.

Currently, we don't have a good way of transitioning lite scripts from
CCT to regular tab. This changes the activity, but does not update the
dependencies of the lite scripts, thus leading to crash when accessing
those dependencies.

As a workaround, this CL disables stops lite scripts when transitioning
from CCT to regular tab. This is an edge case, so disabling this should
not affect the scheduled LE.

For a proper fix, we need to investigate how to update the dependencies
such that lite scripts can continue safely.

Bug: b/167947210
Change-Id: I1524805015766c69f463892a9bec4d5b9c5a284e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2431484Reviewed-by: default avatarMarian Fechete <marianfe@google.com>
Commit-Queue: Clemens Arbesser <arbesser@google.com>
Cr-Commit-Position: refs/heads/master@{#811719}
parent 26523dd9
......@@ -166,7 +166,8 @@ public class AutofillAssistantUiController {
dismissSnackbar();
if (tab == null) {
safeOnTabSwitched(getModel().getBottomSheetState());
safeOnTabSwitched(getModel().getBottomSheetState(),
/* activityChanged = */ false);
// A null tab indicates that there's no selected tab; Most likely, we're
// in the process of selecting a new tab. Hide the UI for possible reuse
// later.
......@@ -183,7 +184,8 @@ public class AutofillAssistantUiController {
}
} else {
//
safeOnTabSwitched(getModel().getBottomSheetState());
safeOnTabSwitched(getModel().getBottomSheetState(),
/* activityChanged = */ false);
// A new tab was selected. If Autofill Assistant is running on it,
// attach the UI to that other instance, otherwise destroy the UI.
AutofillAssistantClient.fromWebContents(mWebContents)
......@@ -205,7 +207,8 @@ public class AutofillAssistantUiController {
return;
}
safeOnTabSwitched(getModel().getBottomSheetState());
safeOnTabSwitched(
getModel().getBottomSheetState(), /* activityChanged = */ true);
// If we have an open snackbar, execute the callback immediately. This
// may shut down the Autofill Assistant.
if (mSnackbarController != null) {
......@@ -481,10 +484,10 @@ public class AutofillAssistantUiController {
}
}
private void safeOnTabSwitched(@SheetState int state) {
private void safeOnTabSwitched(@SheetState int state, boolean activityChanged) {
if (mNativeUiController != 0) {
AutofillAssistantUiControllerJni.get().onTabSwitched(
mNativeUiController, AutofillAssistantUiController.this, state);
AutofillAssistantUiControllerJni.get().onTabSwitched(mNativeUiController,
AutofillAssistantUiController.this, state, activityChanged);
}
}
......@@ -514,7 +517,7 @@ public class AutofillAssistantUiController {
void setVisible(long nativeUiControllerAndroid, AutofillAssistantUiController caller,
boolean visible);
void onTabSwitched(long nativeUiControllerAndroid, AutofillAssistantUiController caller,
@SheetState int state);
@SheetState int state, boolean activityChanged);
void onTabSelected(long nativeUiControllerAndroid, AutofillAssistantUiController caller);
}
}
......@@ -696,11 +696,21 @@ void UiControllerAndroid::RestoreUi() {
void UiControllerAndroid::OnTabSwitched(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& jcaller,
jint state) {
jint state,
jboolean activity_changed) {
if (ui_delegate_ == nullptr) {
return;
}
// TODO(b/167947210) Allow lite scripts to transition from CCT to regular
// scripts.
if (activity_changed && ui_delegate_->IsRunningLiteScript()) {
// Destroying UI here because Shutdown does not do so in all cases.
DestroySelf();
Shutdown(Metrics::DropOutReason::CUSTOM_TAB_CLOSED);
return;
}
ui_delegate_->SetBottomSheetState(
ui_controller_android_utils::ToNativeBottomSheetState(state));
ui_delegate_->SetTabSelected(false);
......
......@@ -203,7 +203,8 @@ class UiControllerAndroid : public ControllerObserver {
jboolean visible);
void OnTabSwitched(JNIEnv* env,
const base::android::JavaParamRef<jobject>& jcaller,
jint state);
jint state,
jboolean activity_changed);
void OnTabSelected(JNIEnv* env,
const base::android::JavaParamRef<jobject>& jcaller);
......
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