Changeset 18794 in webkit


Ignore:
Timestamp:
Jan 11, 2007 9:33:51 PM (17 years ago)
Author:
beidson
Message:

Reviewed by Oliver

-Move more HTTP Auth handling towards ResourceHandle, away from ResourceHandleClient
-Make more of ResourceLoader cross-platform

  • loader/ResourceLoader.cpp: (WebCore::ResourceLoader::ResourceLoader): (WebCore::ResourceLoader::releaseResources): (WebCore::ResourceLoader::didCancel): (WebCore::ResourceLoader::didReceiveAuthenticationChallenge): (WebCore::ResourceLoader::didCancelAuthenticationChallenge): (WebCore::ResourceLoader::receivedCancellation):
  • loader/ResourceLoader.h: (WebCore::ResourceLoader::willStopBufferingData): (WebCore::ResourceLoader::didCancelAuthenticationChallenge): (WebCore::ResourceLoader::willCacheResponse):
  • loader/mac/ResourceLoaderMac.mm:
  • platform/network/ResourceHandle.h:
  • platform/network/ResourceHandleClient.h: (WebCore::ResourceHandleClient::willStopBufferingData):
  • platform/network/ResourceHandleInternal.h: (WebCore::ResourceHandleInternal::ResourceHandleInternal):
  • platform/network/mac/ResourceHandleMac.mm: (WebCore::ResourceHandle::didReceiveAuthenticationChallenge): (WebCore::ResourceHandle::didCancelAuthenticationChallenge): (WebCore::ResourceHandle::receivedCredential): (WebCore::ResourceHandle::receivedRequestToContinueWithoutCredential): (WebCore::ResourceHandle::receivedCancellation): (WebCore::ResourceHandle::clearAuthentication): (-[WebCoreResourceHandleAsDelegate connection:didReceiveAuthenticationChallenge:]): (-[WebCoreResourceHandleAsDelegate connection:didCancelAuthenticationChallenge:]): (-[WebCoreResourceHandleAsDelegate useCredential:forAuthenticationChallenge:]): (-[WebCoreResourceHandleAsDelegate continueWithoutCredentialForAuthenticationChallenge:]): (-[WebCoreResourceHandleAsDelegate cancelAuthenticationChallenge:]):


Location:
trunk/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r18793 r18794  
     12007-01-11  Brady Eidson  <beidson@apple.com>
     2
     3        Reviewed by Oliver
     4
     5        -Move more HTTP Auth handling towards ResourceHandle, away from ResourceHandleClient
     6        -Make more of ResourceLoader cross-platform
     7
     8        * loader/ResourceLoader.cpp:
     9        (WebCore::ResourceLoader::ResourceLoader):
     10        (WebCore::ResourceLoader::releaseResources):
     11        (WebCore::ResourceLoader::didCancel):
     12        (WebCore::ResourceLoader::didReceiveAuthenticationChallenge):
     13        (WebCore::ResourceLoader::didCancelAuthenticationChallenge):
     14        (WebCore::ResourceLoader::receivedCancellation):
     15        * loader/ResourceLoader.h:
     16        (WebCore::ResourceLoader::willStopBufferingData):
     17        (WebCore::ResourceLoader::didCancelAuthenticationChallenge):
     18        (WebCore::ResourceLoader::willCacheResponse):
     19        * loader/mac/ResourceLoaderMac.mm:
     20        * platform/network/ResourceHandle.h:
     21        * platform/network/ResourceHandleClient.h:
     22        (WebCore::ResourceHandleClient::willStopBufferingData):
     23        * platform/network/ResourceHandleInternal.h:
     24        (WebCore::ResourceHandleInternal::ResourceHandleInternal):
     25        * platform/network/mac/ResourceHandleMac.mm:
     26        (WebCore::ResourceHandle::didReceiveAuthenticationChallenge):
     27        (WebCore::ResourceHandle::didCancelAuthenticationChallenge):
     28        (WebCore::ResourceHandle::receivedCredential):
     29        (WebCore::ResourceHandle::receivedRequestToContinueWithoutCredential):
     30        (WebCore::ResourceHandle::receivedCancellation):
     31        (WebCore::ResourceHandle::clearAuthentication):
     32        (-[WebCoreResourceHandleAsDelegate connection:didReceiveAuthenticationChallenge:]):
     33        (-[WebCoreResourceHandleAsDelegate connection:didCancelAuthenticationChallenge:]):
     34        (-[WebCoreResourceHandleAsDelegate useCredential:forAuthenticationChallenge:]):
     35        (-[WebCoreResourceHandleAsDelegate continueWithoutCredentialForAuthenticationChallenge:]):
     36        (-[WebCoreResourceHandleAsDelegate cancelAuthenticationChallenge:]):
     37
    1382007-01-11  David Hyatt  <hyatt@apple.com>
    239
  • trunk/WebCore/loader/ResourceLoader.cpp

    r18783 r18794  
    5555    , m_calledDidFinishLoad(false)
    5656    , m_frame(frame)
    57 #if PLATFORM(MAC)
    58     , m_currentMacChallenge(nil)
    59 #endif
    6057    , m_defersLoading(frame->page()->defersLoading())
    6158{
     
    8582
    8683#if PLATFORM(MAC)
    87     m_identifier = nil;
     84    setIdentifier(nil);
    8885#endif
    8986    m_handle = 0;
     
    255252    m_cancelled = true;
    256253   
    257 #if PLATFORM(MAC)
    258     m_currentMacChallenge = nil;
    259 #endif
    260     m_currentWebChallenge.nullify();
    261 
     254    if (m_handle)
     255        m_handle->clearAuthentication();
    262256
    263257    frameLoader()->cancelPendingArchiveLoad(this);
     
    321315}
    322316
    323 }
     317void ResourceLoader::didReceiveAuthenticationChallenge(const AuthenticationChallenge& challenge)
     318{
     319    // Protect this in this delegate method since the additional processing can do
     320    // anything including possibly derefing this; one example of this is Radar 3266216.
     321    RefPtr<ResourceLoader> protector(this);
     322    frameLoader()->didReceiveAuthenticationChallenge(this, challenge);
     323}
     324
     325void ResourceLoader::didCancelAuthenticationChallenge(const AuthenticationChallenge& challenge)
     326{
     327    // Protect this in this delegate method since the additional processing can do
     328    // anything including possibly derefing this; one example of this is Radar 3266216.
     329    RefPtr<ResourceLoader> protector(this);
     330    frameLoader()->didCancelAuthenticationChallenge(this, challenge);
     331}
     332
     333void ResourceLoader::receivedCancellation(const AuthenticationChallenge&)
     334{
     335    cancel();
     336}
     337
     338}
  • trunk/WebCore/loader/ResourceLoader.h

    r18783 r18794  
    8282
    8383#if PLATFORM(MAC)
    84         void setIdentifier(id);
     84        void setIdentifier(id i) { m_identifier = i; }
    8585        id identifier() const { return m_identifier.get(); }
    8686#else
     
    106106#endif
    107107
     108        void didReceiveAuthenticationChallenge(const AuthenticationChallenge&);
     109        void didCancelAuthenticationChallenge(const AuthenticationChallenge&);
     110        void receivedCancellation(const AuthenticationChallenge&);
     111
    108112        // ResourceHandleClient
    109113        virtual void willSendRequest(ResourceHandle*, ResourceRequest&, const ResourceResponse& redirectResponse);       
     
    113117        virtual void didFail(ResourceHandle*, const ResourceError&);
    114118        virtual void willStopBufferingData(ResourceHandle*, const char* data, int length) { willStopBufferingData(data, length); }
    115 
     119        virtual void didReceiveAuthenticationChallenge(ResourceHandle*, const AuthenticationChallenge& challenge) { didReceiveAuthenticationChallenge(challenge); }
     120        virtual void didCancelAuthenticationChallenge(ResourceHandle*, const AuthenticationChallenge& challenge) { didCancelAuthenticationChallenge(challenge); }
     121        virtual void receivedCancellation(ResourceHandle*, const AuthenticationChallenge& challenge) { receivedCancellation(challenge); }
     122       
    116123#if PLATFORM(MAC)
    117124        virtual NSCachedURLResponse *willCacheResponse(ResourceHandle*, NSCachedURLResponse *cachedResponse) { return willCacheResponse(cachedResponse); }
    118        
    119         void didReceiveAuthenticationChallenge(const AuthenticationChallenge& challenge);
    120         void didCancelAuthenticationChallenge(const AuthenticationChallenge& challenge);
    121         void receivedCredential(const AuthenticationChallenge&, const Credential&);
    122         void receivedRequestToContinueWithoutCredential(const AuthenticationChallenge&);
    123         void receivedCancellation(const AuthenticationChallenge&);
    124        
    125         virtual void didReceiveAuthenticationChallenge(ResourceHandle*, const AuthenticationChallenge& challenge) { didReceiveAuthenticationChallenge(challenge); }
    126         virtual void didCancelAuthenticationChallenge(ResourceHandle*, const AuthenticationChallenge& challenge) { didCancelAuthenticationChallenge(challenge); }
    127         virtual void receivedCredential(ResourceHandle*, const AuthenticationChallenge& challenge, const Credential& credential) { receivedCredential(challenge, credential); }
    128         virtual void receivedRequestToContinueWithoutCredential(ResourceHandle*, const AuthenticationChallenge& challenge) { receivedRequestToContinueWithoutCredential(challenge); }
    129         virtual void receivedCancellation(ResourceHandle*, const AuthenticationChallenge& challenge) { receivedCancellation(challenge); }
    130125#endif
    131126       
     
    159154#if PLATFORM(MAC)
    160155        RetainPtr<id> m_identifier;
    161         NSURLAuthenticationChallenge *m_currentMacChallenge;
    162156#endif
    163         AuthenticationChallenge m_currentWebChallenge;
    164157
    165158        KURL m_originalURL;
  • trunk/WebCore/loader/mac/ResourceLoaderMac.mm

    r18783 r18794  
    5555namespace WebCore {
    5656
    57 void ResourceLoader::didReceiveAuthenticationChallenge(const AuthenticationChallenge& challenge)
    58 {
    59     ASSERT(!m_reachedTerminalState);
    60     ASSERT(!m_currentMacChallenge);
    61     ASSERT(m_currentWebChallenge.isNull());
    62     // Since NSURLConnection networking relies on keeping a reference to the original NSURLAuthenticationChallenge,
    63     // we make sure that is actually present
    64     ASSERT(challenge.nsURLAuthenticationChallenge());
    65    
    66     // Protect this in this delegate method since the additional processing can do
    67     // anything including possibly derefing this; one example of this is Radar 3266216.
    68     RefPtr<ResourceLoader> protector(this);
    69 
    70     m_currentMacChallenge = challenge.nsURLAuthenticationChallenge();
    71     NSURLAuthenticationChallenge *webChallenge = [[NSURLAuthenticationChallenge alloc] initWithAuthenticationChallenge:m_currentMacChallenge
    72                                                                                        sender:(id<NSURLAuthenticationChallengeSender>)m_handle->delegate()];
    73     m_currentWebChallenge = core(webChallenge);
    74     [webChallenge release];
    75 
    76     frameLoader()->didReceiveAuthenticationChallenge(this, m_currentWebChallenge);
    77 }
    78 
    79 void ResourceLoader::didCancelAuthenticationChallenge(const AuthenticationChallenge& challenge)
    80 {
    81     ASSERT(!m_reachedTerminalState);
    82     ASSERT(m_currentMacChallenge);
    83     ASSERT(!m_currentWebChallenge.isNull());
    84     ASSERT(m_currentWebChallenge == challenge);
    85 
    86     // Protect this in this delegate method since the additional processing can do
    87     // anything including possibly derefing this; one example of this is Radar 3266216.
    88     RefPtr<ResourceLoader> protector(this);
    89 
    90     frameLoader()->didCancelAuthenticationChallenge(this, m_currentWebChallenge);
    91 }
    92 
    9357NSCachedURLResponse *ResourceLoader::willCacheResponse(NSCachedURLResponse *cachedResponse)
    9458{
     
    10266}
    10367
    104 void ResourceLoader::setIdentifier(id identifier)
    105 {
    106     m_identifier = identifier;
    10768}
    10869
    109 
    110 void ResourceLoader::receivedCredential(const AuthenticationChallenge& challenge, const Credential& credential)
    111 {
    112     ASSERT(!challenge.isNull());
    113     if (challenge != m_currentWebChallenge)
    114         return;
    115 
    116     [[m_currentMacChallenge sender] useCredential:mac(credential) forAuthenticationChallenge:m_currentMacChallenge];
    117 
    118     m_currentMacChallenge = nil;
    119     m_currentWebChallenge.nullify();
    120 }
    121 
    122 void ResourceLoader::receivedRequestToContinueWithoutCredential(const AuthenticationChallenge& challenge)
    123 {
    124     ASSERT(!challenge.isNull());
    125     if (challenge != m_currentWebChallenge)
    126         return;
    127 
    128     [[m_currentMacChallenge sender] continueWithoutCredentialForAuthenticationChallenge:m_currentMacChallenge];
    129 
    130     m_currentMacChallenge = nil;
    131     m_currentWebChallenge.nullify();
    132 }
    133 
    134 void ResourceLoader::receivedCancellation(const AuthenticationChallenge& challenge)
    135 {
    136     if (challenge != m_currentWebChallenge)
    137         return;
    138 
    139     cancel();
    140 }
    141 
    142 }
    143 
  • trunk/WebCore/platform/network/ResourceHandle.cpp

    r18783 r18794  
    7777}
    7878
     79void ResourceHandle::clearAuthentication()
     80{
     81#if PLATFORM(MAC)
     82    d->m_currentMacChallenge = nil;
     83#endif
     84    d->m_currentWebChallenge.nullify();
     85}
     86
    7987} // namespace WebCore
    8088
  • trunk/WebCore/platform/network/ResourceHandle.h

    r18625 r18794  
    2727#define ResourceHandle_h
    2828
     29#include "AuthenticationChallenge.h"
     30#include "HTTPHeaderMap.h"
    2931#include <wtf/OwnPtr.h>
    3032
    31 #include "HTTPHeaderMap.h"
    3233
    3334#if PLATFORM(WIN)
     
    4344#endif
    4445
     46
    4547#if PLATFORM(MAC)
     48#include "RetainPtr.h"
    4649#ifdef __OBJC__
    4750@class NSData;
     
    6063namespace WebCore {
    6164
     65class AuthenticationChallenge;
     66class Credential;
    6267class FormData;
    6368class Frame;
     
    8893
    8994#if PLATFORM(MAC)
     95    void didReceiveAuthenticationChallenge(const AuthenticationChallenge&);
     96    void didCancelAuthenticationChallenge(const AuthenticationChallenge&);
     97    void receivedCredential(const AuthenticationChallenge&, const Credential&);
     98    void receivedRequestToContinueWithoutCredential(const AuthenticationChallenge&);
     99    void receivedCancellation(const AuthenticationChallenge&);
     100       
    90101    NSURLConnection *connection() const;
    91102    WebCoreResourceHandleAsDelegate *delegate();
     
    117128    static bool loadsBlocked();   
    118129   
     130    void clearAuthentication();
    119131    void cancel();
    120132   
     
    130142private:
    131143    bool start(Frame*);
    132 
     144       
    133145    OwnPtr<ResourceHandleInternal> d;
    134146};
  • trunk/WebCore/platform/network/ResourceHandleClient.h

    r18783 r18794  
    8484        // cached response may be modified
    8585        // void willCacheResponse(ResourceHandle*, CachedResourceResponse&) { }
    86 #if PLATFORM(MAC)
     86
    8787        virtual void didReceiveAuthenticationChallenge(ResourceHandle*, const AuthenticationChallenge&) { }
    8888        virtual void didCancelAuthenticationChallenge(ResourceHandle*, const AuthenticationChallenge&) { }
     
    9090        virtual void receivedRequestToContinueWithoutCredential(ResourceHandle*, const AuthenticationChallenge&) { }
    9191        virtual void receivedCancellation(ResourceHandle*, const AuthenticationChallenge&) { }
    92        
     92
     93#if PLATFORM(MAC)       
    9394        virtual void willStopBufferingData(ResourceHandle*, const char*, int) { }
    94        
    9595        virtual NSCachedURLResponse *willCacheResponse(ResourceHandle*, NSCachedURLResponse *cachedResponse) { return cachedResponse; }
    9696#endif
  • trunk/WebCore/platform/network/ResourceHandleInternal.h

    r18184 r18794  
    9090            , m_handle(0)
    9191#endif
     92#if PLATFORM(MAC)
     93            , m_currentMacChallenge(nil)
     94#endif
    9295        {
    9396        }
     
    128131        CURL* m_handle;
    129132#endif
     133#if PLATFORM(MAC)
     134        NSURLAuthenticationChallenge *m_currentMacChallenge;
     135#endif
     136        AuthenticationChallenge m_currentWebChallenge;
    130137    };
    131138
  • trunk/WebCore/platform/network/mac/ResourceHandleMac.mm

    r18783 r18794  
    230230}
    231231
     232void ResourceHandle::didReceiveAuthenticationChallenge(const AuthenticationChallenge& challenge)
     233{
     234    ASSERT(!d->m_currentMacChallenge);
     235    ASSERT(d->m_currentWebChallenge.isNull());
     236    // Since NSURLConnection networking relies on keeping a reference to the original NSURLAuthenticationChallenge,
     237    // we make sure that is actually present
     238    ASSERT(challenge.nsURLAuthenticationChallenge());
     239       
     240    d->m_currentMacChallenge = challenge.nsURLAuthenticationChallenge();
     241    NSURLAuthenticationChallenge *webChallenge = [[NSURLAuthenticationChallenge alloc] initWithAuthenticationChallenge:d->m_currentMacChallenge
     242                                                                                       sender:(id<NSURLAuthenticationChallengeSender>)delegate()];
     243    d->m_currentWebChallenge = core(webChallenge);
     244    [webChallenge release];
     245   
     246    client()->didReceiveAuthenticationChallenge(this, d->m_currentWebChallenge);
     247}
     248
     249void ResourceHandle::didCancelAuthenticationChallenge(const AuthenticationChallenge& challenge)
     250{
     251    ASSERT(d->m_currentMacChallenge);
     252    ASSERT(!d->m_currentWebChallenge.isNull());
     253    ASSERT(d->m_currentWebChallenge == challenge);
     254
     255    client()->didCancelAuthenticationChallenge(this, d->m_currentWebChallenge);
     256}
     257
     258void ResourceHandle::receivedCredential(const AuthenticationChallenge& challenge, const Credential& credential)
     259{
     260    ASSERT(!challenge.isNull());
     261    if (challenge != d->m_currentWebChallenge)
     262        return;
     263
     264    [[d->m_currentMacChallenge sender] useCredential:mac(credential) forAuthenticationChallenge:d->m_currentMacChallenge];
     265
     266    clearAuthentication();
     267}
     268
     269void ResourceHandle::receivedRequestToContinueWithoutCredential(const AuthenticationChallenge& challenge)
     270{
     271    ASSERT(!challenge.isNull());
     272    if (challenge != d->m_currentWebChallenge)
     273        return;
     274
     275    [[d->m_currentMacChallenge sender] continueWithoutCredentialForAuthenticationChallenge:d->m_currentMacChallenge];
     276
     277    clearAuthentication();
     278}
     279
     280void ResourceHandle::receivedCancellation(const AuthenticationChallenge& challenge)
     281{
     282    if (challenge != d->m_currentWebChallenge)
     283        return;
     284
     285    client()->receivedCancellation(this, challenge);
     286}
     287
    232288} // namespace WebCore
    233289
     
    264320        return;
    265321    ++inNSURLConnectionCallback;
    266     m_handle->client()->didReceiveAuthenticationChallenge(m_handle, core(challenge));
     322    m_handle->didReceiveAuthenticationChallenge(core(challenge));
    267323    --inNSURLConnectionCallback;
    268324}
     
    273329        return;
    274330    ++inNSURLConnectionCallback;
    275     m_handle->client()->didCancelAuthenticationChallenge(m_handle, core(challenge));
     331    m_handle->didCancelAuthenticationChallenge(core(challenge));
    276332    --inNSURLConnectionCallback;
    277333}
     
    340396    if (!m_handle)
    341397        return;
    342     m_handle->client()->receivedCredential(m_handle, core(challenge), core(credential));
     398    m_handle->receivedCredential(core(challenge), core(credential));
    343399}
    344400
     
    347403    if (!m_handle)
    348404        return;
    349     m_handle->client()->receivedRequestToContinueWithoutCredential(m_handle, core(challenge));
     405    m_handle->receivedRequestToContinueWithoutCredential(core(challenge));
    350406}
    351407
     
    354410    if (!m_handle)
    355411        return;
    356     m_handle->client()->receivedCancellation(m_handle, core(challenge));
     412    m_handle->receivedCancellation(core(challenge));
    357413}
    358414
Note: See TracChangeset for help on using the changeset viewer.