Commit 8ded9764 authored by mlamouri's avatar mlamouri Committed by Commit bot

Disable Screen Orientation API locking ability for WebView.

This CL is adding a content switch that is used by WebView to not create
a ScreenOrientationDelegate which will prevent locking to work on WebView
and will correctly return that locking isn't supported to Javascript.

BUG=466080

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

Cr-Commit-Position: refs/heads/master@{#322404}
parent 5f38cadc
......@@ -90,6 +90,9 @@ bool AwMainDelegate::BasicStartupComplete(int* exit_code) {
// This is needed for sharing textures across the different GL threads.
cl->AppendSwitch(switches::kEnableThreadedTextureMailboxes);
// WebView does not yet support screen orientation locking.
cl->AppendSwitch(switches::kDisableScreenOrientationLock);
// This is needed to be able to mmap the V8 snapshot and ICU data file
// directly from the WebView .apk.
// This needs to be here so that it gets to run before the code in
......
......@@ -557,7 +557,8 @@ void BrowserMainLoop::MainMessageLoopStart() {
SurfaceTextureManager::InitInstance(new BrowserSurfaceTextureManager);
}
{
if (!parsed_command_line_.HasSwitch(
switches::kDisableScreenOrientationLock)) {
TRACE_EVENT0("startup",
"BrowserMainLoop::Subsystem:ScreenOrientationProvider");
screen_orientation_delegate_.reset(
......
......@@ -243,4 +243,30 @@ IN_PROC_BROWSER_TEST_F(ScreenOrientationBrowserTest, CrashTest_UseAfterDetach) {
// here.
}
#if defined(OS_ANDROID)
class ScreenOrientationLockDisabledBrowserTest : public ContentBrowserTest {
public:
ScreenOrientationLockDisabledBrowserTest() {}
~ScreenOrientationLockDisabledBrowserTest() override {}
void SetUpCommandLine(base::CommandLine* command_line) override {
command_line->AppendSwitch(switches::kDisableScreenOrientationLock);
}
};
// Check that when --disable-screen-orientation-lock is passed to the command
// line, screen.orientation.lock() correctly reports to not be supported.
IN_PROC_BROWSER_TEST_F(ScreenOrientationLockDisabledBrowserTest, NotSupported) {
GURL test_url = GetTestUrl("screen_orientation",
"screen_orientation_lock_disabled.html");
TestNavigationObserver navigation_observer(shell()->web_contents(), 2);
shell()->LoadURL(test_url);
navigation_observer.Wait();
EXPECT_EQ("NotSupportedError",
shell()->web_contents()->GetLastCommittedURL().ref());
}
#endif // defined(OS_ANDROID)
} // namespace content
......@@ -916,6 +916,9 @@ const char kDisableOverscrollEdgeEffect[] = "disable-overscroll-edge-effect";
// Disable the pull-to-refresh effect when vertically overscrolling content.
const char kDisablePullToRefreshEffect[] = "disable-pull-to-refresh-effect";
// Disable the locking feature of the screen orientation API.
const char kDisableScreenOrientationLock[] = "disable-screen-orientation-lock";
// WebRTC is enabled by default on Android.
const char kDisableWebRTC[] = "disable-webrtc";
......
......@@ -259,6 +259,7 @@ CONTENT_EXPORT extern const char kDisableGestureRequirementForMediaPlayback[];
CONTENT_EXPORT extern const char kDisableClickDelay[];
CONTENT_EXPORT extern const char kDisableOverscrollEdgeEffect[];
CONTENT_EXPORT extern const char kDisablePullToRefreshEffect[];
CONTENT_EXPORT extern const char kDisableScreenOrientationLock[];
CONTENT_EXPORT extern const char kDisableWebRTC[];
CONTENT_EXPORT extern const char kHideScrollbars[];
extern const char kNetworkCountryIso[];
......
<!DOCTYPE HTML>
<html>
<head>
</head>
<script>
screen.orientation.lock('portrait-secondary').then(function() {
document.location.hash = '#success';
}, function(e) {
document.location.hash = '#' + e.name;
});
</script>
<body>
<div>Starting...</div>
</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