Commit 2289b43c authored by abarth@chromium.org's avatar abarth@chromium.org

Revert of Enable HTMLMediaElement@autoplay on Android (https://codereview.chromium.org/447353002/)

Reason for revert:
I misunderstood the outcome of the discussion surrounding this topic. We need to keep this code in order to not break google.com while gathering data about this feature.

Original issue's description:
> Enable HTMLMediaElement@autoplay on Android
> 
> This CL sets user_gesture_required_for_media_playback to false in Chrome for
> Android. Previously, we removed this requirement as a special case for the
> Google Search Results page. Now that this setting matches Chrome's behavior on
> other platforms, we don't need the special case for google.com and can remove
> the entire VoiceSearchTabHelper.
> 
> This CL leaves the user_gesture_required_for_media_playback WebPreference
> because that's used by android_webview.
> 
> R=klobag@chromium.org, darin@chromium.org
> BUG=178297
> 
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=288308

TBR=darin@chromium.org,klobag@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=178297

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

Cr-Commit-Position: refs/heads/master@{#288389}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288389 0039d316-1c4b-4281-b951-d872f2087c98
parent 92f7800e
......@@ -121,6 +121,7 @@ public class Tab implements NavigationClient {
// Content layer Observers and Delegates
private ContentViewClient mContentViewClient;
private WebContentsObserverAndroid mWebContentsObserver;
private VoiceSearchTabHelper mVoiceSearchTabHelper;
private TabChromeWebContentsDelegateAndroid mWebContentsDelegate;
private DomDistillerFeedbackReporter mDomDistillerFeedbackReporter;
......@@ -794,6 +795,7 @@ public class Tab implements NavigationClient {
mWebContentsDelegate = createWebContentsDelegate();
mWebContentsObserver = new TabWebContentsObserverAndroid(mContentViewCore.getWebContents());
mVoiceSearchTabHelper = new VoiceSearchTabHelper(mContentViewCore.getWebContents());
if (mContentViewClient != null) mContentViewCore.setContentViewClient(mContentViewClient);
......@@ -960,6 +962,7 @@ public class Tab implements NavigationClient {
mContentViewCore = null;
mWebContentsDelegate = null;
mWebContentsObserver = null;
mVoiceSearchTabHelper = null;
assert mNativeTabAndroid != 0;
nativeDestroyWebContents(mNativeTabAndroid, deleteNativeWebContents);
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser;
import org.chromium.content.browser.WebContentsObserverAndroid;
import org.chromium.content_public.browser.WebContents;
/**
* Tab helper to toggle media autoplay for voice URL searches.
*/
public class VoiceSearchTabHelper extends WebContentsObserverAndroid {
private final WebContents mWebContents;
/**
* Create an instance of VoiceSearchTabHelper.
*
* @param webContents WebContents to update media autoplay status.
*/
public VoiceSearchTabHelper(WebContents webContents) {
super(webContents);
mWebContents = webContents;
}
@Override
public void navigationEntryCommitted() {
nativeUpdateAutoplayStatus(mWebContents);
}
private native void nativeUpdateAutoplayStatus(WebContents webContents);
}
......@@ -1295,6 +1295,15 @@ const Experiment kExperiments[] = {
kOsAll,
MULTI_VALUE_TYPE(kDefaultTileHeightChoices)
},
#if defined(OS_ANDROID)
{
"disable-gesture-requirement-for-media-playback",
IDS_FLAGS_DISABLE_GESTURE_REQUIREMENT_FOR_MEDIA_PLAYBACK_NAME,
IDS_FLAGS_DISABLE_GESTURE_REQUIREMENT_FOR_MEDIA_PLAYBACK_DESCRIPTION,
kOsAndroid,
SINGLE_VALUE_TYPE(switches::kDisableGestureRequirementForMediaPlayback)
},
#endif
#if defined(OS_CHROMEOS)
{
"enable-virtual-keyboard",
......
......@@ -36,6 +36,7 @@
#include "chrome/browser/android/uma_bridge.h"
#include "chrome/browser/android/uma_utils.h"
#include "chrome/browser/android/url_utilities.h"
#include "chrome/browser/android/voice_search_tab_helper.h"
#include "chrome/browser/autofill/android/personal_data_manager_android.h"
#include "chrome/browser/dom_distiller/dom_distiller_service_factory_android.h"
#include "chrome/browser/dom_distiller/tab_utils_android.h"
......@@ -177,6 +178,7 @@ static base::android::RegistrationMethod kChromeRegisteredMethods[] = {
{ "UmaBridge", RegisterUmaBridge },
{ "UrlUtilities", RegisterUrlUtilities },
{ "Variations", variations::android::RegisterVariations },
{ "VoiceSearchTabHelper", RegisterVoiceSearchTabHelper },
{ "WebsiteSettingsPopupAndroid",
WebsiteSettingsPopupAndroid::RegisterWebsiteSettingsPopupAndroid },
#if defined(ENABLE_PRINTING) && !defined(ENABLE_FULL_PRINTING)
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/android/voice_search_tab_helper.h"
#include "components/google/core/browser/google_util.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/web_preferences.h"
#include "jni/VoiceSearchTabHelper_jni.h"
using content::WebContents;
// Register native methods
bool RegisterVoiceSearchTabHelper(JNIEnv* env) {
return RegisterNativesImpl(env);
}
static void UpdateAutoplayStatus(JNIEnv* env,
jobject obj,
jobject j_web_contents) {
WebContents* web_contents = WebContents::FromJavaWebContents(j_web_contents);
content::RenderViewHost* host = web_contents->GetRenderViewHost();
content::WebPreferences prefs = host->GetWebkitPreferences();
// In the case where media autoplay has been enabled by default (e.g. in
// performance media tests) do not update it based on navigation changes.
//
// Note that GetWekitPreferences() is 'stateless'. It returns the default
// webkit preferences configuration from command line switches.
if (!prefs.user_gesture_required_for_media_playback)
return;
prefs.user_gesture_required_for_media_playback =
!google_util::IsGoogleSearchUrl(web_contents->GetLastCommittedURL());
host->UpdateWebkitPreferences(prefs);
}
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_ANDROID_VOICE_SEARCH_TAB_HELPER_H_
#define CHROME_BROWSER_ANDROID_VOICE_SEARCH_TAB_HELPER_H_
#include "base/android/jni_android.h"
bool RegisterVoiceSearchTabHelper(JNIEnv* env);
#endif // CHROME_BROWSER_ANDROID_VOICE_SEARCH_TAB_HELPER_H_
......@@ -234,6 +234,13 @@ class EncryptedMediaTestBase : public MediaBrowserTest {
title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeKeyError));
}
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
#if defined(OS_ANDROID)
command_line->AppendSwitch(
switches::kDisableGestureRequirementForMediaPlayback);
#endif // defined(OS_ANDROID)
}
void SetUpCommandLineForKeySystem(const std::string& key_system,
CommandLine* command_line) {
if (GetServerConfig(key_system))
......
......@@ -109,6 +109,8 @@
'browser/android/uma_utils.h',
'browser/android/url_utilities.cc',
'browser/android/url_utilities.h',
'browser/android/voice_search_tab_helper.cc',
'browser/android/voice_search_tab_helper.h',
'browser/android/webapps/single_tab_mode_tab_helper.cc',
'browser/android/webapps/single_tab_mode_tab_helper.h',
'browser/app_controller_mac.h',
......@@ -2811,6 +2813,7 @@
'android/java/src/org/chromium/chrome/browser/UmaBridge.java',
'android/java/src/org/chromium/chrome/browser/UmaUtils.java',
'android/java/src/org/chromium/chrome/browser/UrlUtilities.java',
'android/java/src/org/chromium/chrome/browser/VoiceSearchTabHelper.java',
'android/java/src/org/chromium/chrome/browser/WebsiteSettingsPopup.java',
'android/java/src/org/chromium/chrome/browser/infobar/AutoLoginDelegate.java',
'android/java/src/org/chromium/chrome/browser/infobar/ConfirmInfoBarDelegate.java',
......
......@@ -125,6 +125,13 @@ class EncryptedMediaTest : public content::MediaBrowserTest,
title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeNotSupportedError));
title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEmeKeyError));
}
#if defined(OS_ANDROID)
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
command_line->AppendSwitch(
switches::kDisableGestureRequirementForMediaPlayback);
}
#endif
};
using ::testing::Combine;
......
......@@ -46,6 +46,13 @@ class MediaSourceTest : public content::MediaBrowserTest {
RunMediaTestPage("media_source_player.html", query_params, expectation,
true);
}
#if defined(OS_ANDROID)
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
command_line->AppendSwitch(
switches::kDisableGestureRequirementForMediaPlayback);
}
#endif
};
IN_PROC_BROWSER_TEST_F(MediaSourceTest, Playback_VideoAudio_WebM) {
......
......@@ -1238,6 +1238,7 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(
#endif
switches::kLowEndDeviceMode,
#if defined(OS_ANDROID)
switches::kDisableGestureRequirementForMediaPlayback,
switches::kDisableWebRTC,
switches::kEnableSpeechRecognition,
switches::kMediaDrmEnableNonCompositing,
......
......@@ -416,6 +416,11 @@ WebPreferences RenderViewHostImpl::GetWebkitPrefs(const GURL& url) {
}
prefs.use_solid_color_scrollbars = ui::IsOverlayScrollbarEnabled();
#if defined(OS_ANDROID)
prefs.user_gesture_required_for_media_playback = !command_line.HasSwitch(
switches::kDisableGestureRequirementForMediaPlayback);
#endif
prefs.touch_enabled = ui::AreTouchEventsEnabled();
prefs.device_supports_touch = prefs.touch_enabled &&
ui::IsTouchDevicePresent();
......
......@@ -880,6 +880,10 @@ const char kEnableWebRtcHWVp8Encoding[] = "enable-webrtc-hw-vp8-encoding";
#endif
#if defined(OS_ANDROID)
// Disable user gesture requirement for media playback.
const char kDisableGestureRequirementForMediaPlayback[] =
"disable-gesture-requirement-for-media-playback";
// Disable the click delay by sending click events during double tap.
const char kDisableClickDelay[] = "disable-click-delay";
......
......@@ -248,6 +248,7 @@ CONTENT_EXPORT extern const char kEnableWebRtcHWVp8Encoding[];
#endif
#if defined(OS_ANDROID)
CONTENT_EXPORT extern const char kDisableGestureRequirementForMediaPlayback[];
CONTENT_EXPORT extern const char kDisableClickDelay[];
CONTENT_EXPORT extern const char kDisableOverscrollEdgeEffect[];
CONTENT_EXPORT extern const char kDisableWebRTC[];
......
......@@ -138,7 +138,7 @@ WebPreferences::WebPreferences()
force_enable_zoom(false),
disallow_fullscreen_for_non_media_elements(false),
double_tap_to_zoom_enabled(true),
user_gesture_required_for_media_playback(false),
user_gesture_required_for_media_playback(true),
support_deprecated_target_density_dpi(false),
use_legacy_background_size_shorthand_behavior(false),
wide_viewport_quirk(false),
......
......@@ -146,6 +146,10 @@ bool ShellMainDelegate::BasicStartupComplete(int* exit_code) {
command_line.AppendSwitchASCII(switches::kTouchEvents,
switches::kTouchEventsEnabled);
command_line.AppendSwitchASCII(switches::kForceDeviceScaleFactor, "1.0");
#if defined(OS_ANDROID)
command_line.AppendSwitch(
switches::kDisableGestureRequirementForMediaPlayback);
#endif
if (!command_line.HasSwitch(switches::kStableReleaseMode)) {
command_line.AppendSwitch(
......
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