Commit e0a45684 authored by Jinsuk Kim's avatar Jinsuk Kim Committed by Commit Bot

Android: Ensure single TabWebContentsObserver per Tab

TabWebContentsObserver is TabWebContentsUserData which is created
for the first active WebContents for a given Tab, and finally
destroyed together with the Tab. There was a bug creating
multiple instances of the observer for every new active WebContents.
This left an instance for old WebContents undestroyed, and caused
a reported bug for already nulled out WebContents references
while handling an event that should not have been triggered.

This CL makes sure there will be a single TabWebContentsObserver
for Tab.

Bug: 894353
Change-Id: Ie2cbe5c79b4d1e9f68d1be045c4d7e88d91c5312
Reviewed-on: https://chromium-review.googlesource.com/c/1278426Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Commit-Queue: Jinsuk Kim <jinsukkim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#599109}
parent 9d4f9a68
......@@ -69,7 +69,10 @@ public class TabWebContentsObserver extends TabWebContentsUserData {
private WebContentsObserver mObserver;
public static void from(Tab tab) {
tab.getUserDataHost().setUserData(USER_DATA_KEY, new TabWebContentsObserver(tab));
TabWebContentsObserver observer = get(tab);
if (observer == null) {
tab.getUserDataHost().setUserData(USER_DATA_KEY, new TabWebContentsObserver(tab));
}
}
@VisibleForTesting
......
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