| 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.WindowAndroid; |
| 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 public static final String DEFAULT_SHELL_URL = "http://www.google.com"; | 24 public static final String DEFAULT_SHELL_URL = "http://www.google.com"; |
| 25 private static boolean sStartup = true; | 25 private static boolean sStartup = true; |
| 26 private NativeWindow mWindow; | 26 private WindowAndroid mWindow; |
| 27 private Shell mActiveShell; | 27 private Shell mActiveShell; |
| 28 | 28 |
| 29 private String mStartupUrl = DEFAULT_SHELL_URL; | 29 private String mStartupUrl = DEFAULT_SHELL_URL; |
| 30 | 30 |
| 31 // The target for all content rendering. | 31 // The target for all content rendering. |
| 32 private ContentViewRenderView mContentViewRenderView; | 32 private ContentViewRenderView mContentViewRenderView; |
| 33 | 33 |
| 34 /** | 34 /** |
| 35 * Constructor for inflating via XML. | 35 * Constructor for inflating via XML. |
| 36 */ | 36 */ |
| 37 public ShellManager(Context context, AttributeSet attrs) { | 37 public ShellManager(Context context, AttributeSet attrs) { |
| 38 super(context, attrs); | 38 super(context, attrs); |
| 39 nativeInit(this); | 39 nativeInit(this); |
| 40 mContentViewRenderView = new ContentViewRenderView(context) { | 40 mContentViewRenderView = new ContentViewRenderView(context) { |
| 41 @Override | 41 @Override |
| 42 protected void onReadyToRender() { | 42 protected void onReadyToRender() { |
| 43 if (sStartup) { | 43 if (sStartup) { |
| 44 mActiveShell.loadUrl(mStartupUrl); | 44 mActiveShell.loadUrl(mStartupUrl); |
| 45 sStartup = false; | 45 sStartup = false; |
| 46 } | 46 } |
| 47 } | 47 } |
| 48 }; | 48 }; |
| 49 } | 49 } |
| 50 | 50 |
| 51 /** | 51 /** |
| 52 * @param window The window used to generate all shells. | 52 * @param window The window used to generate all shells. |
| 53 */ | 53 */ |
| 54 public void setWindow(NativeWindow window) { | 54 public void setWindow(WindowAndroid window) { |
| 55 mWindow = window; | 55 mWindow = window; |
| 56 } | 56 } |
| 57 | 57 |
| 58 /** | 58 /** |
| 59 * @return The window used to generate all shells. | 59 * @return The window used to generate all shells. |
| 60 */ | 60 */ |
| 61 public NativeWindow getWindow() { | 61 public WindowAndroid getWindow() { |
| 62 return mWindow; | 62 return mWindow; |
| 63 } | 63 } |
| 64 | 64 |
| 65 /** | 65 /** |
| 66 * Sets the startup URL for new shell windows. | 66 * Sets the startup URL for new shell windows. |
| 67 */ | 67 */ |
| 68 public void setStartupUrl(String url) { | 68 public void setStartupUrl(String url) { |
| 69 mStartupUrl = url; | 69 mStartupUrl = url; |
| 70 } | 70 } |
| 71 | 71 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 mContentViewRenderView.setCurrentContentView(contentView); | 108 mContentViewRenderView.setCurrentContentView(contentView); |
| 109 contentView.onShow(); | 109 contentView.onShow(); |
| 110 } | 110 } |
| 111 | 111 |
| 112 return shellView; | 112 return shellView; |
| 113 } | 113 } |
| 114 | 114 |
| 115 private static native void nativeInit(Object shellManagerInstance); | 115 private static native void nativeInit(Object shellManagerInstance); |
| 116 private static native void nativeLaunchShell(String url); | 116 private static native void nativeLaunchShell(String url); |
| 117 } | 117 } |
| OLD | NEW |