| 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.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.ThreadUtils; | 12 import org.chromium.base.ThreadUtils; |
| 13 import org.chromium.base.annotations.CalledByNative; | 13 import org.chromium.base.annotations.CalledByNative; |
| 14 import org.chromium.base.annotations.JNINamespace; | 14 import org.chromium.base.annotations.JNINamespace; |
| 15 import org.chromium.content.browser.ContentViewClient; | |
| 16 import org.chromium.content.browser.ContentViewCore; | 15 import org.chromium.content.browser.ContentViewCore; |
| 17 import org.chromium.content.browser.ContentViewRenderView; | 16 import org.chromium.content.browser.ContentViewRenderView; |
| 18 import org.chromium.ui.base.WindowAndroid; | 17 import org.chromium.ui.base.WindowAndroid; |
| 19 | 18 |
| 20 /** | 19 /** |
| 21 * Container and generator of ShellViews. | 20 * Container and generator of ShellViews. |
| 22 */ | 21 */ |
| 23 @JNINamespace("content") | 22 @JNINamespace("content") |
| 24 public class ShellManager extends FrameLayout { | 23 public class ShellManager extends FrameLayout { |
| 25 | 24 |
| 26 public static final String DEFAULT_SHELL_URL = "http://www.google.com"; | 25 public static final String DEFAULT_SHELL_URL = "http://www.google.com"; |
| 27 private WindowAndroid mWindow; | 26 private WindowAndroid mWindow; |
| 28 private Shell mActiveShell; | 27 private Shell mActiveShell; |
| 29 | 28 |
| 30 private String mStartupUrl = DEFAULT_SHELL_URL; | 29 private String mStartupUrl = DEFAULT_SHELL_URL; |
| 31 | 30 |
| 32 // The target for all content rendering. | 31 // The target for all content rendering. |
| 33 private ContentViewRenderView mContentViewRenderView; | 32 private ContentViewRenderView mContentViewRenderView; |
| 34 private final ContentViewClient mContentViewClient = new ContentViewClient()
; | |
| 35 | 33 |
| 36 /** | 34 /** |
| 37 * Constructor for inflating via XML. | 35 * Constructor for inflating via XML. |
| 38 */ | 36 */ |
| 39 public ShellManager(final Context context, AttributeSet attrs) { | 37 public ShellManager(final Context context, AttributeSet attrs) { |
| 40 super(context, attrs); | 38 super(context, attrs); |
| 41 nativeInit(this); | 39 nativeInit(this); |
| 42 } | 40 } |
| 43 | 41 |
| 44 /** | 42 /** |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 mContentViewRenderView.setOverlayVideoMode(enabled); | 97 mContentViewRenderView.setOverlayVideoMode(enabled); |
| 100 } | 98 } |
| 101 | 99 |
| 102 @SuppressWarnings("unused") | 100 @SuppressWarnings("unused") |
| 103 @CalledByNative | 101 @CalledByNative |
| 104 private Object createShell(long nativeShellPtr) { | 102 private Object createShell(long nativeShellPtr) { |
| 105 assert mContentViewRenderView != null; | 103 assert mContentViewRenderView != null; |
| 106 LayoutInflater inflater = | 104 LayoutInflater inflater = |
| 107 (LayoutInflater) getContext().getSystemService(Context.LAYOUT_IN
FLATER_SERVICE); | 105 (LayoutInflater) getContext().getSystemService(Context.LAYOUT_IN
FLATER_SERVICE); |
| 108 Shell shellView = (Shell) inflater.inflate(R.layout.shell_view, null); | 106 Shell shellView = (Shell) inflater.inflate(R.layout.shell_view, null); |
| 109 shellView.initialize(nativeShellPtr, mWindow, mContentViewClient); | 107 shellView.initialize(nativeShellPtr, mWindow); |
| 110 | 108 |
| 111 // TODO(tedchoc): Allow switching back to these inactive shells. | 109 // TODO(tedchoc): Allow switching back to these inactive shells. |
| 112 if (mActiveShell != null) removeShell(mActiveShell); | 110 if (mActiveShell != null) removeShell(mActiveShell); |
| 113 | 111 |
| 114 showShell(shellView); | 112 showShell(shellView); |
| 115 return shellView; | 113 return shellView; |
| 116 } | 114 } |
| 117 | 115 |
| 118 private void showShell(Shell shellView) { | 116 private void showShell(Shell shellView) { |
| 119 shellView.setContentViewRenderView(mContentViewRenderView); | 117 shellView.setContentViewRenderView(mContentViewRenderView); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 143 public void destroy() { | 141 public void destroy() { |
| 144 // Remove active shell (Currently single shell support only available). | 142 // Remove active shell (Currently single shell support only available). |
| 145 removeShell(mActiveShell); | 143 removeShell(mActiveShell); |
| 146 mContentViewRenderView.destroy(); | 144 mContentViewRenderView.destroy(); |
| 147 mContentViewRenderView = null; | 145 mContentViewRenderView = null; |
| 148 } | 146 } |
| 149 | 147 |
| 150 private static native void nativeInit(Object shellManagerInstance); | 148 private static native void nativeInit(Object shellManagerInstance); |
| 151 private static native void nativeLaunchShell(String url); | 149 private static native void nativeLaunchShell(String url); |
| 152 } | 150 } |
| OLD | NEW |