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.ThreadUtils; | 14 import org.chromium.base.ThreadUtils; |
| 15 import org.chromium.base.VisibleForTesting; |
15 import org.chromium.base.annotations.CalledByNative; | 16 import org.chromium.base.annotations.CalledByNative; |
16 import org.chromium.base.annotations.JNINamespace; | 17 import org.chromium.base.annotations.JNINamespace; |
17 import org.chromium.content.browser.ActivityContentVideoViewEmbedder; | 18 import org.chromium.content.browser.ActivityContentVideoViewEmbedder; |
18 import org.chromium.content.browser.ContentVideoViewEmbedder; | 19 import org.chromium.content.browser.ContentVideoViewEmbedder; |
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 */ |
27 @JNINamespace("content") | 28 @JNINamespace("content") |
28 public class ShellManager extends FrameLayout { | 29 public class ShellManager extends FrameLayout { |
29 | 30 |
30 public static final String DEFAULT_SHELL_URL = "http://www.google.com"; | 31 public static final String DEFAULT_SHELL_URL = "http://www.google.com"; |
| 32 private static boolean sStartup = true; |
31 private WindowAndroid mWindow; | 33 private WindowAndroid mWindow; |
32 private Shell mActiveShell; | 34 private Shell mActiveShell; |
33 | 35 |
34 private String mStartupUrl = DEFAULT_SHELL_URL; | 36 private String mStartupUrl = DEFAULT_SHELL_URL; |
35 | 37 |
36 // The target for all content rendering. | 38 // The target for all content rendering. |
37 private ContentViewRenderView mContentViewRenderView; | 39 private ContentViewRenderView mContentViewRenderView; |
38 private ContentViewClient mContentViewClient; | 40 private ContentViewClient mContentViewClient; |
39 | 41 |
40 /** | 42 /** |
(...skipping 19 matching lines...) Expand all Loading... |
60 } | 62 } |
61 }; | 63 }; |
62 } | 64 } |
63 }; | 65 }; |
64 } | 66 } |
65 | 67 |
66 /** | 68 /** |
67 * @param window The window used to generate all shells. | 69 * @param window The window used to generate all shells. |
68 */ | 70 */ |
69 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) { |
70 assert window != null; | 81 assert window != null; |
71 mWindow = window; | 82 mWindow = window; |
72 mContentViewRenderView = new ContentViewRenderView(getContext()); | 83 mContentViewRenderView = new ContentViewRenderView(getContext()) { |
| 84 @Override |
| 85 protected void onReadyToRender() { |
| 86 if (sStartup) { |
| 87 if (initialLoadingNeeded) mActiveShell.loadUrl(mStartupUrl); |
| 88 sStartup = false; |
| 89 } |
| 90 } |
| 91 }; |
73 mContentViewRenderView.onNativeLibraryLoaded(window); | 92 mContentViewRenderView.onNativeLibraryLoaded(window); |
74 } | 93 } |
75 | 94 |
76 /** | 95 /** |
77 * @return The window used to generate all shells. | 96 * @return The window used to generate all shells. |
78 */ | 97 */ |
79 public WindowAndroid getWindow() { | 98 public WindowAndroid getWindow() { |
80 return mWindow; | 99 return mWindow; |
81 } | 100 } |
82 | 101 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 public void destroy() { | 184 public void destroy() { |
166 // Remove active shell (Currently single shell support only available). | 185 // Remove active shell (Currently single shell support only available). |
167 removeShell(mActiveShell); | 186 removeShell(mActiveShell); |
168 mContentViewRenderView.destroy(); | 187 mContentViewRenderView.destroy(); |
169 mContentViewRenderView = null; | 188 mContentViewRenderView = null; |
170 } | 189 } |
171 | 190 |
172 private static native void nativeInit(Object shellManagerInstance); | 191 private static native void nativeInit(Object shellManagerInstance); |
173 private static native void nativeLaunchShell(String url); | 192 private static native void nativeLaunchShell(String url); |
174 } | 193 } |
OLD | NEW |