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

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

Issue 2496593002: Adding an experimental flag to block autoplay with sound in cross-origin iframes (Closed)
Patch Set: Created 4 years, 1 month 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 | « third_party/WebKit/Source/core/frame/Settings.in ('k') | third_party/WebKit/Source/web/WebSettingsImpl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
index 1d90b0d8fedb9d495cd032a65a8c456d2a276532..7045eea94250d6ad31a307c6dc8f2ce020df35ef 100644
--- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
@@ -282,6 +282,11 @@ String preloadTypeToString(WebMediaPlayer::Preload preloadType) {
return String();
}
+bool isCrossOrigin(Document& document) {
+ const LocalFrame* frame = document.frame();
+ return frame && frame->isCrossOriginSubframe();
+}
+
} // anonymous namespace
class HTMLMediaElement::AutoplayHelperClientImpl
@@ -471,6 +476,9 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName,
// default, otherwise the experiment does nothing.
if ((document.settings() &&
document.settings()->mediaPlaybackRequiresUserGesture()) ||
+ (document.settings() && isCrossOrigin(document) &&
whywhat 2016/11/16 17:37:17 is it this that you don't like? you could've had a
Zhiqiang Zhang (Slow) 2016/11/16 18:11:40 Already merged them into a helper function in my l
+ document.settings()
+ ->mediaPlaybackInCrossOriginIframesRequiresUserGesture()) ||
m_autoplayHelper->isExperimentEnabled()) {
m_lockedPendingUserGesture = true;
}
@@ -519,10 +527,17 @@ void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument) {
bool oldDocumentRequiresUserGesture =
(oldDocument.settings() &&
oldDocument.settings()->mediaPlaybackRequiresUserGesture()) ||
+ (oldDocument.settings() && isCrossOrigin(oldDocument) &&
+ oldDocument.settings()
+ ->mediaPlaybackInCrossOriginIframesRequiresUserGesture()) ||
m_autoplayHelper->isExperimentEnabled();
bool newDocumentRequiresUserGesture =
(document().settings() &&
document().settings()->mediaPlaybackRequiresUserGesture()) ||
+ (document().settings() && isCrossOrigin(oldDocument) &&
+ document()
+ .settings()
+ ->mediaPlaybackInCrossOriginIframesRequiresUserGesture()) ||
m_autoplayHelper->isExperimentEnabled();
if (newDocumentRequiresUserGesture && !oldDocumentRequiresUserGesture) {
m_lockedPendingUserGesture = true;
« no previous file with comments | « third_party/WebKit/Source/core/frame/Settings.in ('k') | third_party/WebKit/Source/web/WebSettingsImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698