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

Unified Diff: android_webview/java/src/org/chromium/android_webview/AwContentVideoViewEmbedder.java

Issue 2353063005: Refactor ContentViewClient (1/6) (Closed)
Patch Set: cast to activity Created 4 years, 3 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: android_webview/java/src/org/chromium/android_webview/AwContentVideoViewEmbedder.java
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContentVideoViewEmbedder.java b/android_webview/java/src/org/chromium/android_webview/AwContentVideoViewEmbedder.java
new file mode 100644
index 0000000000000000000000000000000000000000..9f06e16f902786ee942a819a1e1bc4a9119ae4a0
--- /dev/null
+++ b/android_webview/java/src/org/chromium/android_webview/AwContentVideoViewEmbedder.java
@@ -0,0 +1,102 @@
+// Copyright 2016 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.android_webview;
+
+import android.content.Context;
+import android.view.Gravity;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.FrameLayout;
+import android.widget.LinearLayout;
+import android.widget.ProgressBar;
+import android.widget.TextView;
+
+import org.chromium.base.annotations.JNINamespace;
+import org.chromium.content.browser.ContentVideoViewEmbedder;
+
+/**
+ * Implementation of {@link ContentViewViewEmbedder} for webview.
+ */
+@JNINamespace("android_webview")
+public class AwContentVideoViewEmbedder implements ContentVideoViewEmbedder {
+ private final Context mContext;
+ private final AwContentsClient mAwContentsClient;
+
+ private FrameLayout mCustomView;
+ private View mProgressView;
+
+ public AwContentVideoViewEmbedder(Context context, AwContentsClient contentsClient,
+ FrameLayout customView) {
+ mContext = context;
+ mAwContentsClient = contentsClient;
+ mCustomView = customView;
+ }
+
+ public void setCustomView(FrameLayout customView) {
+ mCustomView = customView;
+ }
+
+ @Override
+ public void enterFullscreenVideo(View videoView, boolean isVideoLoaded) {
+ if (mCustomView == null) {
+ // enterFullscreenVideo will only be called after enterFullscreen, but
+ // in this case exitFullscreen has been invoked in between them.
+ // TODO(igsolla): Fix http://crbug/425926 and replace with assert.
+ return;
+ }
+
+ mCustomView.addView(videoView, 0);
+
+ if (isVideoLoaded) return;
+
+ mProgressView = mAwContentsClient.getVideoLoadingProgressView();
+ if (mProgressView == null) {
+ mProgressView = new ProgressView(mContext);
+ }
+ mCustomView.addView(
+ mProgressView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
+ ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER));
+ }
+
+ @Override
+ public void fullscreenVideoLoaded() {
+ if (mCustomView == null) return;
+
+ if (mProgressView != null) {
+ mCustomView.removeView(mProgressView);
+ mProgressView = null;
+ }
+ }
+
+ @Override
+ public void exitFullscreenVideo() {
+ // Intentional no-op
+ }
+
+ @Override
+ public void setSystemUiVisibility(boolean enterFullscreen) {
+ }
+
+ private static class ProgressView extends LinearLayout {
+ private final ProgressBar mProgressBar;
+ private final TextView mTextView;
+
+ public ProgressView(Context context) {
+ super(context);
+ setOrientation(LinearLayout.VERTICAL);
+ setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
+ LinearLayout.LayoutParams.WRAP_CONTENT));
+ mProgressBar = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);
+ mTextView = new TextView(context);
+
+ String videoLoadingText = context.getString(
+ org.chromium.android_webview.R.string.media_player_loading_video);
+
+ mTextView.setText(videoLoadingText);
+ addView(mProgressBar);
+ addView(mTextView);
+ }
+ }
+}
« no previous file with comments | « android_webview/BUILD.gn ('k') | android_webview/java/src/org/chromium/android_webview/AwContentViewClient.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698