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

Unified Diff: android_webview/java/src/org/chromium/android_webview/AwContentViewClient.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/AwContentViewClient.java
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContentViewClient.java b/android_webview/java/src/org/chromium/android_webview/AwContentViewClient.java
index b06de5e30c2b6e0e1e3d44d0fd2d7b42090a690d..0192b2b0ccf9decc4284be2fd2977fe5ae3fa8cc 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContentViewClient.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContentViewClient.java
@@ -6,30 +6,18 @@ package org.chromium.android_webview;
import android.content.Context;
import android.content.Intent;
-import android.view.Gravity;
import android.view.KeyEvent;
-import android.view.View;
-import android.view.ViewGroup;
-import android.webkit.URLUtil;
-import android.webkit.WebChromeClient;
-import android.widget.FrameLayout;
-import android.widget.LinearLayout;
-import android.widget.ProgressBar;
-import android.widget.TextView;
-import org.chromium.content.browser.ContentVideoViewEmbedder;
import org.chromium.content.browser.ContentViewClient;
/**
* ContentViewClient implementation for WebView
*/
-public class AwContentViewClient extends ContentViewClient implements ContentVideoViewEmbedder {
+public class AwContentViewClient extends ContentViewClient {
private final AwContentsClient mAwContentsClient;
private final AwSettings mAwSettings;
private final AwContents mAwContents;
private final Context mContext;
- private FrameLayout mCustomView;
- private View mProgressView;
public AwContentViewClient(AwContentsClient awContentsClient, AwSettings awSettings,
AwContents awContents, Context context) {
@@ -69,58 +57,6 @@ public class AwContentViewClient extends ContentViewClient implements ContentVid
}
@Override
- public final ContentVideoViewEmbedder getContentVideoViewEmbedder() {
- return this;
- }
-
- @Override
- public boolean shouldBlockMediaRequest(String url) {
- return mAwSettings != null
- ? mAwSettings.getBlockNetworkLoads() && URLUtil.isNetworkUrl(url) : true;
- }
-
- @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) {
- }
-
- @Override
public boolean doesPerformProcessText() {
return true;
}
@@ -134,71 +70,4 @@ public class AwContentViewClient extends ContentViewClient implements ContentVid
public boolean isSelectActionModeAllowed(int actionModeItem) {
return mAwContents.isSelectActionModeAllowed(actionModeItem);
}
-
- /**
- * Called to show the web contents in fullscreen mode.
- *
- * <p>If entering fullscreen on a video element the web contents will contain just
- * the html5 video controls. {@link #enterFullscreenVideo(View)} will be called later
- * once the ContentVideoView, which contains the hardware accelerated fullscreen video,
- * is ready to be shown.
- */
- public void enterFullscreen() {
- if (mAwContents.isFullScreen()) {
- return;
- }
- View fullscreenView = mAwContents.enterFullScreen();
- if (fullscreenView == null) {
- return;
- }
- WebChromeClient.CustomViewCallback cb = new WebChromeClient.CustomViewCallback() {
- @Override
- public void onCustomViewHidden() {
- if (mCustomView != null) {
- mAwContents.requestExitFullscreen();
- }
- }
- };
- mCustomView = new FrameLayout(mContext);
- mCustomView.addView(fullscreenView);
- mAwContentsClient.onShowCustomView(mCustomView, cb);
- }
-
- /**
- * Called to show the web contents in embedded mode.
- */
- public void exitFullscreen() {
- if (mCustomView != null) {
- mCustomView = null;
- mProgressView = null;
- mAwContents.exitFullScreen();
- mAwContentsClient.onHideCustomView();
- }
- }
-
- @Override
- public String getProductVersion() {
- return AwContentsStatics.getProductVersion();
- }
-
- 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);
- }
- }
}

Powered by Google App Engine
This is Rietveld 408576698