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

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

Issue 86443002: Changes to enable HTML5 autoplay for voice search. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Isolated media autoplay enabler from Tab 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..e930128cfe28c5cb2e5d529912f03c394a176dc9
--- /dev/null
+++ b/chrome/browser/android/voice_search_tab_helper.cc
@@ -0,0 +1,37 @@
+// 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 "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 jlong Init(JNIEnv* env, jobject obj, jobject j_web_contents) {
+ WebContents* web_contents = WebContents::FromJavaWebContents(j_web_contents);
+ VoiceSearchTabHelper* helper = new VoiceSearchTabHelper(web_contents);
+ return reinterpret_cast<intptr_t>(helper);
+}
+
+VoiceSearchTabHelper::VoiceSearchTabHelper(WebContents* web_contents)
+ : web_contents_(web_contents) {
+}
+
+void VoiceSearchTabHelper::SetMediaAutoplayEnabled(JNIEnv* env,
+ jobject obj,
+ jboolean is_enabled) {
+ content::RenderViewHost* host = web_contents_->GetRenderViewHost();
+ WebPreferences prefs = host->GetWebkitPreferences();
+ prefs.user_gesture_required_for_media_playback = true;
+ host->UpdateWebkitPreferences(prefs);
+}
+

Powered by Google App Engine
This is Rietveld 408576698