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; ...@@ -11,11 +11,9 @@ import android.webkit.URLUtil;
import android.webkit.WebChromeClient; import android.webkit.WebChromeClient;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import org.chromium.base.CommandLine;
import org.chromium.content.browser.ContentVideoView; import org.chromium.content.browser.ContentVideoView;
import org.chromium.content.browser.ContentVideoViewClient; import org.chromium.content.browser.ContentVideoViewClient;
import org.chromium.content.browser.ContentViewClient; import org.chromium.content.browser.ContentViewClient;
import org.chromium.content.common.ContentSwitches;
/** /**
* ContentViewClient implementation for WebView * ContentViewClient implementation for WebView
...@@ -25,28 +23,6 @@ public class AwContentViewClient extends ContentViewClient { ...@@ -25,28 +23,6 @@ public class AwContentViewClient extends ContentViewClient {
private class AwContentVideoViewClient implements ContentVideoViewClient { private class AwContentVideoViewClient implements ContentVideoViewClient {
@Override @Override
public boolean onShowCustomView(View view) { 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); final FrameLayout viewGroup = new FrameLayout(mContext);
viewGroup.addView(view); viewGroup.addView(view);
viewGroup.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() { viewGroup.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
...@@ -66,14 +42,21 @@ public class AwContentViewClient extends ContentViewClient { ...@@ -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); mAwContentsClient.onShowCustomView(viewGroup, cb);
return true;
} }
@Override @Override
public void onDestroyContentVideoView() { public void onDestroyContentVideoView() {
if (areHtmlControlsEnabled()) {
mAwContents.exitFullScreen(); mAwContents.exitFullScreen();
}
mAwContentsClient.onHideCustomView(); mAwContentsClient.onHideCustomView();
} }
...@@ -128,9 +111,4 @@ public class AwContentViewClient extends ContentViewClient { ...@@ -128,9 +111,4 @@ public class AwContentViewClient extends ContentViewClient {
return mAwSettings != null ? return mAwSettings != null ?
mAwSettings.getBlockNetworkLoads() && URLUtil.isNetworkUrl(url) : true; mAwSettings.getBlockNetworkLoads() && URLUtil.isNetworkUrl(url) : true;
} }
private static boolean areHtmlControlsEnabled() {
return !CommandLine.getInstance().hasSwitch(
ContentSwitches.DISABLE_OVERLAY_FULLSCREEN_VIDEO_SUBTITLE);
}
} }
...@@ -5,19 +5,15 @@ ...@@ -5,19 +5,15 @@
package org.chromium.android_webview.test; package org.chromium.android_webview.test;
import android.test.suitebuilder.annotation.MediumTest; import android.test.suitebuilder.annotation.MediumTest;
import android.view.KeyEvent;
import android.view.View;
import junit.framework.Assert; import junit.framework.Assert;
import org.chromium.android_webview.test.util.JavascriptEventObserver; import org.chromium.android_webview.test.util.JavascriptEventObserver;
import org.chromium.android_webview.test.util.VideoTestWebServer; import org.chromium.android_webview.test.util.VideoTestWebServer;
import org.chromium.base.CommandLine;
import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Feature;
import org.chromium.content.browser.ContentViewCore; import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.test.util.DOMUtils; import org.chromium.content.browser.test.util.DOMUtils;
import org.chromium.content.browser.test.util.TouchCommon; import org.chromium.content.browser.test.util.TouchCommon;
import org.chromium.content.common.ContentSwitches;
/** /**
* Test WebChromeClient::onShow/HideCustomView. * Test WebChromeClient::onShow/HideCustomView.
...@@ -58,26 +54,6 @@ public class AwContentsClientFullScreenVideoTest extends AwTestBase { ...@@ -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 @MediumTest
@Feature({"AndroidWebView"}) @Feature({"AndroidWebView"})
public void testOnShowAndHideCustomViewWithJavascript() throws Throwable { public void testOnShowAndHideCustomViewWithJavascript() throws Throwable {
...@@ -92,9 +68,6 @@ public class AwContentsClientFullScreenVideoTest extends AwTestBase { ...@@ -92,9 +68,6 @@ public class AwContentsClientFullScreenVideoTest extends AwTestBase {
@MediumTest @MediumTest
@Feature({"AndroidWebView"}) @Feature({"AndroidWebView"})
public void testOnShowCustomViewAndPlayWithHtmlControl() throws Throwable { public void testOnShowCustomViewAndPlayWithHtmlControl() throws Throwable {
if (!areHtmlControlsEnabled())
return;
doOnShowCustomViewTest(); doOnShowCustomViewTest();
Assert.assertFalse(DOMUtils.hasVideoEnded( Assert.assertFalse(DOMUtils.hasVideoEnded(
mContentViewCore, VideoTestWebServer.VIDEO_ID)); mContentViewCore, VideoTestWebServer.VIDEO_ID));
...@@ -130,11 +103,6 @@ public class AwContentsClientFullScreenVideoTest extends AwTestBase { ...@@ -130,11 +103,6 @@ public class AwContentsClientFullScreenVideoTest extends AwTestBase {
Assert.assertFalse(mContentsClient.wasCustomViewShownCalled()); Assert.assertFalse(mContentsClient.wasCustomViewShownCalled());
} }
private static boolean areHtmlControlsEnabled() {
return !CommandLine.getInstance().hasSwitch(
ContentSwitches.DISABLE_OVERLAY_FULLSCREEN_VIDEO_SUBTITLE);
}
private void doOnShowAndHideCustomViewTest(final Runnable existFullscreen) private void doOnShowAndHideCustomViewTest(final Runnable existFullscreen)
throws Throwable { throws Throwable {
doOnShowCustomViewTest(); doOnShowCustomViewTest();
......
...@@ -37,7 +37,6 @@ import org.chromium.content.browser.ActivityContentVideoViewClient; ...@@ -37,7 +37,6 @@ import org.chromium.content.browser.ActivityContentVideoViewClient;
import org.chromium.content.browser.BrowserStartupController; import org.chromium.content.browser.BrowserStartupController;
import org.chromium.content.browser.ContentViewCore; import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.DeviceUtils; import org.chromium.content.browser.DeviceUtils;
import org.chromium.content.common.ContentSwitches;
import org.chromium.printing.PrintManagerDelegateImpl; import org.chromium.printing.PrintManagerDelegateImpl;
import org.chromium.printing.PrintingController; import org.chromium.printing.PrintingController;
import org.chromium.sync.signin.AccountManagerHelper; import org.chromium.sync.signin.AccountManagerHelper;
...@@ -141,18 +140,14 @@ public class ChromeShellActivity extends Activity implements AppMenuPropertiesDe ...@@ -141,18 +140,14 @@ public class ChromeShellActivity extends Activity implements AppMenuPropertiesDe
public boolean onShowCustomView(View view) { public boolean onShowCustomView(View view) {
if (mTabManager == null) return false; if (mTabManager == null) return false;
boolean success = super.onShowCustomView(view); boolean success = super.onShowCustomView(view);
if (!CommandLine.getInstance().hasSwitch(
ContentSwitches.DISABLE_OVERLAY_FULLSCREEN_VIDEO_SUBTITLE)) {
mTabManager.setOverlayVideoMode(true); mTabManager.setOverlayVideoMode(true);
}
return success; return success;
} }
@Override @Override
public void onDestroyContentVideoView() { public void onDestroyContentVideoView() {
super.onDestroyContentVideoView(); super.onDestroyContentVideoView();
if (mTabManager != null && !CommandLine.getInstance().hasSwitch( if (mTabManager != null) {
ContentSwitches.DISABLE_OVERLAY_FULLSCREEN_VIDEO_SUBTITLE)) {
mTabManager.setOverlayVideoMode(false); mTabManager.setOverlayVideoMode(false);
} }
} }
......
...@@ -249,16 +249,13 @@ gfx::NativeView ContentVideoView::GetNativeView() { ...@@ -249,16 +249,13 @@ gfx::NativeView ContentVideoView::GetNativeView() {
JavaObjectWeakGlobalRef ContentVideoView::CreateJavaObject() { JavaObjectWeakGlobalRef ContentVideoView::CreateJavaObject() {
ContentViewCoreImpl* content_view_core = manager_->GetContentViewCore(); ContentViewCoreImpl* content_view_core = manager_->GetContentViewCore();
JNIEnv* env = AttachCurrentThread(); JNIEnv* env = AttachCurrentThread();
bool legacyMode = base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableOverlayFullscreenVideoSubtitle);
return JavaObjectWeakGlobalRef( return JavaObjectWeakGlobalRef(
env, env,
Java_ContentVideoView_createContentVideoView( Java_ContentVideoView_createContentVideoView(
env, env,
content_view_core->GetContext().obj(), content_view_core->GetContext().obj(),
reinterpret_cast<intptr_t>(this), reinterpret_cast<intptr_t>(this),
content_view_core->GetContentVideoViewClient().obj(), content_view_core->GetContentVideoViewClient().obj()).obj());
legacyMode).obj());
} }
void ContentVideoView::CreatePowerSaveBlocker() { void ContentVideoView::CreatePowerSaveBlocker() {
...@@ -268,7 +265,6 @@ void ContentVideoView::CreatePowerSaveBlocker() { ...@@ -268,7 +265,6 @@ void ContentVideoView::CreatePowerSaveBlocker() {
// container view that was created for embedded video. The WebView cannot // container view that was created for embedded video. The WebView cannot
// reuse that so we create a new blocker instead. // reuse that so we create a new blocker instead.
if (power_save_blocker_) return; if (power_save_blocker_) return;
power_save_blocker_ = PowerSaveBlocker::Create( power_save_blocker_ = PowerSaveBlocker::Create(
PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep,
"Playing video").Pass(); "Playing video").Pass();
......
...@@ -171,14 +171,11 @@ void BrowserMediaPlayerManager::FullscreenPlayerSeek(int msec) { ...@@ -171,14 +171,11 @@ void BrowserMediaPlayerManager::FullscreenPlayerSeek(int msec) {
void BrowserMediaPlayerManager::ExitFullscreen(bool release_media_player) { void BrowserMediaPlayerManager::ExitFullscreen(bool release_media_player) {
if (WebContentsDelegate* delegate = web_contents_->GetDelegate()) if (WebContentsDelegate* delegate = web_contents_->GetDelegate())
delegate->ToggleFullscreenModeForTab(web_contents_, false); delegate->ToggleFullscreenModeForTab(web_contents_, false);
if (!CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableOverlayFullscreenVideoSubtitle)) {
if (RenderWidgetHostViewAndroid* view_android = if (RenderWidgetHostViewAndroid* view_android =
static_cast<RenderWidgetHostViewAndroid*>( static_cast<RenderWidgetHostViewAndroid*>(
web_contents_->GetRenderWidgetHostView())) { web_contents_->GetRenderWidgetHostView())) {
view_android->SetOverlayVideoMode(false); view_android->SetOverlayVideoMode(false);
} }
}
Send( Send(
new MediaPlayerMsg_DidExitFullscreen(RoutingID(), fullscreen_player_id_)); new MediaPlayerMsg_DidExitFullscreen(RoutingID(), fullscreen_player_id_));
...@@ -213,10 +210,6 @@ void BrowserMediaPlayerManager::SetVideoSurface( ...@@ -213,10 +210,6 @@ void BrowserMediaPlayerManager::SetVideoSurface(
return; return;
Send(new MediaPlayerMsg_DidEnterFullscreen(RoutingID(), player->player_id())); Send(new MediaPlayerMsg_DidEnterFullscreen(RoutingID(), player->player_id()));
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableOverlayFullscreenVideoSubtitle)) {
return;
}
if (RenderWidgetHostViewAndroid* view_android = if (RenderWidgetHostViewAndroid* view_android =
static_cast<RenderWidgetHostViewAndroid*>( static_cast<RenderWidgetHostViewAndroid*>(
web_contents_->GetRenderWidgetHostView())) { web_contents_->GetRenderWidgetHostView())) {
......
...@@ -418,21 +418,14 @@ public class ContentVideoView extends FrameLayout ...@@ -418,21 +418,14 @@ public class ContentVideoView extends FrameLayout
@CalledByNative @CalledByNative
private static ContentVideoView createContentVideoView( private static ContentVideoView createContentVideoView(
Context context, long nativeContentVideoView, ContentVideoViewClient client, Context context, long nativeContentVideoView, ContentVideoViewClient client) {
boolean legacy) {
ThreadUtils.assertOnUiThread(); ThreadUtils.assertOnUiThread();
// The context needs be Activity to create the ContentVideoView correctly. // The context needs be Activity to create the ContentVideoView correctly.
if (!isActivityContext(context)) { if (!isActivityContext(context)) {
Log.e(TAG, "Wrong type of context, can't create fullscreen video"); Log.e(TAG, "Wrong type of context, can't create fullscreen video");
return null; return null;
} }
ContentVideoView videoView = null; ContentVideoView videoView = new ContentVideoView(context, nativeContentVideoView, client);
if (legacy) {
videoView = new ContentVideoViewLegacy(context, nativeContentVideoView, client);
} else {
videoView = new ContentVideoView(context, nativeContentVideoView, client);
}
if (videoView.getContentVideoViewClient().onShowCustomView(videoView)) { if (videoView.getContentVideoViewClient().onShowCustomView(videoView)) {
return videoView; return videoView;
} }
......
...@@ -70,10 +70,6 @@ public abstract class ContentSwitches { ...@@ -70,10 +70,6 @@ public abstract class ContentSwitches {
// Native switch - chrome_switches::kDisablePopupBlocking // Native switch - chrome_switches::kDisablePopupBlocking
public static final String DISABLE_POPUP_BLOCKING = "disable-popup-blocking"; 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 // Native switch - gfx_switches::kForceDeviceScaleFactor
public static final String FORCE_DEVICE_SCALE_FACTOR = public static final String FORCE_DEVICE_SCALE_FACTOR =
"force-device-scale-factor"; "force-device-scale-factor";
......
...@@ -380,10 +380,6 @@ const char kEnableOneCopy[] = "enable-one-copy"; ...@@ -380,10 +380,6 @@ const char kEnableOneCopy[] = "enable-one-copy";
// Enables use of hardware overlay for fullscreen video playback. Android only. // Enables use of hardware overlay for fullscreen video playback. Android only.
const char kEnableOverlayFullscreenVideo[] = "enable-overlay-fullscreen-video"; 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. // Forward overscroll event data from the renderer to the browser.
const char kEnableOverscrollNotifications[] = "enable-overscroll-notifications"; const char kEnableOverscrollNotifications[] = "enable-overscroll-notifications";
......
...@@ -116,7 +116,6 @@ extern const char kEnableMemoryBenchmarking[]; ...@@ -116,7 +116,6 @@ extern const char kEnableMemoryBenchmarking[];
CONTENT_EXPORT extern const char kEnableNetworkInformation[]; CONTENT_EXPORT extern const char kEnableNetworkInformation[];
CONTENT_EXPORT extern const char kEnableOneCopy[]; CONTENT_EXPORT extern const char kEnableOneCopy[];
CONTENT_EXPORT extern const char kEnableOverlayFullscreenVideo[]; CONTENT_EXPORT extern const char kEnableOverlayFullscreenVideo[];
CONTENT_EXPORT extern const char kDisableOverlayFullscreenVideoSubtitle[];
CONTENT_EXPORT extern const char kEnableOverscrollNotifications[]; CONTENT_EXPORT extern const char kEnableOverscrollNotifications[];
CONTENT_EXPORT extern const char kEnablePinch[]; CONTENT_EXPORT extern const char kEnablePinch[];
CONTENT_EXPORT extern const char kEnablePreciseMemoryInfo[]; CONTENT_EXPORT extern const char kEnablePreciseMemoryInfo[];
......
...@@ -12,7 +12,6 @@ import android.view.View; ...@@ -12,7 +12,6 @@ import android.view.View;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import org.chromium.base.CalledByNative; import org.chromium.base.CalledByNative;
import org.chromium.base.CommandLine;
import org.chromium.base.JNINamespace; import org.chromium.base.JNINamespace;
import org.chromium.base.ThreadUtils; import org.chromium.base.ThreadUtils;
import org.chromium.content.browser.ActivityContentVideoViewClient; import org.chromium.content.browser.ActivityContentVideoViewClient;
...@@ -20,7 +19,6 @@ import org.chromium.content.browser.ContentVideoViewClient; ...@@ -20,7 +19,6 @@ import org.chromium.content.browser.ContentVideoViewClient;
import org.chromium.content.browser.ContentViewClient; import org.chromium.content.browser.ContentViewClient;
import org.chromium.content.browser.ContentViewCore; import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.ContentViewRenderView; import org.chromium.content.browser.ContentViewRenderView;
import org.chromium.content.common.ContentSwitches;
import org.chromium.ui.base.WindowAndroid; import org.chromium.ui.base.WindowAndroid;
/** /**
...@@ -53,21 +51,15 @@ public class ShellManager extends FrameLayout { ...@@ -53,21 +51,15 @@ public class ShellManager extends FrameLayout {
@Override @Override
public boolean onShowCustomView(View view) { public boolean onShowCustomView(View view) {
boolean success = super.onShowCustomView(view); boolean success = super.onShowCustomView(view);
if (!CommandLine.getInstance().hasSwitch(
ContentSwitches.DISABLE_OVERLAY_FULLSCREEN_VIDEO_SUBTITLE)) {
setOverlayVideoMode(true); setOverlayVideoMode(true);
}
return success; return success;
} }
@Override @Override
public void onDestroyContentVideoView() { public void onDestroyContentVideoView() {
super.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