Commit 62f3270d authored by igsolla's avatar igsolla Committed by Commit bot

Remove the legacy fullscreen video path in Android.

Remove the legacy fullscreen video path that was used before
html5 video controls were introduced. The last user was the
WebView, but this has been migrated to html5 controls now.

Review URL: https://codereview.chromium.org/597523003

Cr-Commit-Position: refs/heads/master@{#296935}
parent c312255d
......@@ -11,11 +11,9 @@ import android.webkit.URLUtil;
import android.webkit.WebChromeClient;
import android.widget.FrameLayout;
import org.chromium.base.CommandLine;
import org.chromium.content.browser.ContentVideoView;
import org.chromium.content.browser.ContentVideoViewClient;
import org.chromium.content.browser.ContentViewClient;
import org.chromium.content.common.ContentSwitches;
/**
* ContentViewClient implementation for WebView
......@@ -25,28 +23,6 @@ public class AwContentViewClient extends ContentViewClient {
private class AwContentVideoViewClient implements ContentVideoViewClient {
@Override
public boolean onShowCustomView(View view) {
WebChromeClient.CustomViewCallback cb = new WebChromeClient.CustomViewCallback() {
@Override
public void onCustomViewHidden() {
ContentVideoView contentVideoView = ContentVideoView.getContentVideoView();
if (contentVideoView != null)
contentVideoView.exitFullscreen(false);
}
};
// TODO(igsolla): remove the legacy path (kept as a fallback if things go awry).
if (!areHtmlControlsEnabled()) {
onShowCustomViewLegacy(view, cb);
} else {
onShowCustomView(view, cb);
}
return true;
}
private void onShowCustomViewLegacy(View view, WebChromeClient.CustomViewCallback cb) {
mAwContentsClient.onShowCustomView(view, cb);
}
private void onShowCustomView(View view, WebChromeClient.CustomViewCallback cb) {
final FrameLayout viewGroup = new FrameLayout(mContext);
viewGroup.addView(view);
viewGroup.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
......@@ -66,14 +42,21 @@ public class AwContentViewClient extends ContentViewClient {
}
}
});
WebChromeClient.CustomViewCallback cb = new WebChromeClient.CustomViewCallback() {
@Override
public void onCustomViewHidden() {
ContentVideoView contentVideoView = ContentVideoView.getContentVideoView();
if (contentVideoView != null)
contentVideoView.exitFullscreen(false);
}
};
mAwContentsClient.onShowCustomView(viewGroup, cb);
return true;
}
@Override
public void onDestroyContentVideoView() {
if (areHtmlControlsEnabled()) {
mAwContents.exitFullScreen();
}
mAwContents.exitFullScreen();
mAwContentsClient.onHideCustomView();
}
......@@ -128,9 +111,4 @@ public class AwContentViewClient extends ContentViewClient {
return mAwSettings != null ?
mAwSettings.getBlockNetworkLoads() && URLUtil.isNetworkUrl(url) : true;
}
private static boolean areHtmlControlsEnabled() {
return !CommandLine.getInstance().hasSwitch(
ContentSwitches.DISABLE_OVERLAY_FULLSCREEN_VIDEO_SUBTITLE);
}
}
......@@ -5,19 +5,15 @@
package org.chromium.android_webview.test;
import android.test.suitebuilder.annotation.MediumTest;
import android.view.KeyEvent;
import android.view.View;
import junit.framework.Assert;
import org.chromium.android_webview.test.util.JavascriptEventObserver;
import org.chromium.android_webview.test.util.VideoTestWebServer;
import org.chromium.base.CommandLine;
import org.chromium.base.test.util.Feature;
import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.test.util.DOMUtils;
import org.chromium.content.browser.test.util.TouchCommon;
import org.chromium.content.common.ContentSwitches;
/**
* Test WebChromeClient::onShow/HideCustomView.
......@@ -58,26 +54,6 @@ public class AwContentsClientFullScreenVideoTest extends AwTestBase {
});
}
@MediumTest
@Feature({"AndroidWebView"})
public void testOnShowAndHideCustomViewWithBackKeyLegacy() throws Throwable {
// When html controls are enabled we skip this test because pressing the back key
// moves away from the current activity instead of exiting fullscreen mode.
if (areHtmlControlsEnabled())
return;
doOnShowAndHideCustomViewTest(new Runnable() {
@Override
public void run() {
View customView = mContentsClient.getCustomView();
customView.dispatchKeyEvent(
new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK));
customView.dispatchKeyEvent(
new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_BACK));
}
});
}
@MediumTest
@Feature({"AndroidWebView"})
public void testOnShowAndHideCustomViewWithJavascript() throws Throwable {
......@@ -92,9 +68,6 @@ public class AwContentsClientFullScreenVideoTest extends AwTestBase {
@MediumTest
@Feature({"AndroidWebView"})
public void testOnShowCustomViewAndPlayWithHtmlControl() throws Throwable {
if (!areHtmlControlsEnabled())
return;
doOnShowCustomViewTest();
Assert.assertFalse(DOMUtils.hasVideoEnded(
mContentViewCore, VideoTestWebServer.VIDEO_ID));
......@@ -130,11 +103,6 @@ public class AwContentsClientFullScreenVideoTest extends AwTestBase {
Assert.assertFalse(mContentsClient.wasCustomViewShownCalled());
}
private static boolean areHtmlControlsEnabled() {
return !CommandLine.getInstance().hasSwitch(
ContentSwitches.DISABLE_OVERLAY_FULLSCREEN_VIDEO_SUBTITLE);
}
private void doOnShowAndHideCustomViewTest(final Runnable existFullscreen)
throws Throwable {
doOnShowCustomViewTest();
......
......@@ -37,7 +37,6 @@ import org.chromium.content.browser.ActivityContentVideoViewClient;
import org.chromium.content.browser.BrowserStartupController;
import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.DeviceUtils;
import org.chromium.content.common.ContentSwitches;
import org.chromium.printing.PrintManagerDelegateImpl;
import org.chromium.printing.PrintingController;
import org.chromium.sync.signin.AccountManagerHelper;
......@@ -141,18 +140,14 @@ public class ChromeShellActivity extends Activity implements AppMenuPropertiesDe
public boolean onShowCustomView(View view) {
if (mTabManager == null) return false;
boolean success = super.onShowCustomView(view);
if (!CommandLine.getInstance().hasSwitch(
ContentSwitches.DISABLE_OVERLAY_FULLSCREEN_VIDEO_SUBTITLE)) {
mTabManager.setOverlayVideoMode(true);
}
mTabManager.setOverlayVideoMode(true);
return success;
}
@Override
public void onDestroyContentVideoView() {
super.onDestroyContentVideoView();
if (mTabManager != null && !CommandLine.getInstance().hasSwitch(
ContentSwitches.DISABLE_OVERLAY_FULLSCREEN_VIDEO_SUBTITLE)) {
if (mTabManager != null) {
mTabManager.setOverlayVideoMode(false);
}
}
......
......@@ -249,16 +249,13 @@ gfx::NativeView ContentVideoView::GetNativeView() {
JavaObjectWeakGlobalRef ContentVideoView::CreateJavaObject() {
ContentViewCoreImpl* content_view_core = manager_->GetContentViewCore();
JNIEnv* env = AttachCurrentThread();
bool legacyMode = base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableOverlayFullscreenVideoSubtitle);
return JavaObjectWeakGlobalRef(
env,
Java_ContentVideoView_createContentVideoView(
env,
content_view_core->GetContext().obj(),
reinterpret_cast<intptr_t>(this),
content_view_core->GetContentVideoViewClient().obj(),
legacyMode).obj());
content_view_core->GetContentVideoViewClient().obj()).obj());
}
void ContentVideoView::CreatePowerSaveBlocker() {
......@@ -268,7 +265,6 @@ void ContentVideoView::CreatePowerSaveBlocker() {
// container view that was created for embedded video. The WebView cannot
// reuse that so we create a new blocker instead.
if (power_save_blocker_) return;
power_save_blocker_ = PowerSaveBlocker::Create(
PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep,
"Playing video").Pass();
......
......@@ -171,13 +171,10 @@ void BrowserMediaPlayerManager::FullscreenPlayerSeek(int msec) {
void BrowserMediaPlayerManager::ExitFullscreen(bool release_media_player) {
if (WebContentsDelegate* delegate = web_contents_->GetDelegate())
delegate->ToggleFullscreenModeForTab(web_contents_, false);
if (!CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableOverlayFullscreenVideoSubtitle)) {
if (RenderWidgetHostViewAndroid* view_android =
static_cast<RenderWidgetHostViewAndroid*>(
web_contents_->GetRenderWidgetHostView())) {
view_android->SetOverlayVideoMode(false);
}
if (RenderWidgetHostViewAndroid* view_android =
static_cast<RenderWidgetHostViewAndroid*>(
web_contents_->GetRenderWidgetHostView())) {
view_android->SetOverlayVideoMode(false);
}
Send(
......@@ -213,10 +210,6 @@ void BrowserMediaPlayerManager::SetVideoSurface(
return;
Send(new MediaPlayerMsg_DidEnterFullscreen(RoutingID(), player->player_id()));
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableOverlayFullscreenVideoSubtitle)) {
return;
}
if (RenderWidgetHostViewAndroid* view_android =
static_cast<RenderWidgetHostViewAndroid*>(
web_contents_->GetRenderWidgetHostView())) {
......
......@@ -418,21 +418,14 @@ public class ContentVideoView extends FrameLayout
@CalledByNative
private static ContentVideoView createContentVideoView(
Context context, long nativeContentVideoView, ContentVideoViewClient client,
boolean legacy) {
Context context, long nativeContentVideoView, ContentVideoViewClient client) {
ThreadUtils.assertOnUiThread();
// The context needs be Activity to create the ContentVideoView correctly.
if (!isActivityContext(context)) {
Log.e(TAG, "Wrong type of context, can't create fullscreen video");
return null;
}
ContentVideoView videoView = null;
if (legacy) {
videoView = new ContentVideoViewLegacy(context, nativeContentVideoView, client);
} else {
videoView = new ContentVideoView(context, nativeContentVideoView, client);
}
ContentVideoView videoView = new ContentVideoView(context, nativeContentVideoView, client);
if (videoView.getContentVideoViewClient().onShowCustomView(videoView)) {
return videoView;
}
......
......@@ -70,10 +70,6 @@ public abstract class ContentSwitches {
// Native switch - chrome_switches::kDisablePopupBlocking
public static final String DISABLE_POPUP_BLOCKING = "disable-popup-blocking";
// Native switch - content_switches::kDisableOverlayFullscreenVideoSubtitle
public static final String DISABLE_OVERLAY_FULLSCREEN_VIDEO_SUBTITLE =
"disable-overlay-fullscreen-video-subtitle";
// Native switch - gfx_switches::kForceDeviceScaleFactor
public static final String FORCE_DEVICE_SCALE_FACTOR =
"force-device-scale-factor";
......
......@@ -380,10 +380,6 @@ const char kEnableOneCopy[] = "enable-one-copy";
// Enables use of hardware overlay for fullscreen video playback. Android only.
const char kEnableOverlayFullscreenVideo[] = "enable-overlay-fullscreen-video";
// Disables blink subtitle and media control on top of overlay fullscreen video.
const char kDisableOverlayFullscreenVideoSubtitle[] =
"disable-overlay-fullscreen-video-subtitle";
// Forward overscroll event data from the renderer to the browser.
const char kEnableOverscrollNotifications[] = "enable-overscroll-notifications";
......
......@@ -116,7 +116,6 @@ extern const char kEnableMemoryBenchmarking[];
CONTENT_EXPORT extern const char kEnableNetworkInformation[];
CONTENT_EXPORT extern const char kEnableOneCopy[];
CONTENT_EXPORT extern const char kEnableOverlayFullscreenVideo[];
CONTENT_EXPORT extern const char kDisableOverlayFullscreenVideoSubtitle[];
CONTENT_EXPORT extern const char kEnableOverscrollNotifications[];
CONTENT_EXPORT extern const char kEnablePinch[];
CONTENT_EXPORT extern const char kEnablePreciseMemoryInfo[];
......
......@@ -12,7 +12,6 @@ import android.view.View;
import android.widget.FrameLayout;
import org.chromium.base.CalledByNative;
import org.chromium.base.CommandLine;
import org.chromium.base.JNINamespace;
import org.chromium.base.ThreadUtils;
import org.chromium.content.browser.ActivityContentVideoViewClient;
......@@ -20,7 +19,6 @@ import org.chromium.content.browser.ContentVideoViewClient;
import org.chromium.content.browser.ContentViewClient;
import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.ContentViewRenderView;
import org.chromium.content.common.ContentSwitches;
import org.chromium.ui.base.WindowAndroid;
/**
......@@ -53,20 +51,14 @@ public class ShellManager extends FrameLayout {
@Override
public boolean onShowCustomView(View view) {
boolean success = super.onShowCustomView(view);
if (!CommandLine.getInstance().hasSwitch(
ContentSwitches.DISABLE_OVERLAY_FULLSCREEN_VIDEO_SUBTITLE)) {
setOverlayVideoMode(true);
}
setOverlayVideoMode(true);
return success;
}
@Override
public void onDestroyContentVideoView() {
super.onDestroyContentVideoView();
if (!CommandLine.getInstance().hasSwitch(
ContentSwitches.DISABLE_OVERLAY_FULLSCREEN_VIDEO_SUBTITLE)) {
setOverlayVideoMode(false);
}
setOverlayVideoMode(false);
}
};
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment