OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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.content.browser.ContentView; | 14 import org.chromium.content.browser.ContentView; |
15 import org.chromium.content.browser.ContentViewRenderView; | 15 import org.chromium.content.browser.ContentViewRenderView; |
16 import org.chromium.ui.gfx.NativeWindow; | 16 import org.chromium.ui.gfx.NativeWindow; |
17 | 17 |
18 /** | 18 /** |
19 * Container and generator of ShellViews. | 19 * Container and generator of ShellViews. |
20 */ | 20 */ |
21 @JNINamespace("content") | 21 @JNINamespace("content") |
22 public class ShellManager extends FrameLayout { | 22 public class ShellManager extends FrameLayout { |
23 | 23 |
| 24 private static boolean sStartup = true; |
24 private NativeWindow mWindow; | 25 private NativeWindow mWindow; |
25 private Shell mActiveShell; | 26 private Shell mActiveShell; |
26 | 27 |
27 private String mStartupUrl = ContentShellActivity.DEFAULT_SHELL_URL; | 28 private String mStartupUrl = ContentShellActivity.DEFAULT_SHELL_URL; |
28 | 29 |
29 // The target for all content rendering. | 30 // The target for all content rendering. |
30 private ContentViewRenderView mContentViewRenderView; | 31 private ContentViewRenderView mContentViewRenderView; |
31 | 32 |
32 /** | 33 /** |
33 * Constructor for inflating via XML. | 34 * Constructor for inflating via XML. |
34 */ | 35 */ |
35 public ShellManager(Context context, AttributeSet attrs) { | 36 public ShellManager(Context context, AttributeSet attrs) { |
36 super(context, attrs); | 37 super(context, attrs); |
37 nativeInit(this); | 38 nativeInit(this); |
38 mContentViewRenderView = new ContentViewRenderView(context) { | 39 mContentViewRenderView = new ContentViewRenderView(context) { |
39 @Override | 40 @Override |
40 protected void onReadyToRender() { | 41 protected void onReadyToRender() { |
41 mActiveShell.loadUrl(mStartupUrl); | 42 if (sStartup) { |
| 43 mActiveShell.loadUrl(mStartupUrl); |
| 44 sStartup = false; |
| 45 } |
42 } | 46 } |
43 }; | 47 }; |
44 } | 48 } |
45 | 49 |
46 /** | 50 /** |
47 * @param window The window used to generate all shells. | 51 * @param window The window used to generate all shells. |
48 */ | 52 */ |
49 public void setWindow(NativeWindow window) { | 53 public void setWindow(NativeWindow window) { |
50 mWindow = window; | 54 mWindow = window; |
51 } | 55 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 mContentViewRenderView.setCurrentContentView(contentView); | 107 mContentViewRenderView.setCurrentContentView(contentView); |
104 contentView.onShow(); | 108 contentView.onShow(); |
105 } | 109 } |
106 | 110 |
107 return shellView; | 111 return shellView; |
108 } | 112 } |
109 | 113 |
110 private static native void nativeInit(Object shellManagerInstance); | 114 private static native void nativeInit(Object shellManagerInstance); |
111 private static native void nativeLaunchShell(String url); | 115 private static native void nativeLaunchShell(String url); |
112 } | 116 } |
OLD | NEW |