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