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

Unified Diff: third_party/WebKit/Source/modules/webaudio/AudioContext.cpp

Issue 2314903002: Web Audio: when media playback requires a user gesture, apply rule to cross origin iframes. (Closed)
Patch Set: move click simulation to top frame Created 4 years, 3 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/modules/webaudio/AudioContext.cpp
diff --git a/third_party/WebKit/Source/modules/webaudio/AudioContext.cpp b/third_party/WebKit/Source/modules/webaudio/AudioContext.cpp
index c6e3e6d1d37c95d9468c636de5e88982c2451ce0..a21c371ca099e48e1cbc99ddf0f91741830c78eb 100644
--- a/third_party/WebKit/Source/modules/webaudio/AudioContext.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/AudioContext.cpp
@@ -64,7 +64,9 @@ AudioContext* AudioContext::create(Document& document, ExceptionState& exception
// quantum". NOTE: for now AudioContext does not need an explicit
// startRendering() call from JavaScript. We may want to consider
// requiring it for symmetry with OfflineAudioContext.
- audioContext->startRendering();
+ audioContext->maybeUnlockUserGesture();
+ if (audioContext->isAllowedToStart())
+ audioContext->startRendering();
++s_hardwareContextCount;
#if DEBUG_AUDIONODE_REFERENCES
fprintf(stderr, "[%16p]: AudioContext::AudioContext(): %u #%u\n",
@@ -136,14 +138,15 @@ ScriptPromise AudioContext::resumeContext(ScriptState* scriptState)
"cannot resume a closed AudioContext"));
}
- recordUserGestureState();
-
ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
ScriptPromise promise = resolver->promise();
// Restart the destination node to pull on the audio graph.
- if (destination())
- startRendering();
+ if (destination()) {
+ maybeUnlockUserGesture();
+ if (isAllowedToStart())
+ startRendering();
+ }
// Save the resolver which will get resolved when the destination node starts pulling on the
// graph again.

Powered by Google App Engine
This is Rietveld 408576698