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

Unified Diff: content/shell/android/java/src/org/chromium/content_shell/Shell.java

Issue 117403003: Add support for closing Android Shell instances from Java. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changed to allow full closing of Shells from java. Created 6 years, 11 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
Index: content/shell/android/java/src/org/chromium/content_shell/Shell.java
diff --git a/content/shell/android/java/src/org/chromium/content_shell/Shell.java b/content/shell/android/java/src/org/chromium/content_shell/Shell.java
index 1ec5919eae826ce8dd5eb6662cc2e8b2db5c24c6..29ebbadf7d7f253778a9ec84c2329054cc886779 100644
--- a/content/shell/android/java/src/org/chromium/content_shell/Shell.java
+++ b/content/shell/android/java/src/org/chromium/content_shell/Shell.java
@@ -49,6 +49,7 @@ public class Shell extends LinearLayout {
private ClipDrawable mProgressDrawable;
+ private long mNativeShell;
private ContentViewRenderView mContentViewRenderView;
private WindowAndroid mWindow;
@@ -80,13 +81,43 @@ public class Shell extends LinearLayout {
}
/**
+ * Initializes the Shell for use.
+ *
+ * @param nativeShell The pointer to the native Shell object.
* @param window The owning window for this shell.
*/
- public void setWindow(WindowAndroid window) {
+ public void initialize(long nativeShell, WindowAndroid window) {
+ mNativeShell = nativeShell;
mWindow = window;
}
/**
+ * Closes the shell and cleans up the native instance, which will handle destroying all
+ * dependencies.
+ */
+ public void close() {
+ if (mNativeShell == 0) return;
+ nativeCloseShell(mNativeShell);
+ }
+
+ @CalledByNative
+ private void onNativeDestroyed() {
+ mWindow = null;
+ mNativeShell = 0;
+ assert !mContentView.isAttachedToWindow()
+ : "Attempting to destroy the content view while attached to the view hierarchy.";
+ mContentView.destroy();
+ }
+
+ /**
+ * @return Whether the Shell has been destroyed.
+ * @see #onNativeDestroyed()
+ */
+ public boolean isDestroyed() {
+ return mNativeShell == 0;
+ }
+
+ /**
* @return Whether or not the Shell is loading content.
*/
public boolean isLoading() {
@@ -242,4 +273,6 @@ public class Shell extends LinearLayout {
imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0);
}
}
+
+ private static native void nativeCloseShell(long nativeShell);
}

Powered by Google App Engine
This is Rietveld 408576698