Chromium Code Reviews| Index: android_webview/java/src/org/chromium/android_webview/AwWebContentsDelegateAdapter.java |
| diff --git a/android_webview/java/src/org/chromium/android_webview/AwWebContentsDelegateAdapter.java b/android_webview/java/src/org/chromium/android_webview/AwWebContentsDelegateAdapter.java |
| index cb372ae4d1eebe8c20c08f89585504a4e7dd115b..8752566590e5d36d302e7b39a83e32a5e424aa12 100644 |
| --- a/android_webview/java/src/org/chromium/android_webview/AwWebContentsDelegateAdapter.java |
| +++ b/android_webview/java/src/org/chromium/android_webview/AwWebContentsDelegateAdapter.java |
| @@ -19,10 +19,14 @@ import android.util.Log; |
| import android.view.KeyEvent; |
| import android.view.View; |
| import android.webkit.ConsoleMessage; |
| +import android.webkit.URLUtil; |
| import android.webkit.ValueCallback; |
| +import android.webkit.WebChromeClient; |
| +import android.widget.FrameLayout; |
| import org.chromium.base.ContentUriUtils; |
| import org.chromium.base.ThreadUtils; |
| +import org.chromium.content.browser.ContentVideoViewEmbedder; |
| import org.chromium.content_public.browser.InvalidateTypes; |
| import org.chromium.content_public.common.ResourceRequestBody; |
| @@ -37,15 +41,17 @@ class AwWebContentsDelegateAdapter extends AwWebContentsDelegate { |
| private final AwContents mAwContents; |
| private final AwContentsClient mContentsClient; |
| - private final AwContentViewClient mContentViewClient; |
| + private final AwSettings mAwSettings; |
| private final Context mContext; |
| private View mContainerView; |
| + private FrameLayout mCustomView; |
| + private AwContentVideoViewEmbedder mVideoViewEmbedder; |
| public AwWebContentsDelegateAdapter(AwContents awContents, AwContentsClient contentsClient, |
| - AwContentViewClient contentViewClient, Context context, View containerView) { |
| + AwSettings settings, Context context, View containerView) { |
| mAwContents = awContents; |
| mContentsClient = contentsClient; |
| - mContentViewClient = contentViewClient; |
| + mAwSettings = settings; |
| mContext = context; |
| setContainerView(containerView); |
| } |
| @@ -264,9 +270,9 @@ class AwWebContentsDelegateAdapter extends AwWebContentsDelegate { |
| @Override |
| public void toggleFullscreenModeForTab(boolean enterFullscreen) { |
| if (enterFullscreen) { |
| - mContentViewClient.enterFullscreen(); |
| + enterFullscreen(); |
| } else { |
| - mContentViewClient.exitFullscreen(); |
| + exitFullscreen(); |
| } |
| } |
| @@ -275,6 +281,59 @@ class AwWebContentsDelegateAdapter extends AwWebContentsDelegate { |
| mContentsClient.updateTitle(mAwContents.getTitle(), false); |
| } |
| + /** |
| + * 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() { |
|
boliu
2016/09/26 21:25:24
private
Jinsuk Kim
2016/09/27 10:08:58
Done.
|
| + 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); |
| + mContentsClient.onShowCustomView(mCustomView, cb); |
| + } |
| + |
| + /** |
| + * Called to show the web contents in embedded mode. |
| + */ |
| + public void exitFullscreen() { |
|
boliu
2016/09/26 21:25:24
private
Jinsuk Kim
2016/09/27 10:08:58
Done.
|
| + if (mCustomView != null) { |
| + mCustomView = null; |
| + if (mVideoViewEmbedder != null) mVideoViewEmbedder.setCustomView(null); |
| + mAwContents.exitFullScreen(); |
| + mContentsClient.onHideCustomView(); |
| + } |
| + } |
| + |
| + @Override |
| + public ContentVideoViewEmbedder getContentVideoViewEmbedder() { |
| + mVideoViewEmbedder = new AwContentVideoViewEmbedder(mContext, mContentsClient, mCustomView); |
| + return mVideoViewEmbedder; |
| + } |
| + |
| + @Override |
| + protected boolean shouldBlockMediaRequest(String url) { |
| + return mAwSettings != null |
| + ? mAwSettings.getBlockNetworkLoads() && URLUtil.isNetworkUrl(url) : true; |
| + } |
| + |
| private static class GetDisplayNameTask extends AsyncTask<Void, Void, String[]> { |
| final int mProcessId; |
| final int mRenderId; |