Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9487)

Unified Diff: chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastWindowManager.java

Issue 2570623003: [Chromecast] Turn CastContentWindow into an abstract interface. (Closed)
Patch Set: Fix browser test Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastWindowManager.java
diff --git a/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastWindowManager.java b/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastWindowManager.java
deleted file mode 100644
index 2cd4dd1b6273a54826e2d524bf972b36b48313c3..0000000000000000000000000000000000000000
--- a/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastWindowManager.java
+++ /dev/null
@@ -1,158 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package org.chromium.chromecast.shell;
-
-import android.content.Context;
-import android.graphics.Color;
-import android.util.AttributeSet;
-import android.view.LayoutInflater;
-import android.widget.FrameLayout;
-
-import org.chromium.base.annotations.CalledByNative;
-import org.chromium.base.annotations.JNINamespace;
-import org.chromium.content.browser.ContentViewCore;
-import org.chromium.content.browser.ContentViewRenderView;
-import org.chromium.ui.base.WindowAndroid;
-
-/**
- * Container and generator of CastWindow instances.
- */
-@JNINamespace("chromecast::shell")
-public class CastWindowManager extends FrameLayout {
- private static final String TAG = "CastWindowManager";
-
- private WindowAndroid mWindow;
- private CastWindowAndroid mActiveCastWindow;
-
- // The target for all content rendering.
- private ContentViewRenderView mContentViewRenderView;
-
- /**
- * Delegate to deliver events from the native window.
- */
- public interface Delegate {
- public void onCreated();
- public void onClosed();
- }
- private Delegate mDelegate;
-
- /**
- * Constructor for inflating via XML.
- */
- public CastWindowManager(Context context, AttributeSet attrs) {
- super(context, attrs);
- nativeInit(this);
- }
-
- /**
- * @param delegate Delegate to handle events.
- */
- public void setDelegate(Delegate delegate) {
- mDelegate = delegate;
- }
-
- /**
- * @param window Represents the activity window.
- */
- public void setWindow(WindowAndroid window) {
- assert window != null;
- mWindow = window;
- mContentViewRenderView = new ContentViewRenderView(getContext()) {
- @Override
- protected void onReadyToRender() {
- setOverlayVideoMode(true);
- }
- };
- mContentViewRenderView.onNativeLibraryLoaded(window);
- // Setting the background color to black avoids rendering a white splash screen
- // before the players are loaded. See crbug/307113 for details.
- mContentViewRenderView.setSurfaceViewBackgroundColor(Color.BLACK);
- }
-
- /**
- * @return The window used to generate all shells.
- */
- public WindowAndroid getWindow() {
- return mWindow;
- }
-
- /**
- * @return The currently visible shell view or null if one is not showing.
- */
- public CastWindowAndroid getActiveCastWindow() {
- return mActiveCastWindow;
- }
-
- /**
- * Creates a new shell pointing to the specified URL.
- * @param url The URL the shell should load upon creation.
- * @return Pointer of native cast shell instance.
- */
- public long launchCastWindow(String url) {
- return nativeLaunchCastWindow(url);
- }
-
- /**
- * Stops a native cast shell instance created by {@link #launchCastWindow(String)}.
- * @param nativeCastWindow Pointer of native cast shell instance returned
- * by {@link #launchCastWindow(String)}.
- * @param gracefully Whether or not to call RVH::ClosePage to deliver unload event.
- * @see #launchCastWindow(String)
- */
- public void stopCastWindow(long nativeCastWindow, boolean gracefully) {
- nativeStopCastWindow(nativeCastWindow, gracefully);
- }
-
- @SuppressWarnings("unused")
- @CalledByNative
- private Object createCastWindow() {
- assert mContentViewRenderView != null;
- LayoutInflater inflater =
- (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- CastWindowAndroid shellView =
- (CastWindowAndroid) inflater.inflate(R.layout.cast_window_view, null);
- shellView.setWindow(mWindow);
-
- if (mActiveCastWindow != null) closeCastWindow(mActiveCastWindow);
-
- shellView.setContentViewRenderView(mContentViewRenderView);
- addView(shellView, new FrameLayout.LayoutParams(
- FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
- mActiveCastWindow = shellView;
- ContentViewCore contentViewCore = mActiveCastWindow.getContentViewCore();
- if (contentViewCore != null) {
- mContentViewRenderView.setCurrentContentViewCore(contentViewCore);
- contentViewCore.onShow();
- }
-
- if (mDelegate != null) {
- mDelegate.onCreated();
- }
-
- return shellView;
- }
-
- @SuppressWarnings("unused")
- @CalledByNative
- private void closeCastWindow(CastWindowAndroid shellView) {
- if (shellView == mActiveCastWindow) mActiveCastWindow = null;
- ContentViewCore contentViewCore = shellView.getContentViewCore();
- if (contentViewCore != null) contentViewCore.onHide();
- shellView.setContentViewRenderView(null);
- shellView.setWindow(null);
- removeView(shellView);
- mContentViewRenderView.destroy();
- mContentViewRenderView = null;
- if (mDelegate != null) {
- mDelegate.onClosed();
- }
- }
-
- private static native void nativeInit(Object shellManagerInstance);
- private static native long nativeLaunchCastWindow(String url);
- private static native void nativeStopCastWindow(long pointerOfNativeCastWindow,
- boolean gracefully);
- public static native void nativeEnableDevTools(boolean enable);
-}

Powered by Google App Engine
This is Rietveld 408576698