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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ContentVideoView.java

Issue 11412076: Create a ContentVideoViewDelegate.java (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: compiler errors Created 8 years, 1 month 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: 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 b5f67ead74e6cd461c219ac084af5c0ffd9fddf5..64685e20f0514fd58af0dccde74b365dbb231d6c 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 ContentVideoViewContextDelegate sDelegate = null;
+
private class VideoSurfaceView extends SurfaceView {
public VideoSurfaceView(Context context) {
@@ -199,14 +200,11 @@ public class ContentVideoView extends FrameLayout implements MediaPlayerControl,
private static void initResources(Context context) {
if (mPlaybackErrorText != null) return;
-
- mPlaybackErrorText = context.getString(
- R.string.media_player_error_text_invalid_progressive_playback);
- mUnknownErrorText = context.getString(
- R.string.media_player_error_text_unknown);
- mErrorButton = context.getString(R.string.media_player_error_button);
- mErrorTitle = context.getString(R.string.media_player_error_title);
- mVideoLoadingText = context.getString(R.string.media_player_loading_video);
+ mPlaybackErrorText = sDelegate.getPlayBackErrorText();
+ mUnknownErrorText = sDelegate.getUnknownErrorText();
+ mErrorButton = sDelegate.getErrorButton();
+ mErrorTitle = sDelegate.getErrorTitle();
+ mVideoLoadingText = sDelegate.getVideoLoadingText();
}
void showContentVideoView() {
@@ -373,7 +371,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 +542,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 +555,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 +572,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 +585,9 @@ public class ContentVideoView extends FrameLayout implements MediaPlayerControl,
return sContentVideoView;
}
- public static void registerChromeActivity(Activity activity) {
- sChromeActivity = activity;
+ public static void registerContentVideoViewContextDelegate(
+ ContentVideoViewContextDelegate delegate) {
+ sDelegate = delegate;
}
@Override

Powered by Google App Engine
This is Rietveld 408576698