Changeset 18794 in webkit
- Timestamp:
- Jan 11, 2007 9:33:51 PM (17 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r18793 r18794 1 2007-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 1 38 2007-01-11 David Hyatt <hyatt@apple.com> 2 39 -
trunk/WebCore/loader/ResourceLoader.cpp
r18783 r18794 55 55 , m_calledDidFinishLoad(false) 56 56 , m_frame(frame) 57 #if PLATFORM(MAC)58 , m_currentMacChallenge(nil)59 #endif60 57 , m_defersLoading(frame->page()->defersLoading()) 61 58 { … … 85 82 86 83 #if PLATFORM(MAC) 87 m_identifier = nil;84 setIdentifier(nil); 88 85 #endif 89 86 m_handle = 0; … … 255 252 m_cancelled = true; 256 253 257 #if PLATFORM(MAC) 258 m_currentMacChallenge = nil; 259 #endif 260 m_currentWebChallenge.nullify(); 261 254 if (m_handle) 255 m_handle->clearAuthentication(); 262 256 263 257 frameLoader()->cancelPendingArchiveLoad(this); … … 321 315 } 322 316 323 } 317 void 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 325 void 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 333 void ResourceLoader::receivedCancellation(const AuthenticationChallenge&) 334 { 335 cancel(); 336 } 337 338 } -
trunk/WebCore/loader/ResourceLoader.h
r18783 r18794 82 82 83 83 #if PLATFORM(MAC) 84 void setIdentifier(id );84 void setIdentifier(id i) { m_identifier = i; } 85 85 id identifier() const { return m_identifier.get(); } 86 86 #else … … 106 106 #endif 107 107 108 void didReceiveAuthenticationChallenge(const AuthenticationChallenge&); 109 void didCancelAuthenticationChallenge(const AuthenticationChallenge&); 110 void receivedCancellation(const AuthenticationChallenge&); 111 108 112 // ResourceHandleClient 109 113 virtual void willSendRequest(ResourceHandle*, ResourceRequest&, const ResourceResponse& redirectResponse); … … 113 117 virtual void didFail(ResourceHandle*, const ResourceError&); 114 118 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 116 123 #if PLATFORM(MAC) 117 124 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); }130 125 #endif 131 126 … … 159 154 #if PLATFORM(MAC) 160 155 RetainPtr<id> m_identifier; 161 NSURLAuthenticationChallenge *m_currentMacChallenge;162 156 #endif 163 AuthenticationChallenge m_currentWebChallenge;164 157 165 158 KURL m_originalURL; -
trunk/WebCore/loader/mac/ResourceLoaderMac.mm
r18783 r18794 55 55 namespace WebCore { 56 56 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 present64 ASSERT(challenge.nsURLAuthenticationChallenge());65 66 // Protect this in this delegate method since the additional processing can do67 // 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_currentMacChallenge72 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 do87 // 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 93 57 NSCachedURLResponse *ResourceLoader::willCacheResponse(NSCachedURLResponse *cachedResponse) 94 58 { … … 102 66 } 103 67 104 void ResourceLoader::setIdentifier(id identifier)105 {106 m_identifier = identifier;107 68 } 108 69 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 77 77 } 78 78 79 void ResourceHandle::clearAuthentication() 80 { 81 #if PLATFORM(MAC) 82 d->m_currentMacChallenge = nil; 83 #endif 84 d->m_currentWebChallenge.nullify(); 85 } 86 79 87 } // namespace WebCore 80 88 -
trunk/WebCore/platform/network/ResourceHandle.h
r18625 r18794 27 27 #define ResourceHandle_h 28 28 29 #include "AuthenticationChallenge.h" 30 #include "HTTPHeaderMap.h" 29 31 #include <wtf/OwnPtr.h> 30 32 31 #include "HTTPHeaderMap.h"32 33 33 34 #if PLATFORM(WIN) … … 43 44 #endif 44 45 46 45 47 #if PLATFORM(MAC) 48 #include "RetainPtr.h" 46 49 #ifdef __OBJC__ 47 50 @class NSData; … … 60 63 namespace WebCore { 61 64 65 class AuthenticationChallenge; 66 class Credential; 62 67 class FormData; 63 68 class Frame; … … 88 93 89 94 #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 90 101 NSURLConnection *connection() const; 91 102 WebCoreResourceHandleAsDelegate *delegate(); … … 117 128 static bool loadsBlocked(); 118 129 130 void clearAuthentication(); 119 131 void cancel(); 120 132 … … 130 142 private: 131 143 bool start(Frame*); 132 144 133 145 OwnPtr<ResourceHandleInternal> d; 134 146 }; -
trunk/WebCore/platform/network/ResourceHandleClient.h
r18783 r18794 84 84 // cached response may be modified 85 85 // void willCacheResponse(ResourceHandle*, CachedResourceResponse&) { } 86 #if PLATFORM(MAC) 86 87 87 virtual void didReceiveAuthenticationChallenge(ResourceHandle*, const AuthenticationChallenge&) { } 88 88 virtual void didCancelAuthenticationChallenge(ResourceHandle*, const AuthenticationChallenge&) { } … … 90 90 virtual void receivedRequestToContinueWithoutCredential(ResourceHandle*, const AuthenticationChallenge&) { } 91 91 virtual void receivedCancellation(ResourceHandle*, const AuthenticationChallenge&) { } 92 92 93 #if PLATFORM(MAC) 93 94 virtual void willStopBufferingData(ResourceHandle*, const char*, int) { } 94 95 95 virtual NSCachedURLResponse *willCacheResponse(ResourceHandle*, NSCachedURLResponse *cachedResponse) { return cachedResponse; } 96 96 #endif -
trunk/WebCore/platform/network/ResourceHandleInternal.h
r18184 r18794 90 90 , m_handle(0) 91 91 #endif 92 #if PLATFORM(MAC) 93 , m_currentMacChallenge(nil) 94 #endif 92 95 { 93 96 } … … 128 131 CURL* m_handle; 129 132 #endif 133 #if PLATFORM(MAC) 134 NSURLAuthenticationChallenge *m_currentMacChallenge; 135 #endif 136 AuthenticationChallenge m_currentWebChallenge; 130 137 }; 131 138 -
trunk/WebCore/platform/network/mac/ResourceHandleMac.mm
r18783 r18794 230 230 } 231 231 232 void 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 249 void 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 258 void 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 269 void 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 280 void ResourceHandle::receivedCancellation(const AuthenticationChallenge& challenge) 281 { 282 if (challenge != d->m_currentWebChallenge) 283 return; 284 285 client()->receivedCancellation(this, challenge); 286 } 287 232 288 } // namespace WebCore 233 289 … … 264 320 return; 265 321 ++inNSURLConnectionCallback; 266 m_handle-> client()->didReceiveAuthenticationChallenge(m_handle,core(challenge));322 m_handle->didReceiveAuthenticationChallenge(core(challenge)); 267 323 --inNSURLConnectionCallback; 268 324 } … … 273 329 return; 274 330 ++inNSURLConnectionCallback; 275 m_handle-> client()->didCancelAuthenticationChallenge(m_handle,core(challenge));331 m_handle->didCancelAuthenticationChallenge(core(challenge)); 276 332 --inNSURLConnectionCallback; 277 333 } … … 340 396 if (!m_handle) 341 397 return; 342 m_handle-> client()->receivedCredential(m_handle,core(challenge), core(credential));398 m_handle->receivedCredential(core(challenge), core(credential)); 343 399 } 344 400 … … 347 403 if (!m_handle) 348 404 return; 349 m_handle-> client()->receivedRequestToContinueWithoutCredential(m_handle,core(challenge));405 m_handle->receivedRequestToContinueWithoutCredential(core(challenge)); 350 406 } 351 407 … … 354 410 if (!m_handle) 355 411 return; 356 m_handle-> client()->receivedCancellation(m_handle,core(challenge));412 m_handle->receivedCancellation(core(challenge)); 357 413 } 358 414
Note: See TracChangeset
for help on using the changeset viewer.