| Index: content/public/android/java/src/org/chromium/content/browser/ContentVideoView.java
|
| diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentVideoView.java b/content/public/android/java/src/org/chromium/content/browser/ContentVideoView.java
|
| index 665b401bbeeb0128f276a4ee527c66c7214f975e..94f8f5a91b9de3fb981cda399ea81f0589c46858 100644
|
| --- a/content/public/android/java/src/org/chromium/content/browser/ContentVideoView.java
|
| +++ b/content/public/android/java/src/org/chromium/content/browser/ContentVideoView.java
|
| @@ -21,7 +21,6 @@ import android.view.SurfaceHolder;
|
| import android.view.SurfaceView;
|
| import android.view.View;
|
| import android.view.ViewGroup;
|
| -import android.view.WindowManager;
|
| import android.widget.FrameLayout;
|
| import android.widget.LinearLayout;
|
| import android.widget.MediaController;
|
| @@ -101,13 +100,15 @@ public class ContentVideoView extends FrameLayout implements MediaPlayerControl,
|
|
|
| private Surface mSurface = null;
|
|
|
| - private static Activity sChromeActivity;
|
| -
|
| // There are can be at most 1 fullscreen video
|
| // TODO(qinmin): will change this once we move the creation of this class
|
| // to the host application
|
| private static ContentVideoView sContentVideoView = null;
|
|
|
| + // The delegate will follow sContentVideoView. We would need to
|
| + // move this to an instance variable if we allow multiple ContentVideoViews.
|
| + private static ContentVideoViewDelegate sDelegate = null;
|
| +
|
| private class VideoSurfaceView extends SurfaceView {
|
|
|
| public VideoSurfaceView(Context context) {
|
| @@ -373,7 +374,7 @@ public class ContentVideoView extends FrameLayout implements MediaPlayerControl,
|
| public void openVideo() {
|
| if (mSurfaceHolder != null) {
|
| mCurrentState = STATE_IDLE;
|
| - setMediaController(new FullScreenMediaController(getChromeActivity(), this));
|
| + setMediaController(new FullScreenMediaController(sDelegate.getContext(), this));
|
| if (mNativeContentVideoView != 0) {
|
| nativeUpdateMediaMetadata(mNativeContentVideoView);
|
| }
|
| @@ -544,20 +545,11 @@ public class ContentVideoView extends FrameLayout implements MediaPlayerControl,
|
| if (sContentVideoView != null)
|
| return sContentVideoView;
|
|
|
| - if (getChromeActivity() != null) {
|
| - sContentVideoView = new ContentVideoView(getChromeActivity(),
|
| + if (sDelegate != null && sDelegate.getContext() != null) {
|
| + sContentVideoView = new ContentVideoView(sDelegate.getContext(),
|
| nativeContentVideoView);
|
|
|
| - sChromeActivity.getWindow().setFlags(
|
| - WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
| - WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
| -
|
| - sChromeActivity.getWindow().addContentView(sContentVideoView,
|
| - new FrameLayout.LayoutParams(
|
| - ViewGroup.LayoutParams.MATCH_PARENT,
|
| - ViewGroup.LayoutParams.MATCH_PARENT,
|
| - Gravity.CENTER));
|
| -
|
| + sDelegate.onShowCustomView(sContentVideoView);
|
| sContentVideoView.setBackgroundColor(Color.BLACK);
|
| sContentVideoView.showContentVideoView();
|
| sContentVideoView.setVisibility(View.VISIBLE);
|
| @@ -566,10 +558,6 @@ public class ContentVideoView extends FrameLayout implements MediaPlayerControl,
|
| return null;
|
| }
|
|
|
| - public static Activity getChromeActivity() {
|
| - return sChromeActivity;
|
| - }
|
| -
|
| public void removeMediaController() {
|
| if (mMediaController != null) {
|
| mMediaController.setEnabled(false);
|
| @@ -587,7 +575,7 @@ public class ContentVideoView extends FrameLayout implements MediaPlayerControl,
|
|
|
| @CalledByNative
|
| public static void destroyContentVideoView() {
|
| - sChromeActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
| + sDelegate.onDestroyContentVideoView();
|
| if (sContentVideoView != null) {
|
| sContentVideoView.removeMediaController();
|
| sContentVideoView.removeSurfaceView();
|
| @@ -600,8 +588,8 @@ public class ContentVideoView extends FrameLayout implements MediaPlayerControl,
|
| return sContentVideoView;
|
| }
|
|
|
| - public static void registerChromeActivity(Activity activity) {
|
| - sChromeActivity = activity;
|
| + public static void registerContentVideoViewDelegate(ContentVideoViewDelegate delegate) {
|
| + sDelegate = delegate;
|
| }
|
|
|
| @Override
|
|
|