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

Unified Diff: content/browser/renderer_host/render_view_host_impl.cc

Issue 2846623003: Make autoplay policies no longer platform dependant. (Closed)
Patch Set: fix webview Created 3 years, 7 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
Index: content/browser/renderer_host/render_view_host_impl.cc
diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc
index 51c20a6a5edc7613df5df254e71128c4a70f7af2..1b33efa75a6fef7c1c79b703495c2988b1b322d2 100644
--- a/content/browser/renderer_host/render_view_host_impl.cc
+++ b/content/browser/renderer_host/render_view_host_impl.cc
@@ -437,23 +437,22 @@ WebPreferences RenderViewHostImpl::ComputeWebkitPrefs() {
command_line.HasSwitch(switches::kHistoryEntryRequiresUserGesture);
#if defined(OS_ANDROID)
- // On Android, user gestures are normally required, unless that requirement
- // is disabled with a command-line switch or the equivalent field trial is
- // is set to "Enabled".
- prefs.user_gesture_required_for_media_playback =
- !command_line.HasSwitch(switches::kIgnoreAutoplayRestrictionsForTests) &&
- command_line.GetSwitchValueASCII(switches::kAutoplayPolicy) !=
- switches::autoplay::kNoUserGestureRequiredPolicy;
-
prefs.progress_bar_completion = GetProgressBarCompletionPolicy();
prefs.use_solid_color_scrollbars = true;
-#else // defined(OS_ANDROID)
- prefs.cross_origin_media_playback_requires_user_gesture =
- command_line.GetSwitchValueASCII(switches::kAutoplayPolicy) ==
- switches::autoplay::kCrossOriginUserGestureRequiredPolicy;
#endif // defined(OS_ANDROID)
+ std::string autoplay_policy = media::GetEffectiveAutoplayPolicy(command_line);
+ if (autoplay_policy == switches::autoplay::kNoUserGestureRequiredPolicy) {
+ prefs.autoplay_policy = AutoplayPolicy::kNoUserGestureRequired;
+ } else if (autoplay_policy ==
+ switches::autoplay::kCrossOriginUserGestureRequiredPolicy) {
+ prefs.autoplay_policy = AutoplayPolicy::kCrossOriginUserGestureRequired;
+ } else if (autoplay_policy ==
+ switches::autoplay::kUserGestureRequiredPolicy) {
+ prefs.autoplay_policy = AutoplayPolicy::kUserGestureRequired;
+ }
+
const std::string touch_enabled_switch =
command_line.HasSwitch(switches::kTouchEventFeatureDetection)
? command_line.GetSwitchValueASCII(

Powered by Google App Engine
This is Rietveld 408576698