Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3155)

Unified Diff: chrome/browser/android/voice_search_tab_helper.cc

Issue 114183006: Changes to enable HTML5 autoplay for voice search. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/voice_search_tab_helper.cc
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 0000000000000000000000000000000000000000..e640fda8dfc2ddad4176b1e4c559e5de3104b476
--- /dev/null
+++ b/chrome/browser/android/voice_search_tab_helper.cc
@@ -0,0 +1,39 @@
+// Copyright 2013 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 "chrome/browser/google/google_util.h"
+#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/web_contents.h"
+#include "jni/VoiceSearchTabHelper_jni.h"
+#include "webkit/common/webpreferences.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();
David Trainor- moved to gerrit 2013/12/30 18:14:30 IIRC they're refactoring RenderViewHost to RenderF
apiccion 2013/12/31 18:52:46 The PSA is here: https://groups.google.com/a/chrom
apiccion 2014/01/02 17:59:09 They say it will probably move into WebContents si
+ WebPreferences prefs = host->GetWebkitPreferences();
+
+ // Handle the case where media autoplay has been enabled from the command
+ // line. Or some other override is otherwise in place. This currently fixes
+ // performance tests (see tools/perf/benchmarks/media.py line 33).
+ //
+ // Note that GetWekitPreferences() is 'stateless'. It returns the default
+ // webkit preferences configuration from command line switches.
+ if (prefs.user_gesture_required_for_media_playback == false)
+ return;
+
+ prefs.user_gesture_required_for_media_playback =
+ !google_util::IsGoogleSearchUrl(web_contents->GetLastCommittedURL());
+ host->UpdateWebkitPreferences(prefs);
+}

Powered by Google App Engine
This is Rietveld 408576698