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

Side by Side Diff: content/shell/android/java/src/org/chromium/content_shell/ShellManager.java

Issue 130503003: Revert "Add support for closing Android Shell instances from Java." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.content_shell; 5 package org.chromium.content_shell;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.util.AttributeSet; 8 import android.util.AttributeSet;
9 import android.view.LayoutInflater; 9 import android.view.LayoutInflater;
10 import android.widget.FrameLayout; 10 import android.widget.FrameLayout;
11 11
12 import org.chromium.base.CalledByNative; 12 import org.chromium.base.CalledByNative;
13 import org.chromium.base.JNINamespace; 13 import org.chromium.base.JNINamespace;
14 import org.chromium.base.ThreadUtils;
15 import org.chromium.content.browser.ContentView; 14 import org.chromium.content.browser.ContentView;
16 import org.chromium.content.browser.ContentViewRenderView; 15 import org.chromium.content.browser.ContentViewRenderView;
17 import org.chromium.ui.base.WindowAndroid; 16 import org.chromium.ui.base.WindowAndroid;
18 17
19 /** 18 /**
20 * Container and generator of ShellViews. 19 * Container and generator of ShellViews.
21 */ 20 */
22 @JNINamespace("content") 21 @JNINamespace("content")
23 public class ShellManager extends FrameLayout { 22 public class ShellManager extends FrameLayout {
24 23
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 */ 75 */
77 public Shell getActiveShell() { 76 public Shell getActiveShell() {
78 return mActiveShell; 77 return mActiveShell;
79 } 78 }
80 79
81 /** 80 /**
82 * Creates a new shell pointing to the specified URL. 81 * Creates a new shell pointing to the specified URL.
83 * @param url The URL the shell should load upon creation. 82 * @param url The URL the shell should load upon creation.
84 */ 83 */
85 public void launchShell(String url) { 84 public void launchShell(String url) {
86 ThreadUtils.assertOnUiThread();
87 nativeLaunchShell(url); 85 nativeLaunchShell(url);
88 } 86 }
89 87
90 /** 88 /**
91 * Enter or leave overlay video mode. 89 * Enter or leave overlay video mode.
92 * @param enabled Whether overlay mode is enabled. 90 * @param enabled Whether overlay mode is enabled.
93 */ 91 */
94 public void setOverlayVideoMode(boolean enabled) { 92 public void setOverlayVideoMode(boolean enabled) {
95 if (mContentViewRenderView == null) return; 93 if (mContentViewRenderView == null) return;
96 mContentViewRenderView.setOverlayVideoMode(enabled); 94 mContentViewRenderView.setOverlayVideoMode(enabled);
97 } 95 }
98 96
99 @SuppressWarnings("unused") 97 @SuppressWarnings("unused")
100 @CalledByNative 98 @CalledByNative
101 private Object createShell(long nativeShellPtr) { 99 private Object createShell() {
102 assert mContentViewRenderView != null; 100 assert mContentViewRenderView != null;
103 LayoutInflater inflater = 101 LayoutInflater inflater =
104 (LayoutInflater) getContext().getSystemService(Context.LAYOUT_IN FLATER_SERVICE); 102 (LayoutInflater) getContext().getSystemService(Context.LAYOUT_IN FLATER_SERVICE);
105 Shell shellView = (Shell) inflater.inflate(R.layout.shell_view, null); 103 Shell shellView = (Shell) inflater.inflate(R.layout.shell_view, null);
106 shellView.initialize(nativeShellPtr, mWindow); 104 shellView.setWindow(mWindow);
107 105
108 if (mActiveShell != null) mActiveShell.close(); 106 if (mActiveShell != null) closeShell(mActiveShell);
109 107
110 shellView.setContentViewRenderView(mContentViewRenderView); 108 shellView.setContentViewRenderView(mContentViewRenderView);
111 addView(shellView, new FrameLayout.LayoutParams( 109 addView(shellView, new FrameLayout.LayoutParams(
112 FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams. MATCH_PARENT)); 110 FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams. MATCH_PARENT));
113 mActiveShell = shellView; 111 mActiveShell = shellView;
114 ContentView contentView = mActiveShell.getContentView(); 112 ContentView contentView = mActiveShell.getContentView();
115 if (contentView != null) { 113 if (contentView != null) {
116 mContentViewRenderView.setCurrentContentView(contentView); 114 mContentViewRenderView.setCurrentContentView(contentView);
117 contentView.onShow(); 115 contentView.onShow();
118 } 116 }
119 117
120 return shellView; 118 return shellView;
121 } 119 }
122 120
123 @SuppressWarnings("unused") 121 @SuppressWarnings("unused")
124 @CalledByNative 122 @CalledByNative
125 private void removeShell(Shell shellView) { 123 private void closeShell(Shell shellView) {
126 if (shellView == mActiveShell) mActiveShell = null; 124 if (shellView == mActiveShell) mActiveShell = null;
127 ContentView contentView = shellView.getContentView(); 125 ContentView contentView = shellView.getContentView();
128 if (contentView != null) contentView.onHide(); 126 if (contentView != null) contentView.onHide();
129 shellView.setContentViewRenderView(null); 127 shellView.setContentViewRenderView(null);
128 shellView.setWindow(null);
130 removeView(shellView); 129 removeView(shellView);
131 } 130 }
132 131
133 private static native void nativeInit(Object shellManagerInstance); 132 private static native void nativeInit(Object shellManagerInstance);
134 private static native void nativeLaunchShell(String url); 133 private static native void nativeLaunchShell(String url);
135 } 134 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698