OLD | NEW |
---|---|
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.app.Activity; | 7 import android.app.Activity; |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.util.AttributeSet; | 9 import android.util.AttributeSet; |
10 import android.view.LayoutInflater; | 10 import android.view.LayoutInflater; |
11 import android.view.View; | 11 import android.view.View; |
12 import android.widget.FrameLayout; | 12 import android.widget.FrameLayout; |
13 | 13 |
14 import org.chromium.base.CalledByNative; | 14 import org.chromium.base.CalledByNative; |
15 import org.chromium.base.CommandLine; | |
15 import org.chromium.base.JNINamespace; | 16 import org.chromium.base.JNINamespace; |
16 import org.chromium.base.ThreadUtils; | 17 import org.chromium.base.ThreadUtils; |
18 import org.chromium.base.VisibleForTesting; | |
17 import org.chromium.content.browser.ActivityContentVideoViewClient; | 19 import org.chromium.content.browser.ActivityContentVideoViewClient; |
18 import org.chromium.content.browser.ContentVideoViewClient; | 20 import org.chromium.content.browser.ContentVideoViewClient; |
19 import org.chromium.content.browser.ContentViewClient; | 21 import org.chromium.content.browser.ContentViewClient; |
20 import org.chromium.content.browser.ContentViewCore; | 22 import org.chromium.content.browser.ContentViewCore; |
21 import org.chromium.content.browser.ContentViewRenderView; | 23 import org.chromium.content.browser.ContentViewRenderView; |
22 import org.chromium.ui.base.WindowAndroid; | 24 import org.chromium.ui.base.WindowAndroid; |
23 | 25 |
24 /** | 26 /** |
25 * Container and generator of ShellViews. | 27 * Container and generator of ShellViews. |
26 */ | 28 */ |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
61 } | 63 } |
62 }; | 64 }; |
63 } | 65 } |
64 }; | 66 }; |
65 } | 67 } |
66 | 68 |
67 /** | 69 /** |
68 * @param window The window used to generate all shells. | 70 * @param window The window used to generate all shells. |
69 */ | 71 */ |
70 public void setWindow(WindowAndroid window) { | 72 public void setWindow(WindowAndroid window) { |
73 setWindow(window, true); | |
74 } | |
75 | |
76 /** | |
77 * @param window The window used to generate all shells. | |
78 * @param initialLoadingNeeded Whether initial loading is needed or not. | |
79 */ | |
80 @VisibleForTesting | |
81 public void setWindow(WindowAndroid window, final boolean initialLoadingNeed ed) { | |
71 assert window != null; | 82 assert window != null; |
72 mWindow = window; | 83 mWindow = window; |
73 mContentViewRenderView = new ContentViewRenderView(getContext()) { | 84 mContentViewRenderView = new ContentViewRenderView(getContext()) { |
74 @Override | 85 @Override |
75 protected void onReadyToRender() { | 86 protected void onReadyToRender() { |
76 if (sStartup) { | 87 if (sStartup) { |
77 mActiveShell.loadUrl(mStartupUrl); | 88 if (initialLoadingNeeded) mActiveShell.loadUrl(mStartupUrl); |
78 sStartup = false; | 89 sStartup = false; |
79 } | 90 } |
80 } | 91 } |
81 | 92 |
82 @Override | 93 @Override |
83 protected void onWindowVisibilityChanged(int visibility) { | 94 protected void onWindowVisibilityChanged(int visibility) { |
84 if (visibility == View.GONE && mActiveShell != null) { | 95 if (visibility == View.GONE && mActiveShell != null) { |
85 ContentViewCore contentViewCore = mActiveShell.getContentVie wCore(); | 96 ContentViewCore contentViewCore = mActiveShell.getContentVie wCore(); |
86 if (contentViewCore != null) contentViewCore.onHide(); | 97 if (contentViewCore != null) contentViewCore.onHide(); |
87 } | 98 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 | 161 |
151 // TODO(tedchoc): Allow switching back to these inactive shells. | 162 // TODO(tedchoc): Allow switching back to these inactive shells. |
152 if (mActiveShell != null) removeShell(mActiveShell); | 163 if (mActiveShell != null) removeShell(mActiveShell); |
153 | 164 |
154 showShell(shellView); | 165 showShell(shellView); |
155 return shellView; | 166 return shellView; |
156 } | 167 } |
157 | 168 |
158 private void showShell(Shell shellView) { | 169 private void showShell(Shell shellView) { |
159 shellView.setContentViewRenderView(mContentViewRenderView); | 170 shellView.setContentViewRenderView(mContentViewRenderView); |
160 addView(shellView, new FrameLayout.LayoutParams( | 171 // If GPU hardware acceleration is disabled, composition shouldn't happe n. |
161 FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams. MATCH_PARENT)); | 172 if (!CommandLine.getInstance().hasSwitch("disable-gpu")) { |
Jaekyun Seok (inactive)
2015/02/23 10:41:34
I found that ChildDiscardableSharedMemoryManagerBr
no sievers
2015/02/24 02:02:32
--disable-gpu is not supported on Android.
Let's
Jaekyun Seok (inactive)
2015/02/24 12:49:50
Then I will disable those tests as a workaround, a
| |
173 addView(shellView, new FrameLayout.LayoutParams(FrameLayout.LayoutPa rams.MATCH_PARENT, | |
174 FrameLayout.LayoutParams.MATCH_PARENT)); | |
175 } | |
162 mActiveShell = shellView; | 176 mActiveShell = shellView; |
163 ContentViewCore contentViewCore = mActiveShell.getContentViewCore(); | 177 ContentViewCore contentViewCore = mActiveShell.getContentViewCore(); |
164 if (contentViewCore != null) { | 178 if (contentViewCore != null) { |
165 mContentViewRenderView.setCurrentContentViewCore(contentViewCore); | 179 mContentViewRenderView.setCurrentContentViewCore(contentViewCore); |
166 contentViewCore.onShow(); | 180 contentViewCore.onShow(); |
167 } | 181 } |
168 } | 182 } |
169 | 183 |
170 @CalledByNative | 184 @CalledByNative |
171 private void removeShell(Shell shellView) { | 185 private void removeShell(Shell shellView) { |
172 if (shellView == mActiveShell) mActiveShell = null; | 186 if (shellView == mActiveShell) mActiveShell = null; |
173 if (shellView.getParent() == null) return; | 187 if (shellView.getParent() == null) return; |
174 ContentViewCore contentViewCore = shellView.getContentViewCore(); | 188 ContentViewCore contentViewCore = shellView.getContentViewCore(); |
175 if (contentViewCore != null) contentViewCore.onHide(); | 189 if (contentViewCore != null) contentViewCore.onHide(); |
176 shellView.setContentViewRenderView(null); | 190 shellView.setContentViewRenderView(null); |
177 removeView(shellView); | 191 removeView(shellView); |
178 } | 192 } |
179 | 193 |
180 private static native void nativeInit(Object shellManagerInstance); | 194 private static native void nativeInit(Object shellManagerInstance); |
181 private static native void nativeLaunchShell(String url); | 195 private static native void nativeLaunchShell(String url); |
182 } | 196 } |
OLD | NEW |