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

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

Issue 444843002: Cache the current WebPreferences on RenderViewHostImpl (try #2). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix. Created 6 years, 4 months 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
« no previous file with comments | « android_webview/native/aw_settings.cc ('k') | chrome/browser/prefs/chrome_pref_service_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
index c8f10db3662fae873a0708f60ee2a395dd6b40b3..0782f7578ece106454e03072177956f114b5073f 100644
--- a/chrome/browser/android/voice_search_tab_helper.cc
+++ b/chrome/browser/android/voice_search_tab_helper.cc
@@ -4,9 +4,11 @@
#include "chrome/browser/android/voice_search_tab_helper.h"
+#include "base/command_line.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/content_switches.h"
#include "content/public/common/web_preferences.h"
#include "jni/VoiceSearchTabHelper_jni.h"
@@ -20,19 +22,25 @@ bool RegisterVoiceSearchTabHelper(JNIEnv* env) {
static void UpdateAutoplayStatus(JNIEnv* env,
jobject obj,
jobject j_web_contents) {
+ // In the case where media autoplay has been disabled by default (e.g. in
+ // performance media tests) do not update it based on navigation changes.
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ if (command_line.HasSwitch(
+ switches::kDisableGestureRequirementForMediaPlayback))
+ return;
+
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 =
+ bool gesture_required =
!google_util::IsGoogleSearchUrl(web_contents->GetLastCommittedURL());
- host->UpdateWebkitPreferences(prefs);
+
+ if (gesture_required != prefs.user_gesture_required_for_media_playback) {
+ // TODO(chrishtr): this is wrong. user_gesture_required_for_media_playback
+ // will be reset the next time a preference changes.
+ prefs.user_gesture_required_for_media_playback =
+ !google_util::IsGoogleSearchUrl(web_contents->GetLastCommittedURL());
+ host->UpdateWebkitPreferences(prefs);
+ }
}
« no previous file with comments | « android_webview/native/aw_settings.cc ('k') | chrome/browser/prefs/chrome_pref_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698