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

Unified Diff: third_party/WebKit/Source/core/html/AutoplayExperimentHelper.cpp

Issue 1853543002: Add -ifsameorigin to autoplay experiment. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@autoplay
Patch Set: rebased. Created 4 years, 8 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: third_party/WebKit/Source/core/html/AutoplayExperimentHelper.cpp
diff --git a/third_party/WebKit/Source/core/html/AutoplayExperimentHelper.cpp b/third_party/WebKit/Source/core/html/AutoplayExperimentHelper.cpp
index bbfbbe36f2c0692d0d8d03247198e7fff8e36e28..836dcfd8bda86ad36c83d15020d5476f952acc9d 100644
--- a/third_party/WebKit/Source/core/html/AutoplayExperimentHelper.cpp
+++ b/third_party/WebKit/Source/core/html/AutoplayExperimentHelper.cpp
@@ -327,6 +327,14 @@ bool AutoplayExperimentHelper::isEligible() const
&& !client().isLegacyViewportType())
return false;
+ // If we require same-origin, then check the origin. If we additionally
+ // allow "or muted", then also allow autoplay in that case.
+ if (enabled(IfSameOrigin) && client().frame()
+ && client().frame()->isCrossOrigin()) {
+ if (!enabled(OrMuted) || !client().muted())
+ return false;
+ }
+
// If we require muted media and this is muted, then it is eligible.
if (enabled(IfMuted))
return client().muted();
@@ -394,6 +402,10 @@ AutoplayExperimentHelper::Mode AutoplayExperimentHelper::fromString(const String
value |= IfMuted;
if (mode.contains("-ifmobile"))
value |= IfMobile;
+ if (mode.contains("-ifsameorigin"))
+ value |= IfSameOrigin;
+ if (mode.contains("-ormuted"))
+ value |= OrMuted;
if (mode.contains("-playmuted"))
value |= PlayMuted;

Powered by Google App Engine
This is Rietveld 408576698