Commit 6524fa4d authored by liberato's avatar liberato Committed by Commit bot

Set autoplay gesture override experiment based on finch trial group.

This CL uses the finch trial group name to set WebKit settings for the android autoplay gesture override experiment.  Most of the code for the experiment itself is in https://codereview.chromium.org/1179223002/ .  The present CL will not build without it.

Summary of the experiment: Our goal is to decide if the requirement for a user gesture can be relaxed on android, to allow some media to autoplay without always requiring the user to interact with it manuall.  The finch experiment will let us try various combinations of heuristics for when to autoplay without a user gesture.  We record metrics based on user behavior, such as "manually started playback", "manually stopped playback", etc.

These options are composible, so we just use the trial group name to specify the options directly.  This lets us try different combinations after we get some initial data from the experiment.

BUG=487345, 402044

Review URL: https://codereview.chromium.org/1331203003

Cr-Commit-Position: refs/heads/master@{#348762}
parent adfd7f4b
......@@ -455,6 +455,11 @@ WebPreferences RenderViewHostImpl::ComputeWebkitPrefs() {
prefs.user_gesture_required_for_media_playback = !command_line.HasSwitch(
switches::kDisableGestureRequirementForMediaPlayback) &&
(autoplay_group_name.empty() || autoplay_group_name != "Enabled");
// Handle autoplay gesture override experiment.
// Note that anything but a well-formed string turns the experiment off.
prefs.autoplay_experiment_mode = base::FieldTrialList::FindFullName(
"MediaElementGestureOverrideExperiment");
#endif
prefs.touch_enabled = ui::AreTouchEventsEnabled();
......
......@@ -225,6 +225,7 @@ IPC_STRUCT_TRAITS_BEGIN(content::WebPreferences)
IPC_STRUCT_TRAITS_MEMBER(ignore_main_frame_overflow_hidden_quirk)
IPC_STRUCT_TRAITS_MEMBER(report_screen_size_in_physical_pixels_quirk)
IPC_STRUCT_TRAITS_MEMBER(record_whole_document)
IPC_STRUCT_TRAITS_MEMBER(autoplay_experiment_mode)
#endif
IPC_STRUCT_TRAITS_MEMBER(default_minimum_page_scale_factor)
IPC_STRUCT_TRAITS_MEMBER(default_maximum_page_scale_factor)
......
......@@ -61,7 +61,8 @@ CONTENT_EXPORT extern const char kCommonScript[];
//
// Adding new values to this class probably involves updating
// blink::WebSettings, content/common/view_messages.h, browser/tab_contents/
// render_view_host_delegate_helper.cc, and browser/profiles/profile.cc.
// render_view_host_delegate_helper.cc, browser/profiles/profile.cc,
// and content/public/common/common_param_traits_macros.h
struct CONTENT_EXPORT WebPreferences {
ScriptFontFamilyMap standard_font_family_map;
ScriptFontFamilyMap fixed_font_family_map;
......@@ -211,6 +212,7 @@ struct CONTENT_EXPORT WebPreferences {
bool ignore_main_frame_overflow_hidden_quirk;
bool report_screen_size_in_physical_pixels_quirk;
bool record_whole_document;
std::string autoplay_experiment_mode;
#endif
// Default (used if the page or UA doesn't override these) values for page
......
......@@ -1116,6 +1116,8 @@ void RenderView::ApplyWebPreferences(const WebPreferences& prefs,
settings->setMainFrameClipsContent(!prefs.record_whole_document);
settings->setShrinksViewportContentToFit(true);
settings->setUseMobileViewportStyle(true);
settings->setAutoplayExperimentMode(
blink::WebString::fromUTF8(prefs.autoplay_experiment_mode));
#endif
WebNetworkStateNotifier::setOnLine(prefs.is_online);
......
......@@ -65488,6 +65488,16 @@ To add a new entry, add it with any value and run test to compute valid value.
<int value="4"
label="Autoplay enabled through a user-gesture triggered load() call."/>
<int value="5" label="Autoplay disabled by sandbox flags."/>
<int value="6" label="Gesture requirement overridden during initial load."/>
<int value="7" label="Gesture requirement overridden in play()."/>
<int value="8"
label="Gesture req. overridden after scroll for deferred attribute."/>
<int value="9"
label="Gesture req. overridden after scroll for deferred play()."/>
<int value="10" label="play() call failed due to gesture requirement."/>
<int value="11" label="Any playback started."/>
<int value="12" label="Any playback paused."/>
<int value="13" label="Any playback bailed out."/>
</enum>
<enum name="MediaGalleriesUsageType" type="int">
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment