summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorabarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-08 17:52:11 +0000
committerabarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-08 17:52:11 +0000
commit2bb10ef8fb422424e66cfab0857d25c0b8fc8f9a (patch)
treee74783bacce24e4e653cae7f7dd2848bb6719130
parent110eab9f26c174befebe246e1eee6b0550d99f83 (diff)
downloadchromium_src-2bb10ef8fb422424e66cfab0857d25c0b8fc8f9a.zip
chromium_src-2bb10ef8fb422424e66cfab0857d25c0b8fc8f9a.tar.gz
chromium_src-2bb10ef8fb422424e66cfab0857d25c0b8fc8f9a.tar.bz2
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 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288389 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/android/java/src/org/chromium/chrome/browser/Tab.java3
-rw-r--r--chrome/android/java/src/org/chromium/chrome/browser/VoiceSearchTabHelper.java32
-rw-r--r--chrome/browser/about_flags.cc9
-rw-r--r--chrome/browser/android/chrome_jni_registrar.cc2
-rw-r--r--chrome/browser/android/voice_search_tab_helper.cc38
-rw-r--r--chrome/browser/android/voice_search_tab_helper.h12
-rw-r--r--chrome/browser/media/encrypted_media_browsertest.cc7
-rw-r--r--chrome/chrome_browser.gypi3
-rw-r--r--content/browser/media/encrypted_media_browsertest.cc7
-rw-r--r--content/browser/media/media_source_browsertest.cc7
-rw-r--r--content/browser/renderer_host/render_process_host_impl.cc1
-rw-r--r--content/browser/renderer_host/render_view_host_impl.cc5
-rw-r--r--content/public/common/content_switches.cc4
-rw-r--r--content/public/common/content_switches.h1
-rw-r--r--content/public/common/web_preferences.cc2
-rw-r--r--content/shell/app/shell_main_delegate.cc4
16 files changed, 136 insertions, 1 deletions
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/Tab.java b/chrome/android/java/src/org/chromium/chrome/browser/Tab.java
index 50f8b6c..cca0ac6 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/Tab.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/Tab.java
@@ -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);
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/VoiceSearchTabHelper.java b/chrome/android/java/src/org/chromium/chrome/browser/VoiceSearchTabHelper.java
new file mode 100644
index 0000000..1a74d5c
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/VoiceSearchTabHelper.java
@@ -0,0 +1,32 @@
+// 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);
+}
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index 35966a6..cdb2a67 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -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",
diff --git a/chrome/browser/android/chrome_jni_registrar.cc b/chrome/browser/android/chrome_jni_registrar.cc
index 2848b6f..e338acb 100644
--- a/chrome/browser/android/chrome_jni_registrar.cc
+++ b/chrome/browser/android/chrome_jni_registrar.cc
@@ -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)
diff --git a/chrome/browser/android/voice_search_tab_helper.cc b/chrome/browser/android/voice_search_tab_helper.cc
new file mode 100644
index 0000000..c8f10db
--- /dev/null
+++ b/chrome/browser/android/voice_search_tab_helper.cc
@@ -0,0 +1,38 @@
+// 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);
+}
diff --git a/chrome/browser/android/voice_search_tab_helper.h b/chrome/browser/android/voice_search_tab_helper.h
new file mode 100644
index 0000000..3cf34f0
--- /dev/null
+++ b/chrome/browser/android/voice_search_tab_helper.h
@@ -0,0 +1,12 @@
+// 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_
diff --git a/chrome/browser/media/encrypted_media_browsertest.cc b/chrome/browser/media/encrypted_media_browsertest.cc
index d21e87a..65a7280 100644
--- a/chrome/browser/media/encrypted_media_browsertest.cc
+++ b/chrome/browser/media/encrypted_media_browsertest.cc
@@ -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))
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index ba1ffd5..69dd5a9 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -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',
diff --git a/content/browser/media/encrypted_media_browsertest.cc b/content/browser/media/encrypted_media_browsertest.cc
index d9a2573..9f5e137 100644
--- a/content/browser/media/encrypted_media_browsertest.cc
+++ b/content/browser/media/encrypted_media_browsertest.cc
@@ -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;
diff --git a/content/browser/media/media_source_browsertest.cc b/content/browser/media/media_source_browsertest.cc
index 7cbfb64..90d0c84 100644
--- a/content/browser/media/media_source_browsertest.cc
+++ b/content/browser/media/media_source_browsertest.cc
@@ -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) {
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index 0348827..611d602 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -1238,6 +1238,7 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(
#endif
switches::kLowEndDeviceMode,
#if defined(OS_ANDROID)
+ switches::kDisableGestureRequirementForMediaPlayback,
switches::kDisableWebRTC,
switches::kEnableSpeechRecognition,
switches::kMediaDrmEnableNonCompositing,
diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc
index 506c367..b03d28f 100644
--- a/content/browser/renderer_host/render_view_host_impl.cc
+++ b/content/browser/renderer_host/render_view_host_impl.cc
@@ -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();
diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc
index ee3f81d..1bc2a24 100644
--- a/content/public/common/content_switches.cc
+++ b/content/public/common/content_switches.cc
@@ -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";
diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h
index 4ff0c28..47b5fdc 100644
--- a/content/public/common/content_switches.h
+++ b/content/public/common/content_switches.h
@@ -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[];
diff --git a/content/public/common/web_preferences.cc b/content/public/common/web_preferences.cc
index d956eb7..6a1858e 100644
--- a/content/public/common/web_preferences.cc
+++ b/content/public/common/web_preferences.cc
@@ -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),
diff --git a/content/shell/app/shell_main_delegate.cc b/content/shell/app/shell_main_delegate.cc
index d34dc04..1af3303 100644
--- a/content/shell/app/shell_main_delegate.cc
+++ b/content/shell/app/shell_main_delegate.cc
@@ -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(