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

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: nits Created 4 years 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 1556c0b15dc600190e536d80b264b7d83d341aa9..f8d3bfc94308a85f3f12c0e604d1c97baa06ad1d 100644
--- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
@@ -288,6 +288,25 @@ String preloadTypeToString(WebMediaPlayer::Preload preloadType) {
return String();
}
+bool isDocumentCrossOrigin(Document& document) {
+ const LocalFrame* frame = document.frame();
+ return frame && frame->isCrossOriginSubframe();
+}
+
+// Return true if and only if the document settings specifies media playback
+// requires user gesture.
+bool computeLockedPendingUserGesture(Document& document) {
+ if (!document.settings())
+ return false;
+
+ if (document.settings()->crossOriginMediaPlaybackRequiresUserGesture() &&
+ isDocumentCrossOrigin(document)) {
+ return true;
+ }
+
+ return document.settings()->mediaPlaybackRequiresUserGesture();
+}
+
} // anonymous namespace
MIMETypeRegistry::SupportsType HTMLMediaElement::supportsType(
@@ -402,12 +421,7 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName,
BLINK_MEDIA_LOG << "HTMLMediaElement(" << (void*)this << ")";
- // If any experiment is enabled, then we want to enable a user gesture by
- // default, otherwise the experiment does nothing.
- if ((document.settings() &&
- document.settings()->mediaPlaybackRequiresUserGesture())) {
- m_lockedPendingUserGesture = true;
- }
+ m_lockedPendingUserGesture = computeLockedPendingUserGesture(document);
LocalFrame* frame = document.frame();
if (frame) {
@@ -451,11 +465,9 @@ void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument) {
// If any experiment is enabled, then we want to enable a user gesture by
// default, otherwise the experiment does nothing.
bool oldDocumentRequiresUserGesture =
- (oldDocument.settings() &&
- oldDocument.settings()->mediaPlaybackRequiresUserGesture());
+ computeLockedPendingUserGesture(oldDocument);
bool newDocumentRequiresUserGesture =
- (document().settings() &&
- document().settings()->mediaPlaybackRequiresUserGesture());
+ computeLockedPendingUserGesture(document());
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