| 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 f07285b3f08ac05c764048b5942832008cad3829..554ccb19d98d6694892b00c9ddcd04fecdfe09dc 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
|
| @@ -126,6 +126,21 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
|
| public void updateZoomControls() {}
|
| };
|
|
|
| + /**
|
| + * Observer for changes to WindowAndroid. Mirrors
|
| + * ContentViewCoreImplObserver in native. Appends 'Android' to (a) match
|
| + * WindowAndroid, and (b) avoid a name collision with View.
|
| + */
|
| + public interface Observer {
|
| + public void onContentViewCoreDestroyed(ContentViewCore cvc);
|
| + public void onAttachedToWindowAndroid(ContentViewCore cvc);
|
| + public void onDetachedFromWindowAndroid(ContentViewCore cvc);
|
| + }
|
| +
|
| + // Single observer. We only support one right now, since we have only one
|
| + // consumer of it.
|
| + private Observer mObserver;
|
| +
|
| // 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
|
| @@ -905,6 +920,7 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
|
| private void onNativeContentViewCoreDestroyed(long nativeContentViewCore) {
|
| assert nativeContentViewCore == mNativeContentViewCore;
|
| mNativeContentViewCore = 0;
|
| + if (mObserver != null) mObserver.onContentViewCoreDestroyed(this);
|
| }
|
|
|
| /**
|
| @@ -3463,6 +3479,28 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
|
| return mShowKeyboardResultReceiver;
|
| }
|
|
|
| + // Set our observer. We support only a single observer right now.
|
| + public void addObserver(Observer observer) {
|
| + assert mObserver == null;
|
| + mObserver = observer;
|
| + }
|
| +
|
| + // Remove our single observer.
|
| + public void removeObserver(Observer observer) {
|
| + assert mObserver == observer;
|
| + mObserver = null;
|
| + }
|
| +
|
| + @CalledByNative
|
| + private void onAttachedToWindowAndroid() {
|
| + if (mObserver != null) mObserver.onAttachedToWindowAndroid(this);
|
| + }
|
| +
|
| + @CalledByNative
|
| + private void onDetachedFromWindowAndroid() {
|
| + if (mObserver != null) mObserver.onDetachedFromWindowAndroid(this);
|
| + }
|
| +
|
| private native long nativeInit(WebContents webContents, ViewAndroidDelegate viewAndroidDelegate,
|
| long windowAndroidPtr, HashSet<Object> retainedObjectSet);
|
| private static native ContentViewCore nativeFromWebContentsAndroid(WebContents webContents);
|
|
|