Commit 91c6e316 authored by skyostil@chromium.org's avatar skyostil@chromium.org

Android: implement content::Shell::Close()

This patch implements the Shell::Close() method for Content Shell on Android.

BUG=138226

Review URL: https://chromiumcodereview.appspot.com/14977010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202852 0039d316-1c4b-4281-b951-d872f2087c98
parent 537a42eb
...@@ -92,12 +92,7 @@ public class ShellManager extends FrameLayout { ...@@ -92,12 +92,7 @@ public class ShellManager extends FrameLayout {
Shell shellView = (Shell) inflater.inflate(R.layout.shell_view, null); Shell shellView = (Shell) inflater.inflate(R.layout.shell_view, null);
shellView.setWindow(mWindow); shellView.setWindow(mWindow);
removeAllViews(); if (mActiveShell != null) closeShell(mActiveShell);
if (mActiveShell != null) {
ContentView contentView = mActiveShell.getContentView();
if (contentView != null) contentView.onHide();
mActiveShell.setContentViewRenderView(null);
}
shellView.setContentViewRenderView(mContentViewRenderView); shellView.setContentViewRenderView(mContentViewRenderView);
addView(shellView, new FrameLayout.LayoutParams( addView(shellView, new FrameLayout.LayoutParams(
...@@ -112,6 +107,17 @@ public class ShellManager extends FrameLayout { ...@@ -112,6 +107,17 @@ public class ShellManager extends FrameLayout {
return shellView; return shellView;
} }
@SuppressWarnings("unused")
@CalledByNative
private void closeShell(Shell shellView) {
if (shellView == mActiveShell) mActiveShell = null;
ContentView contentView = shellView.getContentView();
if (contentView != null) contentView.onHide();
shellView.setContentViewRenderView(null);
shellView.setWindow(null);
removeView(shellView);
}
private static native void nativeInit(Object shellManagerInstance); private static native void nativeInit(Object shellManagerInstance);
private static native void nativeLaunchShell(String url); private static native void nativeLaunchShell(String url);
} }
...@@ -38,6 +38,12 @@ jobject CreateShellView(Shell* shell) { ...@@ -38,6 +38,12 @@ jobject CreateShellView(Shell* shell) {
return Java_ShellManager_createShell(env, j_shell_manager).Release(); return Java_ShellManager_createShell(env, j_shell_manager).Release();
} }
void CloseShellView(jobject shell_view) {
JNIEnv* env = base::android::AttachCurrentThread();
jobject j_shell_manager = g_global_state.Get().j_shell_manager.obj();
Java_ShellManager_closeShell(env, j_shell_manager, shell_view);
}
// Register native methods // Register native methods
bool RegisterShellManager(JNIEnv* env) { bool RegisterShellManager(JNIEnv* env) {
return RegisterNativesImpl(env); return RegisterNativesImpl(env);
......
...@@ -24,6 +24,9 @@ namespace content { ...@@ -24,6 +24,9 @@ namespace content {
// object. // object.
jobject CreateShellView(Shell* shell); jobject CreateShellView(Shell* shell);
// Closes a previously created shell view.
void CloseShellView(jobject shell_view);
// Registers the ShellManager native methods. // Registers the ShellManager native methods.
bool RegisterShellManager(JNIEnv* env); bool RegisterShellManager(JNIEnv* env);
......
...@@ -80,8 +80,9 @@ bool Shell::PlatformIsFullscreenForTabOrPending( ...@@ -80,8 +80,9 @@ bool Shell::PlatformIsFullscreenForTabOrPending(
} }
void Shell::Close() { void Shell::Close() {
// TODO(tedchoc): Implement Close method for android shell CloseShellView(java_object_.obj());
NOTIMPLEMENTED(); java_object_.Reset();
delete this;
} }
// static // static
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment