Bug 23870 - Allow ports to define restrictions on media loading
Summary: Allow ports to define restrictions on media loading
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-10 10:37 PST by Eric Carlson
Modified: 2009-02-17 14:38 PST (History)
0 users

See Also:


Attachments
proposed patch (5.71 KB, patch)
2009-02-10 10:45 PST, Eric Carlson
no flags Details | Formatted Diff | Diff
revised patch (6.10 KB, patch)
2009-02-10 10:54 PST, Eric Carlson
simon.fraser: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Carlson 2009-02-10 10:37:54 PST
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.
Comment 1 Eric Carlson 2009-02-10 10:45:00 PST
Created attachment 27523 [details]
proposed patch
Comment 2 Eric Carlson 2009-02-10 10:54:43 PST
Created attachment 27530 [details]
revised patch

added missing ChangeLog comments
Comment 3 Simon Fraser (smfr) 2009-02-10 11:07:08 PST
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
Comment 4 Eric Carlson 2009-02-17 14:38:49 PST
Committed revision 40828.