Changeset 161455 in webkit


Ignore:
Timestamp:
Jan 7, 2014 2:24:37 PM (10 years ago)
Author:
jer.noble@apple.com
Message:

HTML5 video tag Does Not Load in Apache htaccess/htpasswd Protected Directory
https://bugs.webkit.org/show_bug.cgi?id=40382

Reviewed by Eric Carlson.

Source/WebCore:

Test: http/tests/media/video-auth.html

Adopt a new AVFoundation API to handle authentication challenge generated while loading
media through an AVAsset. The authentication request comes through as a
NSURLAuthenticationChallenge, and is wrapped in a WebCore::AuthenticationChallenge
by MediaPlayerPrivateAVFoundationObjC, and is sent up to the HTMLMediaElement to handle.
The HTMLMediaElement creates a ResourceRequest, and passes the challenge up to the
ResourceLoadNotifier.

To allow the HTMLMediaElement to initiate handling an AuthenticationChallenge without
actually creating a ResourceLoader, allow ResourceLoaderDelegate to accept a unique
identifier and a DocumentLoader in lieu of a ResourceLoader.

  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::parseAttribute):

  • html/HTMLMediaElement.h:
  • loader/ResourceLoadNotifier.cpp:

(WebCore::ResourceLoadNotifier::didReceiveAuthenticationChallenge):
(WebCore::ResourceLoadNotifier::didCancelAuthenticationChallenge):

  • loader/ResourceLoadNotifier.h:
  • platform/graphics/MediaPlayer.cpp:

(WebCore::MediaPlayer::shouldWaitForResponseToAuthenticationChallenge):

  • platform/graphics/MediaPlayer.h:

(WebCore::MediaPlayerClient::mediaPlayerShouldWaitForResponseToAuthenticationChallenge):

  • platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
  • platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:

(WebCore::MediaPlayerPrivateAVFoundationObjC::shouldWaitForResponseToAuthenticationChallenge):
(-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForResponseToAuthenticationChallenge:]):

LayoutTests:

  • http/tests/media/resources/video-auth.php: Added.
  • http/tests/media/video-auth-expected.txt: Added.
  • http/tests/media/video-auth.html: Added.
  • platform/mac/TestExpectations:
Location:
trunk
Files:
3 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r161444 r161455  
     12014-01-06  Jer Noble  <jer.noble@apple.com>
     2
     3        HTML5 video tag Does Not Load in Apache htaccess/htpasswd Protected Directory
     4        https://bugs.webkit.org/show_bug.cgi?id=40382
     5
     6        Reviewed by Eric Carlson.
     7
     8        * http/tests/media/resources/video-auth.php: Added.
     9        * http/tests/media/video-auth-expected.txt: Added.
     10        * http/tests/media/video-auth.html: Added.
     11        * platform/mac/TestExpectations:
     12
    1132014-01-07  Brent Fulgham  <bfulgham@apple.com>
    214
  • trunk/LayoutTests/platform/mac/TestExpectations

    r161444 r161455  
    13141314webkit.org/b/126455 [ MountainLion ] webgl/1.0.2/conformance/rendering/gl-scissor-test.html [ Failure ]
    13151315webkit.org/b/126586 [ Mavericks Debug] webgl/1.0.2/conformance/rendering/gl-scissor-test.html [ Pass Failure ]
     1316
     1317# HTTP Auth in Media is not supported in Mavericks and Mountain Lion
     1318webkit.org/b/40382 http/tests/media/video-auth.html [ Skip ]
  • trunk/Source/WebCore/ChangeLog

    r161452 r161455  
     12014-01-06  Jer Noble  <jer.noble@apple.com>
     2
     3        HTML5 video tag Does Not Load in Apache htaccess/htpasswd Protected Directory
     4        https://bugs.webkit.org/show_bug.cgi?id=40382
     5
     6        Reviewed by Eric Carlson.
     7
     8        Test: http/tests/media/video-auth.html
     9
     10        Adopt a new AVFoundation API to handle authentication challenge generated while loading
     11        media through an AVAsset. The authentication request comes through as a
     12        NSURLAuthenticationChallenge, and is wrapped in a WebCore::AuthenticationChallenge
     13        by MediaPlayerPrivateAVFoundationObjC, and is sent up to the HTMLMediaElement to handle.
     14        The HTMLMediaElement creates a ResourceRequest, and passes the challenge up to the
     15        ResourceLoadNotifier.
     16
     17        To allow the HTMLMediaElement to initiate handling an AuthenticationChallenge without
     18        actually creating a ResourceLoader, allow ResourceLoaderDelegate to accept a unique
     19        identifier and a DocumentLoader in lieu of a ResourceLoader.
     20
     21        * html/HTMLMediaElement.cpp:
     22        (WebCore::HTMLMediaElement::parseAttribute):
     23        * html/HTMLMediaElement.h:
     24        * loader/ResourceLoadNotifier.cpp:
     25        (WebCore::ResourceLoadNotifier::didReceiveAuthenticationChallenge):
     26        (WebCore::ResourceLoadNotifier::didCancelAuthenticationChallenge):
     27        * loader/ResourceLoadNotifier.h:
     28        * platform/graphics/MediaPlayer.cpp:
     29        (WebCore::MediaPlayer::shouldWaitForResponseToAuthenticationChallenge):
     30        * platform/graphics/MediaPlayer.h:
     31        (WebCore::MediaPlayerClient::mediaPlayerShouldWaitForResponseToAuthenticationChallenge):
     32        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
     33        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
     34        (WebCore::MediaPlayerPrivateAVFoundationObjC::shouldWaitForResponseToAuthenticationChallenge):
     35        (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForResponseToAuthenticationChallenge:]):
     36
    1372014-01-07  Commit Queue  <commit-queue@webkit.org>
    238
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r161280 r161455  
    6363#include "PageActivityAssertionToken.h"
    6464#include "PageGroup.h"
     65#include "ProgressTracker.h"
    6566#include "RenderVideo.h"
    6667#include "RenderView.h"
     
    55785579}
    55795580
     5581bool HTMLMediaElement::mediaPlayerShouldWaitForResponseToAuthenticationChallenge(const AuthenticationChallenge& challenge)
     5582{
     5583    Frame* frame = document().frame();
     5584    if (!frame)
     5585        return false;
     5586
     5587    Page* page = frame->page();
     5588    if (!page)
     5589        return false;
     5590
     5591    ResourceRequest request(m_currentSrc);
     5592    ResourceLoadNotifier& notifier = frame->loader().notifier();
     5593    DocumentLoader* documentLoader = document().loader();
     5594    unsigned long identifier = page->progress().createUniqueIdentifier();
     5595
     5596    notifier.assignIdentifierToInitialRequest(identifier, documentLoader, request);
     5597    notifier.didReceiveAuthenticationChallenge(identifier, documentLoader, challenge);
     5598
     5599    return true;
     5600}
     5601
    55805602void HTMLMediaElement::removeBehaviorsRestrictionsAfterFirstUserGesture()
    55815603{
  • trunk/Source/WebCore/html/HTMLMediaElement.h

    r161181 r161455  
    585585#endif
    586586
     587    virtual bool mediaPlayerShouldWaitForResponseToAuthenticationChallenge(const AuthenticationChallenge&) OVERRIDE;
     588
    587589    void loadTimerFired(Timer<HTMLMediaElement>*);
    588590    void progressEventTimerFired(Timer<HTMLMediaElement>*);
  • trunk/Source/WebCore/loader/ResourceLoadNotifier.cpp

    r160841 r161455  
    5454void ResourceLoadNotifier::didReceiveAuthenticationChallenge(ResourceLoader* loader, const AuthenticationChallenge& currentWebChallenge)
    5555{
    56     m_frame.loader().client().dispatchDidReceiveAuthenticationChallenge(loader->documentLoader(), loader->identifier(), currentWebChallenge);
     56    didReceiveAuthenticationChallenge(loader->identifier(), loader->documentLoader(), currentWebChallenge);
     57}
     58
     59void ResourceLoadNotifier::didReceiveAuthenticationChallenge(unsigned long identifier, DocumentLoader* loader, const AuthenticationChallenge& currentWebChallenge)
     60{
     61    m_frame.loader().client().dispatchDidReceiveAuthenticationChallenge(loader, identifier, currentWebChallenge);
    5762}
    5863
    5964void ResourceLoadNotifier::didCancelAuthenticationChallenge(ResourceLoader* loader, const AuthenticationChallenge& currentWebChallenge)
    6065{
    61     m_frame.loader().client().dispatchDidCancelAuthenticationChallenge(loader->documentLoader(), loader->identifier(), currentWebChallenge);
     66    didCancelAuthenticationChallenge(loader->identifier(), loader->documentLoader(), currentWebChallenge);
     67}
     68
     69void ResourceLoadNotifier::didCancelAuthenticationChallenge(unsigned long identifier, DocumentLoader* loader, const AuthenticationChallenge& currentWebChallenge)
     70{
     71    m_frame.loader().client().dispatchDidCancelAuthenticationChallenge(loader, identifier, currentWebChallenge);
    6272}
    6373
  • trunk/Source/WebCore/loader/ResourceLoadNotifier.h

    r157007 r161455  
    5050
    5151    void didReceiveAuthenticationChallenge(ResourceLoader*, const AuthenticationChallenge&);
     52    void didReceiveAuthenticationChallenge(unsigned long identifier, DocumentLoader*, const AuthenticationChallenge&);
    5253    void didCancelAuthenticationChallenge(ResourceLoader*, const AuthenticationChallenge&);
     54    void didCancelAuthenticationChallenge(unsigned long identifier, DocumentLoader*, const AuthenticationChallenge&);
    5355
    5456    void willSendRequest(ResourceLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
  • trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp

    r160577 r161455  
    12721272#endif
    12731273
     1274bool MediaPlayer::shouldWaitForResponseToAuthenticationChallenge(const AuthenticationChallenge& challenge)
     1275{
     1276    if (!m_mediaPlayerClient)
     1277        return false;
     1278
     1279    return m_mediaPlayerClient->mediaPlayerShouldWaitForResponseToAuthenticationChallenge(challenge);
     1280}
     1281
    12741282void MediaPlayerFactorySupport::callRegisterMediaEngine(MediaEngineRegister registerMediaEngine)
    12751283{
  • trunk/Source/WebCore/platform/graphics/MediaPlayer.h

    r160336 r161455  
    6969
    7070class AudioSourceProvider;
     71class AuthenticationChallenge;
    7172class Document;
    7273#if ENABLE(MEDIA_SOURCE)
     
    253254    virtual void textTrackRepresentationBoundsChanged(const IntRect&) { }
    254255#endif
     256
     257    virtual bool mediaPlayerShouldWaitForResponseToAuthenticationChallenge(const AuthenticationChallenge&) { return false; }
    255258};
    256259
     
    521524    double totalFrameDelay();
    522525#endif
     526
     527    bool shouldWaitForResponseToAuthenticationChallenge(const AuthenticationChallenge&);
    523528
    524529private:
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h

    r159827 r161455  
    4343OBJC_CLASS AVURLAsset;
    4444OBJC_CLASS NSArray;
     45OBJC_CLASS NSURLAuthenticationChallenge;
    4546OBJC_CLASS WebCoreAVFMovieObserver;
    4647OBJC_CLASS WebCoreAVFPullDelegate;
     
    8182#if HAVE(AVFOUNDATION_LOADER_DELEGATE)
    8283    bool shouldWaitForLoadingOfResource(AVAssetResourceLoadingRequest*);
     84    bool shouldWaitForResponseToAuthenticationChallenge(NSURLAuthenticationChallenge*);
    8385    void didCancelLoadingRequest(AVAssetResourceLoadingRequest*);
    8486    void didStopLoadingRequest(AVAssetResourceLoadingRequest *);
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

    r159827 r161455  
    3030#import "MediaPlayerPrivateAVFoundationObjC.h"
    3131
     32#import "AVTrackPrivateAVFObjCImpl.h"
    3233#import "AudioTrackPrivateAVFObjC.h"
    33 #import "AVTrackPrivateAVFObjCImpl.h"
     34#import "AuthenticationChallenge.h"
    3435#import "BlockExceptions.h"
    3536#import "ExceptionCodePlaceholder.h"
     
    10181019}
    10191020
     1021bool MediaPlayerPrivateAVFoundationObjC::shouldWaitForResponseToAuthenticationChallenge(NSURLAuthenticationChallenge* nsChallenge)
     1022{
     1023    AuthenticationChallenge challenge(nsChallenge);
     1024
     1025    return player()->shouldWaitForResponseToAuthenticationChallenge(challenge);
     1026}
     1027
    10201028void MediaPlayerPrivateAVFoundationObjC::didCancelLoadingRequest(AVAssetResourceLoadingRequest* avRequest)
    10211029{
     
    20502058}
    20512059
     2060- (BOOL)resourceLoader:(AVAssetResourceLoader *)resourceLoader shouldWaitForResponseToAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
     2061{
     2062    UNUSED_PARAM(resourceLoader);
     2063    if (!m_callback)
     2064        return NO;
     2065
     2066    dispatch_async(dispatch_get_main_queue(), ^{
     2067        if (!m_callback) {
     2068            [[challenge sender] cancelAuthenticationChallenge:challenge];
     2069            return;
     2070        }
     2071
     2072        if (!m_callback->shouldWaitForResponseToAuthenticationChallenge(challenge))
     2073            [[challenge sender] cancelAuthenticationChallenge:challenge];
     2074    });
     2075
     2076    return YES;
     2077}
     2078
    20522079- (void)resourceLoader:(AVAssetResourceLoader *)resourceLoader didCancelLoadingRequest:(AVAssetResourceLoadingRequest *)loadingRequest
    20532080{
Note: See TracChangeset for help on using the changeset viewer.