| 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; | |
| 8 import android.content.Context; | 7 import android.content.Context; |
| 9 import android.util.AttributeSet; | 8 import android.util.AttributeSet; |
| 10 import android.view.LayoutInflater; | 9 import android.view.LayoutInflater; |
| 11 import android.view.View; | |
| 12 import android.widget.FrameLayout; | 10 import android.widget.FrameLayout; |
| 13 | 11 |
| 14 import org.chromium.base.ThreadUtils; | 12 import org.chromium.base.ThreadUtils; |
| 15 import org.chromium.base.annotations.CalledByNative; | 13 import org.chromium.base.annotations.CalledByNative; |
| 16 import org.chromium.base.annotations.JNINamespace; | 14 import org.chromium.base.annotations.JNINamespace; |
| 17 import org.chromium.content.browser.ActivityContentVideoViewEmbedder; | |
| 18 import org.chromium.content.browser.ContentVideoViewEmbedder; | |
| 19 import org.chromium.content.browser.ContentViewClient; | 15 import org.chromium.content.browser.ContentViewClient; |
| 20 import org.chromium.content.browser.ContentViewCore; | 16 import org.chromium.content.browser.ContentViewCore; |
| 21 import org.chromium.content.browser.ContentViewRenderView; | 17 import org.chromium.content.browser.ContentViewRenderView; |
| 22 import org.chromium.ui.base.WindowAndroid; | 18 import org.chromium.ui.base.WindowAndroid; |
| 23 | 19 |
| 24 /** | 20 /** |
| 25 * Container and generator of ShellViews. | 21 * Container and generator of ShellViews. |
| 26 */ | 22 */ |
| 27 @JNINamespace("content") | 23 @JNINamespace("content") |
| 28 public class ShellManager extends FrameLayout { | 24 public class ShellManager extends FrameLayout { |
| 29 | 25 |
| 30 public static final String DEFAULT_SHELL_URL = "http://www.google.com"; | 26 public static final String DEFAULT_SHELL_URL = "http://www.google.com"; |
| 31 private WindowAndroid mWindow; | 27 private WindowAndroid mWindow; |
| 32 private Shell mActiveShell; | 28 private Shell mActiveShell; |
| 33 | 29 |
| 34 private String mStartupUrl = DEFAULT_SHELL_URL; | 30 private String mStartupUrl = DEFAULT_SHELL_URL; |
| 35 | 31 |
| 36 // The target for all content rendering. | 32 // The target for all content rendering. |
| 37 private ContentViewRenderView mContentViewRenderView; | 33 private ContentViewRenderView mContentViewRenderView; |
| 38 private ContentViewClient mContentViewClient; | 34 private final ContentViewClient mContentViewClient = new ContentViewClient()
; |
| 39 | 35 |
| 40 /** | 36 /** |
| 41 * Constructor for inflating via XML. | 37 * Constructor for inflating via XML. |
| 42 */ | 38 */ |
| 43 public ShellManager(final Context context, AttributeSet attrs) { | 39 public ShellManager(final Context context, AttributeSet attrs) { |
| 44 super(context, attrs); | 40 super(context, attrs); |
| 45 nativeInit(this); | 41 nativeInit(this); |
| 46 mContentViewClient = new ContentViewClient() { | |
| 47 @Override | |
| 48 public ContentVideoViewEmbedder getContentVideoViewEmbedder() { | |
| 49 return new ActivityContentVideoViewEmbedder((Activity) context)
{ | |
| 50 @Override | |
| 51 public void enterFullscreenVideo(View view, boolean isVideoL
oaded) { | |
| 52 super.enterFullscreenVideo(view, isVideoLoaded); | |
| 53 setOverlayVideoMode(true); | |
| 54 } | |
| 55 | |
| 56 @Override | |
| 57 public void exitFullscreenVideo() { | |
| 58 super.exitFullscreenVideo(); | |
| 59 setOverlayVideoMode(false); | |
| 60 } | |
| 61 }; | |
| 62 } | |
| 63 }; | |
| 64 } | 42 } |
| 65 | 43 |
| 66 /** | 44 /** |
| 67 * @param window The window used to generate all shells. | 45 * @param window The window used to generate all shells. |
| 68 */ | 46 */ |
| 69 public void setWindow(WindowAndroid window) { | 47 public void setWindow(WindowAndroid window) { |
| 70 assert window != null; | 48 assert window != null; |
| 71 mWindow = window; | 49 mWindow = window; |
| 72 mContentViewRenderView = new ContentViewRenderView(getContext()); | 50 mContentViewRenderView = new ContentViewRenderView(getContext()); |
| 73 mContentViewRenderView.onNativeLibraryLoaded(window); | 51 mContentViewRenderView.onNativeLibraryLoaded(window); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 public void destroy() { | 143 public void destroy() { |
| 166 // Remove active shell (Currently single shell support only available). | 144 // Remove active shell (Currently single shell support only available). |
| 167 removeShell(mActiveShell); | 145 removeShell(mActiveShell); |
| 168 mContentViewRenderView.destroy(); | 146 mContentViewRenderView.destroy(); |
| 169 mContentViewRenderView = null; | 147 mContentViewRenderView = null; |
| 170 } | 148 } |
| 171 | 149 |
| 172 private static native void nativeInit(Object shellManagerInstance); | 150 private static native void nativeInit(Object shellManagerInstance); |
| 173 private static native void nativeLaunchShell(String url); | 151 private static native void nativeLaunchShell(String url); |
| 174 } | 152 } |
| OLD | NEW |