A port should be able to prevent automatic opening of media files by <video> and <audio> elements by returning an error from load() unless it is invoked as a result of a user gesture.
Created attachment 27523 [details] proposed patch
Created attachment 27530 [details] revised patch added missing ChangeLog comments
Comment on attachment 27530 [details] revised patch > Index: WebCore/ChangeLog > =================================================================== > + https://bugs.webkit.org/post_bug.cgi Please fix the link. > + make it possible for a port to require a user gesture for an <audio> or <video> element > + to load a file To load a url? Sentence case. > Index: WebCore/html/HTMLMediaElement.cpp > =================================================================== > - if (m_currentLoop < playCount() - 1 && currentTime() >= effectiveLoopEnd()) { > + float now = currentTime(); I'm worried about name conflicts with wtf/CurrentTime at some point, but that's not your problem. > +bool HTMLMediaElement::processingUserGesture() > +{ > + Frame* frame = document()->frame(); > + FrameLoader *loader = frame ? frame->loader() : NULL; For C++, use FrameLoader* loader Use 0 not NULL. > + return loader ? loader->userGestureHint() : false; Should this return 'true' in the failure case for safety? > Index: WebCore/html/HTMLMediaElement.h > =================================================================== > --- WebCore/html/HTMLMediaElement.h (revision 40823) > +++ WebCore/html/HTMLMediaElement.h (working copy) > @@ -159,6 +159,8 @@ private: > void seek(float time, ExceptionCode& ec); > void checkIfSeekNeeded(); > > + bool processingUserGesture(); Make this |const|? > + enum LoadingRestrictions Rename to LoadRestrictions > + { > + NO_RESTRICTIONS = 0, > + REQUIRE_USER_GESTURE = 1 << 0, > + }; Maybe rename to NoLoadRestriction, RequireUserGestureLoadRestriction r=me with those fixes
Committed revision 40828.