OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/android/voice_search_tab_helper.h" |
| 6 |
| 7 #include "content/public/browser/render_view_host.h" |
| 8 #include "content/public/browser/web_contents.h" |
| 9 #include "jni/VoiceSearchTabHelper_jni.h" |
| 10 #include "webkit/common/webpreferences.h" |
| 11 |
| 12 using content::WebContents; |
| 13 |
| 14 // Register native methods |
| 15 bool RegisterVoiceSearchTabHelper(JNIEnv* env) { |
| 16 return RegisterNativesImpl(env); |
| 17 } |
| 18 |
| 19 static jlong Init(JNIEnv* env, jobject obj, jobject j_web_contents) { |
| 20 WebContents* web_contents = WebContents::FromJavaWebContents(j_web_contents); |
| 21 VoiceSearchTabHelper* helper = new VoiceSearchTabHelper(web_contents); |
| 22 return reinterpret_cast<intptr_t>(helper); |
| 23 } |
| 24 |
| 25 VoiceSearchTabHelper::VoiceSearchTabHelper(WebContents* web_contents) |
| 26 : web_contents_(web_contents) { |
| 27 } |
| 28 |
| 29 void VoiceSearchTabHelper::SetMediaAutoplayEnabled(JNIEnv* env, |
| 30 jobject obj, |
| 31 jboolean is_enabled) { |
| 32 content::RenderViewHost* host = web_contents_->GetRenderViewHost(); |
| 33 WebPreferences prefs = host->GetWebkitPreferences(); |
| 34 prefs.user_gesture_required_for_media_playback = true; |
| 35 host->UpdateWebkitPreferences(prefs); |
| 36 } |
| 37 |
OLD | NEW |