Index: android_webview/java/src/org/chromium/android_webview/AwContents.java |
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java |
index fc456df4a0d89ff83c3ce0ec1e57b8d2fa341ba2..8338559035220c8762571e0d4a9627c13eeb1464 100644 |
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java |
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java |
@@ -52,6 +52,7 @@ import org.chromium.content.browser.ContentViewStatics; |
import org.chromium.content.browser.LoadUrlParams; |
import org.chromium.content.browser.NavigationHistory; |
import org.chromium.content.browser.PageTransitionTypes; |
+import org.chromium.content.browser.WebContentsObserverAndroid; |
import org.chromium.content.common.CleanupReference; |
import org.chromium.content_public.Referrer; |
import org.chromium.content_public.browser.GestureStateListener; |
@@ -182,6 +183,7 @@ public class AwContents { |
private ContentViewCore mContentViewCore; |
private final AwContentsClient mContentsClient; |
private final AwContentViewClient mContentViewClient; |
+ private WebContentsObserverAndroid mWebContentsObserver; |
private final AwContentsClientBridge mContentsClientBridge; |
private final AwWebContentsDelegateAdapter mWebContentsDelegate; |
private final AwContentsIoThreadClient mIoThreadClient; |
@@ -758,7 +760,7 @@ public class AwContents { |
new AwGestureStateListener(), mContentViewClient, mZoomControls); |
nativeSetJavaPeers(mNativeAwContents, this, mWebContentsDelegate, mContentsClientBridge, |
mIoThreadClient, mInterceptNavigationDelegate); |
- mContentsClient.installWebContentsObserver(mContentViewCore.getWebContents()); |
+ installWebContentsObserver(); |
mSettings.setWebContents(nativeWebContents); |
nativeSetDipScale(mNativeAwContents, (float) mDIPScale); |
@@ -766,6 +768,14 @@ public class AwContents { |
mContentViewCore.onShow(); |
} |
+ private void installWebContentsObserver() { |
+ if (mWebContentsObserver != null) { |
+ mWebContentsObserver.detachFromWebContents(); |
+ } |
+ mWebContentsObserver = new AwWebContentsObserver(mContentViewCore.getWebContents(), |
+ mContentsClient); |
+ } |
+ |
/** |
* Called on the "source" AwContents that is opening the popup window to |
* provide the AwContents to host the pop up content. |