| 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.JNINamespace; | 15 import org.chromium.base.JNINamespace; |
| 16 import org.chromium.base.ThreadUtils; | 16 import org.chromium.base.ThreadUtils; |
| 17 import org.chromium.base.VisibleForTesting; |
| 17 import org.chromium.content.browser.ActivityContentVideoViewClient; | 18 import org.chromium.content.browser.ActivityContentVideoViewClient; |
| 18 import org.chromium.content.browser.ContentVideoViewClient; | 19 import org.chromium.content.browser.ContentVideoViewClient; |
| 19 import org.chromium.content.browser.ContentViewClient; | 20 import org.chromium.content.browser.ContentViewClient; |
| 20 import org.chromium.content.browser.ContentViewCore; | 21 import org.chromium.content.browser.ContentViewCore; |
| 21 import org.chromium.content.browser.ContentViewRenderView; | 22 import org.chromium.content.browser.ContentViewRenderView; |
| 22 import org.chromium.ui.base.WindowAndroid; | 23 import org.chromium.ui.base.WindowAndroid; |
| 23 | 24 |
| 24 /** | 25 /** |
| 25 * Container and generator of ShellViews. | 26 * Container and generator of ShellViews. |
| 26 */ | 27 */ |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 } | 62 } |
| 62 }; | 63 }; |
| 63 } | 64 } |
| 64 }; | 65 }; |
| 65 } | 66 } |
| 66 | 67 |
| 67 /** | 68 /** |
| 68 * @param window The window used to generate all shells. | 69 * @param window The window used to generate all shells. |
| 69 */ | 70 */ |
| 70 public void setWindow(WindowAndroid window) { | 71 public void setWindow(WindowAndroid window) { |
| 72 setWindow(window, true); |
| 73 } |
| 74 |
| 75 /** |
| 76 * @param window The window used to generate all shells. |
| 77 * @param initialLoadingNeeded Whether initial loading is needed or not. |
| 78 */ |
| 79 @VisibleForTesting |
| 80 public void setWindow(WindowAndroid window, final boolean initialLoadingNeed
ed) { |
| 71 assert window != null; | 81 assert window != null; |
| 72 mWindow = window; | 82 mWindow = window; |
| 73 mContentViewRenderView = new ContentViewRenderView(getContext()) { | 83 mContentViewRenderView = new ContentViewRenderView(getContext()) { |
| 74 @Override | 84 @Override |
| 75 protected void onReadyToRender() { | 85 protected void onReadyToRender() { |
| 76 if (sStartup) { | 86 if (sStartup) { |
| 77 mActiveShell.loadUrl(mStartupUrl); | 87 if (initialLoadingNeeded) mActiveShell.loadUrl(mStartupUrl); |
| 78 sStartup = false; | 88 sStartup = false; |
| 79 } | 89 } |
| 80 } | 90 } |
| 81 | 91 |
| 82 @Override | 92 @Override |
| 83 protected void onWindowVisibilityChanged(int visibility) { | 93 protected void onWindowVisibilityChanged(int visibility) { |
| 84 if (visibility == View.GONE && mActiveShell != null) { | 94 if (visibility == View.GONE && mActiveShell != null) { |
| 85 ContentViewCore contentViewCore = mActiveShell.getContentVie
wCore(); | 95 ContentViewCore contentViewCore = mActiveShell.getContentVie
wCore(); |
| 86 if (contentViewCore != null) contentViewCore.onHide(); | 96 if (contentViewCore != null) contentViewCore.onHide(); |
| 87 } | 97 } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 if (shellView.getParent() == null) return; | 183 if (shellView.getParent() == null) return; |
| 174 ContentViewCore contentViewCore = shellView.getContentViewCore(); | 184 ContentViewCore contentViewCore = shellView.getContentViewCore(); |
| 175 if (contentViewCore != null) contentViewCore.onHide(); | 185 if (contentViewCore != null) contentViewCore.onHide(); |
| 176 shellView.setContentViewRenderView(null); | 186 shellView.setContentViewRenderView(null); |
| 177 removeView(shellView); | 187 removeView(shellView); |
| 178 } | 188 } |
| 179 | 189 |
| 180 private static native void nativeInit(Object shellManagerInstance); | 190 private static native void nativeInit(Object shellManagerInstance); |
| 181 private static native void nativeLaunchShell(String url); | 191 private static native void nativeLaunchShell(String url); |
| 182 } | 192 } |
| OLD | NEW |