Commit 7efc56dc authored by Clemens Arbesser's avatar Clemens Arbesser Committed by Commit Bot

[Autofill Assistant] Fixed crash caused by TouchEventFilter when interacting...

[Autofill Assistant] Fixed crash caused by TouchEventFilter when interacting with page after autofill assistant has given up.

The crash was caused by listeners that were not properly unregistered.

Bug: 806868
Change-Id: Id7514b6a1c6a2a6e97ecf57b4eb4c6812ed1cb4e
Reviewed-on: https://chromium-review.googlesource.com/c/1344103Reviewed-by: default avatarStephane Zermatten <szermatt@chromium.org>
Commit-Queue: Clemens Arbesser <arbesser@google.com>
Cr-Commit-Position: refs/heads/master@{#609740}
parent c08e796e
......@@ -238,8 +238,6 @@ class AutofillAssistantUiDelegate {
.findViewById(R.id.autofill_assistant);
// TODO(crbug.com/806868): Set hint text on overlay.
mTouchEventFilter = (TouchEventFilter) mFullContainer.findViewById(R.id.touch_event_filter);
mTouchEventFilter.init(client, activity.getFullscreenManager(),
activity.getActivityTab().getWebContents());
mBottomBar = mFullContainer.findViewById(R.id.bottombar);
mBottomBar.findViewById(R.id.close_button)
.setOnClickListener(unusedView -> mClient.onDismiss());
......@@ -403,6 +401,8 @@ class AutofillAssistantUiDelegate {
public void show() {
if (mFullContainer.getVisibility() != View.VISIBLE) {
mTouchEventFilter.init(mClient, mActivity.getFullscreenManager(),
mActivity.getActivityTab().getWebContents());
mFullContainer.setVisibility(View.VISIBLE);
// Set the initial progress. It is OK to make multiple calls to this method as it will
......@@ -412,6 +412,7 @@ class AutofillAssistantUiDelegate {
}
public void hide() {
mTouchEventFilter.deInit();
mFullContainer.setVisibility(View.GONE);
}
......
......@@ -66,6 +66,7 @@ public class TouchEventFilter
private Client mClient;
private ChromeFullscreenManager mFullscreenManager;
private GestureListenerManager mGestureListenerManager;
private final List<RectF> mTouchableArea = new ArrayList<>();
private final Paint mGrayOut;
private final Paint mClear;
......@@ -174,7 +175,20 @@ public class TouchEventFilter
mClient = client;
mFullscreenManager = fullscreenManager;
mFullscreenManager.addListener(this);
GestureListenerManager.fromWebContents(webContents).addListener(this);
mGestureListenerManager = GestureListenerManager.fromWebContents(webContents);
mGestureListenerManager.addListener(this);
}
public void deInit() {
mClient = null;
if (mFullscreenManager != null) {
mFullscreenManager.removeListener(this);
mFullscreenManager = null;
}
if (mGestureListenerManager != null) {
mGestureListenerManager.removeListener(this);
mGestureListenerManager = null;
}
}
/** Sets the color to be used for unusable areas. */
......
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