Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(342)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java

Issue 594103002: [aw] Unregister delegates from AwContents.destroy() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « android_webview/native/aw_contents.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
index 7d4bac5ce6094cfa3de67d2a75b3e2fe66bf430d..85e2da86ed8c4907dbfa32eca7c72bd3bbe5f88c 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
@@ -110,6 +110,16 @@ public class ContentViewCore
private static final int IS_LONG_PRESS = 1;
private static final int IS_LONG_TAP = 2;
+ private static final ZoomControlsDelegate NO_OP_ZOOM_CONTROLS_DELEGATE =
+ new ZoomControlsDelegate() {
+ @Override
+ public void invokeZoomPicker() {}
+ @Override
+ public void dismissZoomPicker() {}
+ @Override
+ public void updateZoomControls() {}
+ };
+
// If the embedder adds a JavaScript interface object that contains an indirect reference to
// the ContentViewCore, then storing a strong ref to the interface object on the native
// side would prevent garbage collection of the ContentViewCore (as that strong ref would
@@ -603,14 +613,7 @@ public class ContentViewCore
long viewAndroidNativePointer = mViewAndroid.getNativePointer();
assert viewAndroidNativePointer != 0;
- mZoomControlsDelegate = new ZoomControlsDelegate() {
- @Override
- public void invokeZoomPicker() {}
- @Override
- public void dismissZoomPicker() {}
- @Override
- public void updateZoomControls() {}
- };
+ mZoomControlsDelegate = NO_OP_ZOOM_CONTROLS_DELEGATE;
mNativeContentViewCore = nativeInit(
nativeWebContents, viewAndroidNativePointer, windowNativePointer,
@@ -779,6 +782,16 @@ public class ContentViewCore
if (mNativeContentViewCore != 0) {
nativeOnJavaContentViewCoreDestroyed(mNativeContentViewCore);
}
+ mWebContentsObserver.detachFromWebContents();
+ mWebContentsObserver = null;
+ setSmartClipDataListener(null);
+ setZoomControlsDelegate(null);
+ // TODO(igsolla): address TODO in ContentViewClient because ContentViewClient is not
+ // currently a real Null Object.
+ //
+ // Instead of deleting the client we use the Null Object pattern to avoid null checks
+ // in this class.
+ mContentViewClient = new ContentViewClient();
mWebContents = null;
if (mViewAndroid != null) mViewAndroid.destroy();
mNativeContentViewCore = 0;
@@ -1758,6 +1771,10 @@ public class ContentViewCore
}
public void setZoomControlsDelegate(ZoomControlsDelegate zoomControlsDelegate) {
+ if (zoomControlsDelegate == null) {
+ mZoomControlsDelegate = NO_OP_ZOOM_CONTROLS_DELEGATE;
+ return;
+ }
mZoomControlsDelegate = zoomControlsDelegate;
}
« no previous file with comments | « android_webview/native/aw_contents.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698