Commit 10565066 authored by Gayane Petrosyan's avatar Gayane Petrosyan Committed by Commit Bot

Revert "Add autoplay parameter to navigations."

This reverts commit 1b36f1a7.

Reason for revert: causes weblayer_browsertests failure
Bug: 1132848

Original change's description:
> Add autoplay parameter to navigations.
>
> Bug: 1131881
> Change-Id: Ia152dc0a76d1f9ad6eff87f74fef2ad17b327b91
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2432755
> Reviewed-by: Scott Violet <sky@chromium.org>
> Commit-Queue: John Abd-El-Malek <jam@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#810932}

TBR=sky@chromium.org,jam@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 1131881
Change-Id: Id853eaab83af2bc6cf4392a12d3b104bf6652442
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2435718Reviewed-by: default avatarGayane Petrosyan <gayane@chromium.org>
Commit-Queue: Gayane Petrosyan <gayane@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811239}
parent 47481387
...@@ -36,18 +36,16 @@ public final class NavigationControllerImpl extends INavigationController.Stub { ...@@ -36,18 +36,16 @@ public final class NavigationControllerImpl extends INavigationController.Stub {
if (WebLayerFactoryImpl.getClientMajorVersion() < 83) { if (WebLayerFactoryImpl.getClientMajorVersion() < 83) {
assert params == null; assert params == null;
} }
navigate2(uri, params == null ? false : params.mShouldReplaceCurrentEntry, false, false, navigate2(uri, params == null ? false : params.mShouldReplaceCurrentEntry, false, false);
false);
} }
@Override @Override
public void navigate2(String uri, boolean shouldReplaceCurrentEntry, public void navigate2(String uri, boolean shouldReplaceCurrentEntry,
boolean disableIntentProcessing, boolean disableNetworkErrorAutoReload, boolean disableIntentProcessing, boolean disableNetworkErrorAutoReload)
boolean enableAutoPlay) throws RemoteException { throws RemoteException {
StrictModeWorkaround.apply(); StrictModeWorkaround.apply();
NavigationControllerImplJni.get().navigate(mNativeNavigationController, uri, NavigationControllerImplJni.get().navigate(mNativeNavigationController, uri,
shouldReplaceCurrentEntry, disableIntentProcessing, disableNetworkErrorAutoReload, shouldReplaceCurrentEntry, disableIntentProcessing, disableNetworkErrorAutoReload);
enableAutoPlay);
} }
@Override @Override
...@@ -185,7 +183,7 @@ public final class NavigationControllerImpl extends INavigationController.Stub { ...@@ -185,7 +183,7 @@ public final class NavigationControllerImpl extends INavigationController.Stub {
long getNavigationController(long tab); long getNavigationController(long tab);
void navigate(long nativeNavigationControllerImpl, String uri, void navigate(long nativeNavigationControllerImpl, String uri,
boolean shouldReplaceCurrentEntry, boolean disableIntentProcessing, boolean shouldReplaceCurrentEntry, boolean disableIntentProcessing,
boolean disableNetworkErrorAutoReload, boolean enableAutoPlay); boolean disableNetworkErrorAutoReload);
void goBack(long nativeNavigationControllerImpl); void goBack(long nativeNavigationControllerImpl);
void goForward(long nativeNavigationControllerImpl); void goForward(long nativeNavigationControllerImpl);
boolean canGoBack(long nativeNavigationControllerImpl); boolean canGoBack(long nativeNavigationControllerImpl);
......
...@@ -41,6 +41,5 @@ interface INavigationController { ...@@ -41,6 +41,5 @@ interface INavigationController {
void navigate2(in String uri, void navigate2(in String uri,
in boolean shouldReplaceEntry, in boolean shouldReplaceEntry,
in boolean disableIntentProcessing, in boolean disableIntentProcessing,
in boolean disableNetworkErrorAutoReload, in boolean disableNetworkErrorAutoReload) = 14;
in boolean enableAutoPlay) = 14;
} }
...@@ -9,21 +9,18 @@ ...@@ -9,21 +9,18 @@
#include "base/test/bind_test_util.h" #include "base/test/bind_test_util.h"
#include "components/variations/net/variations_http_headers.h" #include "components/variations/net/variations_http_headers.h"
#include "components/variations/variations_ids_provider.h" #include "components/variations/variations_ids_provider.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/url_loader_interceptor.h" #include "content/public/test/url_loader_interceptor.h"
#include "net/dns/mock_host_resolver.h" #include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/controllable_http_response.h" #include "net/test/embedded_test_server/controllable_http_response.h"
#include "net/test/embedded_test_server/embedded_test_server.h" #include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/embedded_test_server/http_response.h" #include "net/test/embedded_test_server/http_response.h"
#include "weblayer/browser/tab_impl.h"
#include "weblayer/public/browser.h" #include "weblayer/public/browser.h"
#include "weblayer/public/navigation.h" #include "weblayer/public/navigation.h"
#include "weblayer/public/navigation_controller.h" #include "weblayer/public/navigation_controller.h"
#include "weblayer/public/navigation_observer.h" #include "weblayer/public/navigation_observer.h"
#include "weblayer/public/tab.h"
#include "weblayer/shell/browser/shell.h" #include "weblayer/shell/browser/shell.h"
#include "weblayer/test/interstitial_utils.h" #include "weblayer/test/interstitial_utils.h"
#include "weblayer/test/test_navigation_observer.h"
#include "weblayer/test/weblayer_browser_test_utils.h" #include "weblayer/test/weblayer_browser_test_utils.h"
namespace weblayer { namespace weblayer {
...@@ -591,63 +588,6 @@ IN_PROC_BROWSER_TEST_F(NavigationBrowserTest, ...@@ -591,63 +588,6 @@ IN_PROC_BROWSER_TEST_F(NavigationBrowserTest,
EXPECT_EQ(custom_ua, new_ua); EXPECT_EQ(custom_ua, new_ua);
} }
IN_PROC_BROWSER_TEST_F(NavigationBrowserTest, AutoPlayDefault) {
ASSERT_TRUE(embedded_test_server()->Start());
GURL url(embedded_test_server()->GetURL("/autoplay.html"));
auto* tab = static_cast<TabImpl*>(shell()->tab());
NavigateAndWaitForCompletion(url, tab);
auto* web_contents = tab->web_contents();
bool playing = false;
// There's no notification to watch that would signal video wasn't autoplayed,
// so instead check once through javascript.
EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
web_contents,
"window.domAutomationController.send(!document.getElementById('vid')."
"paused)",
&playing));
ASSERT_FALSE(playing);
}
namespace {
class WaitForMediaPlaying : public content::WebContentsObserver {
public:
explicit WaitForMediaPlaying(content::WebContents* web_contents)
: WebContentsObserver(web_contents) {}
// WebContentsObserver override.
void MediaStartedPlaying(const MediaPlayerInfo& info,
const content::MediaPlayerId&) final {
run_loop_.Quit();
CHECK(info.has_audio);
CHECK(info.has_video);
}
void Wait() { run_loop_.Run(); }
private:
base::RunLoop run_loop_;
DISALLOW_COPY_AND_ASSIGN(WaitForMediaPlaying);
};
} // namespace
IN_PROC_BROWSER_TEST_F(NavigationBrowserTest, AutoPlayEnabled) {
ASSERT_TRUE(embedded_test_server()->Start());
GURL url(embedded_test_server()->GetURL("/autoplay.html"));
NavigationController::NavigateParams params;
params.enable_auto_play = true;
GetNavigationController()->Navigate(url, params);
auto* tab = static_cast<TabImpl*>(shell()->tab());
WaitForMediaPlaying wait_for_media(tab->web_contents());
wait_for_media.Wait();
}
class NavigationBrowserTest2 : public NavigationBrowserTest { class NavigationBrowserTest2 : public NavigationBrowserTest {
public: public:
void SetUp() override { void SetUp() override {
......
...@@ -153,8 +153,7 @@ void NavigationControllerImpl::Navigate( ...@@ -153,8 +153,7 @@ void NavigationControllerImpl::Navigate(
const JavaParamRef<jstring>& url, const JavaParamRef<jstring>& url,
jboolean should_replace_current_entry, jboolean should_replace_current_entry,
jboolean disable_intent_processing, jboolean disable_intent_processing,
jboolean disable_network_error_auto_reload, jboolean disable_network_error_auto_reload) {
jboolean enable_auto_play) {
auto params = std::make_unique<content::NavigationController::LoadURLParams>( auto params = std::make_unique<content::NavigationController::LoadURLParams>(
GURL(base::android::ConvertJavaStringToUTF8(env, url))); GURL(base::android::ConvertJavaStringToUTF8(env, url)));
params->should_replace_current_entry = should_replace_current_entry; params->should_replace_current_entry = should_replace_current_entry;
...@@ -167,8 +166,6 @@ void NavigationControllerImpl::Navigate( ...@@ -167,8 +166,6 @@ void NavigationControllerImpl::Navigate(
: ui::PAGE_TRANSITION_LINK; : ui::PAGE_TRANSITION_LINK;
if (disable_network_error_auto_reload) if (disable_network_error_auto_reload)
params->navigation_ui_data = std::make_unique<NavigationUIDataImpl>(true); params->navigation_ui_data = std::make_unique<NavigationUIDataImpl>(true);
if (enable_auto_play)
params->was_activated = content::mojom::WasActivatedOption::kYes;
DoNavigate(std::move(params)); DoNavigate(std::move(params));
} }
...@@ -241,9 +238,6 @@ void NavigationControllerImpl::Navigate( ...@@ -241,9 +238,6 @@ void NavigationControllerImpl::Navigate(
load_params->navigation_ui_data = load_params->navigation_ui_data =
std::make_unique<NavigationUIDataImpl>(true); std::make_unique<NavigationUIDataImpl>(true);
} }
if (params.enable_auto_play)
load_params->was_activated = content::mojom::WasActivatedOption::kYes;
DoNavigate(std::move(load_params)); DoNavigate(std::move(load_params));
} }
......
...@@ -53,8 +53,7 @@ class NavigationControllerImpl : public NavigationController, ...@@ -53,8 +53,7 @@ class NavigationControllerImpl : public NavigationController,
const base::android::JavaParamRef<jstring>& url, const base::android::JavaParamRef<jstring>& url,
jboolean should_replace_current_entry, jboolean should_replace_current_entry,
jboolean disable_intent_processing, jboolean disable_intent_processing,
jboolean disable_network_error_auto_reload, jboolean disable_network_error_auto_reload);
jboolean enable_auto_play);
void GoBack(JNIEnv* env) { GoBack(); } void GoBack(JNIEnv* env) { GoBack(); }
void GoForward(JNIEnv* env) { GoForward(); } void GoForward(JNIEnv* env) { GoForward(); }
bool CanGoBack(JNIEnv* env) { return CanGoBack(); } bool CanGoBack(JNIEnv* env) { return CanGoBack(); }
......
...@@ -16,7 +16,6 @@ public class NavigateParams { ...@@ -16,7 +16,6 @@ public class NavigateParams {
new org.chromium.weblayer_private.interfaces.NavigateParams(); new org.chromium.weblayer_private.interfaces.NavigateParams();
private boolean mIntentProcessingDisabled; private boolean mIntentProcessingDisabled;
private boolean mNetworkErrorAutoReloadDisabled; private boolean mNetworkErrorAutoReloadDisabled;
private boolean mAutoPlayEnabled;
/** /**
* A Builder class to help create NavigateParams. * A Builder class to help create NavigateParams.
...@@ -83,21 +82,6 @@ public class NavigateParams { ...@@ -83,21 +82,6 @@ public class NavigateParams {
mParams.mNetworkErrorAutoReloadDisabled = true; mParams.mNetworkErrorAutoReloadDisabled = true;
return this; return this;
} }
/**
* Enable auto-play for videos in this navigation. Auto-play is disabled by default.
*
* @since 86
*/
@NonNull
public Builder enableAutoPlay() {
if (WebLayer.shouldPerformVersionChecks()
&& WebLayer.getSupportedMajorVersionInternal() < 86) {
throw new UnsupportedOperationException();
}
mParams.mAutoPlayEnabled = true;
return this;
}
} }
org.chromium.weblayer_private.interfaces.NavigateParams toInterfaceParams() { org.chromium.weblayer_private.interfaces.NavigateParams toInterfaceParams() {
...@@ -142,19 +126,4 @@ public class NavigateParams { ...@@ -142,19 +126,4 @@ public class NavigateParams {
} }
return mNetworkErrorAutoReloadDisabled; return mNetworkErrorAutoReloadDisabled;
} }
/**
* Returns true if auto play for videos is enabled.
*
* @return Whether auto play for videos is enabled.
*
* @since 86
*/
public boolean isAutoPlayEnabled() {
if (WebLayer.shouldPerformVersionChecks()
&& WebLayer.getSupportedMajorVersionInternal() < 86) {
throw new UnsupportedOperationException();
}
return mAutoPlayEnabled;
}
} }
...@@ -63,8 +63,7 @@ public class NavigationController { ...@@ -63,8 +63,7 @@ public class NavigationController {
mNavigationController.navigate2(uri.toString(), mNavigationController.navigate2(uri.toString(),
params == null ? false : params.getShouldReplaceCurrentEntry(), params == null ? false : params.getShouldReplaceCurrentEntry(),
params == null ? false : params.isIntentProcessingDisabled(), params == null ? false : params.isIntentProcessingDisabled(),
params == null ? false : params.isNetworkErrorAutoReloadDisabled(), params == null ? false : params.isNetworkErrorAutoReloadDisabled());
params == null ? false : params.isAutoPlayEnabled());
} }
} catch (RemoteException e) { } catch (RemoteException e) {
throw new APICallException(e); throw new APICallException(e);
......
...@@ -20,7 +20,6 @@ class NavigationController { ...@@ -20,7 +20,6 @@ class NavigationController {
struct NavigateParams { struct NavigateParams {
bool should_replace_current_entry = false; bool should_replace_current_entry = false;
bool disable_network_error_auto_reload = false; bool disable_network_error_auto_reload = false;
bool enable_auto_play = false;
}; };
virtual ~NavigationController() = default; virtual ~NavigationController() = default;
......
<html>
<body>
<video id="vid" controls autoplay>
<source src="bear.mp4" type="video/mp4">
</video>
</body>
</html>
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