Index: content/shell/android/java/src/org/chromium/aura_content_shell/Shell.java |
diff --git a/content/shell/android/java/src/org/chromium/aura_content_shell/Shell.java b/content/shell/android/java/src/org/chromium/aura_content_shell/Shell.java |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7d09ed8addf337ce712f69630cd08becc01a4b4d |
--- /dev/null |
+++ b/content/shell/android/java/src/org/chromium/aura_content_shell/Shell.java |
@@ -0,0 +1,78 @@ |
+// Copyright 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+package org.chromium.aura_content_shell; |
+ |
+import android.app.Activity; |
+ |
+import org.chromium.base.annotations.CalledByNative; |
+import org.chromium.base.annotations.JNINamespace; |
+ |
+// 1. Activity creates the Java Shell class, passes itself |
+// 2. Shell.java saves Activity pointer |
+// 3. Shell.java has a Java JNI method exposed to native to access the activity |
+// 4, There's nativeInit or something which would link Java and CPP Shells |
+// 5. Cpp Shell/shell_views can access the activity and pass it to the platform |
+// window. |
+ |
+/** |
+ * Container for the various UI components that make up a shell window. |
+ */ |
+@JNINamespace("content") |
+public class Shell { |
+ |
+// private WebContents mWebContents; |
+// private NavigationController mNavigationController; |
+ |
+ private long mNativeShell; |
+ private Activity mContentShellActivity; |
+ |
+ /** |
+ * Constructor for inflating via XML. |
+ */ |
+ public Shell(Activity activity) { |
+ mContentShellActivity = activity; |
+ nativeInit(this); |
+ } |
+ |
+ /** |
+ * Initializes the Shell for use. |
+ * |
+ * @param nativeShell The pointer to the native Shell object. |
+ */ |
+ public void initialize(long nativeShell) { |
+ mNativeShell = nativeShell; |
+ } |
+ |
+ /** |
+ * 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() { |
+ mNativeShell = 0; |
+ } |
+ |
+ @CalledByNative |
+ private Object getActivity() { |
+ assert mContentShellActivity != null; |
+ return mContentShellActivity; |
+ } |
+ |
+ /** |
+ * @return Whether the Shell has been destroyed. |
+ * @see #onNativeDestroyed() |
+ */ |
+ public boolean isDestroyed() { |
+ return mNativeShell == 0; |
+ } |
+ |
+ private static native void nativeCloseShell(long shellPtr); |
+ private static native void nativeInit(Object shellInstance); |
+} |