Commit 048a4af6 authored by ap@webkit.org's avatar ap@webkit.org

Rubber-stamped by Darin Adler.

        Don't keep platform objects for authentication challenge in ResourceHandleInternal.
        We already have a copy in AuthenticationChallenge object.

        * platform/network/ResourceHandle.cpp:
        (WebCore::ResourceHandle::clearAuthentication):
        * platform/network/ResourceHandleInternal.h:
        (WebCore::ResourceHandleInternal::ResourceHandleInternal):
        * platform/network/cf/ResourceHandleCFNet.cpp:
        (WebCore::ResourceHandle::didReceiveAuthenticationChallenge):
        (WebCore::ResourceHandle::receivedCredential):
        (WebCore::ResourceHandle::receivedRequestToContinueWithoutCredential):
        (WebCore::ResourceHandle::receivedCancellation):
        * platform/network/mac/ResourceHandleMac.mm:
        (WebCore::ResourceHandle::didReceiveAuthenticationChallenge):
        (WebCore::ResourceHandle::didCancelAuthenticationChallenge):
        (WebCore::ResourceHandle::receivedCredential):
        (WebCore::ResourceHandle::receivedRequestToContinueWithoutCredential):
        (WebCore::ResourceHandle::receivedCancellation):



git-svn-id: svn://svn.chromium.org/blink/trunk@42536 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent c4b0c277
2009-04-14 Alexey Proskuryakov <ap@webkit.org>
Rubber-stamped by Darin Adler.
Don't keep platform objects for authentication challenge in ResourceHandleInternal.
We already have a copy in AuthenticationChallenge object.
* platform/network/ResourceHandle.cpp:
(WebCore::ResourceHandle::clearAuthentication):
* platform/network/ResourceHandleInternal.h:
(WebCore::ResourceHandleInternal::ResourceHandleInternal):
* platform/network/cf/ResourceHandleCFNet.cpp:
(WebCore::ResourceHandle::didReceiveAuthenticationChallenge):
(WebCore::ResourceHandle::receivedCredential):
(WebCore::ResourceHandle::receivedRequestToContinueWithoutCredential):
(WebCore::ResourceHandle::receivedCancellation):
* platform/network/mac/ResourceHandleMac.mm:
(WebCore::ResourceHandle::didReceiveAuthenticationChallenge):
(WebCore::ResourceHandle::didCancelAuthenticationChallenge):
(WebCore::ResourceHandle::receivedCredential):
(WebCore::ResourceHandle::receivedRequestToContinueWithoutCredential):
(WebCore::ResourceHandle::receivedCancellation):
2009-04-14 Geoffrey Garen <ggaren@apple.com> 2009-04-14 Geoffrey Garen <ggaren@apple.com>
Reviewed by Sam Weinig. Reviewed by Sam Weinig.
...@@ -103,12 +103,7 @@ const ResourceRequest& ResourceHandle::request() const ...@@ -103,12 +103,7 @@ const ResourceRequest& ResourceHandle::request() const
void ResourceHandle::clearAuthentication() void ResourceHandle::clearAuthentication()
{ {
#if PLATFORM(MAC) d->m_currentChallenge.nullify();
d->m_currentMacChallenge = nil;
#elif USE(CFNETWORK)
d->m_currentCFChallenge = 0;
#endif
d->m_currentWebChallenge.nullify();
} }
static bool portAllowed(const ResourceRequest& request) static bool portAllowed(const ResourceRequest& request)
......
...@@ -127,9 +127,6 @@ namespace WebCore { ...@@ -127,9 +127,6 @@ namespace WebCore {
#endif #endif
#if PLATFORM(MAC) #if PLATFORM(MAC)
, m_startWhenScheduled(false) , m_startWhenScheduled(false)
, m_currentMacChallenge(nil)
#elif USE(CFNETWORK)
, m_currentCFChallenge(0)
#endif #endif
, m_failureTimer(loader, &ResourceHandle::fireFailure) , m_failureTimer(loader, &ResourceHandle::fireFailure)
{ {
...@@ -209,13 +206,7 @@ namespace WebCore { ...@@ -209,13 +206,7 @@ namespace WebCore {
#endif #endif
QWebFrame* m_frame; QWebFrame* m_frame;
#endif #endif
#if PLATFORM(MAC) AuthenticationChallenge m_currentChallenge;
NSURLAuthenticationChallenge *m_currentMacChallenge;
#endif
#if USE(CFNETWORK)
CFURLAuthChallengeRef m_currentCFChallenge;
#endif
AuthenticationChallenge m_currentWebChallenge;
ResourceHandle::FailureType m_failureType; ResourceHandle::FailureType m_failureType;
Timer<ResourceHandle> m_failureTimer; Timer<ResourceHandle> m_failureTimer;
......
...@@ -409,8 +409,7 @@ bool ResourceHandle::shouldUseCredentialStorage() ...@@ -409,8 +409,7 @@ bool ResourceHandle::shouldUseCredentialStorage()
void ResourceHandle::didReceiveAuthenticationChallenge(const AuthenticationChallenge& challenge) void ResourceHandle::didReceiveAuthenticationChallenge(const AuthenticationChallenge& challenge)
{ {
LOG(Network, "CFNet - didReceiveAuthenticationChallenge()"); LOG(Network, "CFNet - didReceiveAuthenticationChallenge()");
ASSERT(!d->m_currentCFChallenge); ASSERT(d->m_currentChallenge.isNull());
ASSERT(d->m_currentWebChallenge.isNull());
// Since CFURLConnection networking relies on keeping a reference to the original CFURLAuthChallengeRef, // Since CFURLConnection networking relies on keeping a reference to the original CFURLAuthChallengeRef,
// we make sure that is actually present // we make sure that is actually present
ASSERT(challenge.cfURLAuthChallengeRef()); ASSERT(challenge.cfURLAuthChallengeRef());
...@@ -437,11 +436,10 @@ void ResourceHandle::didReceiveAuthenticationChallenge(const AuthenticationChall ...@@ -437,11 +436,10 @@ void ResourceHandle::didReceiveAuthenticationChallenge(const AuthenticationChall
} }
} }
d->m_currentCFChallenge = challenge.cfURLAuthChallengeRef(); d->m_currentChallenge = AuthenticationChallenge(challenge.cfURLAuthChallengeRef(), this);
d->m_currentWebChallenge = AuthenticationChallenge(d->m_currentCFChallenge, this);
if (client()) if (client())
client()->didReceiveAuthenticationChallenge(this, d->m_currentWebChallenge); client()->didReceiveAuthenticationChallenge(this, d->m_currentChallenge);
} }
void ResourceHandle::receivedCredential(const AuthenticationChallenge& challenge, const Credential& credential) void ResourceHandle::receivedCredential(const AuthenticationChallenge& challenge, const Credential& credential)
...@@ -449,7 +447,7 @@ void ResourceHandle::receivedCredential(const AuthenticationChallenge& challenge ...@@ -449,7 +447,7 @@ void ResourceHandle::receivedCredential(const AuthenticationChallenge& challenge
LOG(Network, "CFNet - receivedCredential()"); LOG(Network, "CFNet - receivedCredential()");
ASSERT(!challenge.isNull()); ASSERT(!challenge.isNull());
ASSERT(challenge.cfURLAuthChallengeRef()); ASSERT(challenge.cfURLAuthChallengeRef());
if (challenge != d->m_currentWebChallenge) if (challenge != d->m_currentChallenge)
return; return;
if (credential.persistence() == CredentialPersistenceForSession) { if (credential.persistence() == CredentialPersistenceForSession) {
...@@ -472,7 +470,7 @@ void ResourceHandle::receivedRequestToContinueWithoutCredential(const Authentica ...@@ -472,7 +470,7 @@ void ResourceHandle::receivedRequestToContinueWithoutCredential(const Authentica
LOG(Network, "CFNet - receivedRequestToContinueWithoutCredential()"); LOG(Network, "CFNet - receivedRequestToContinueWithoutCredential()");
ASSERT(!challenge.isNull()); ASSERT(!challenge.isNull());
ASSERT(challenge.cfURLAuthChallengeRef()); ASSERT(challenge.cfURLAuthChallengeRef());
if (challenge != d->m_currentWebChallenge) if (challenge != d->m_currentChallenge)
return; return;
CFURLConnectionUseCredential(d->m_connection.get(), 0, challenge.cfURLAuthChallengeRef()); CFURLConnectionUseCredential(d->m_connection.get(), 0, challenge.cfURLAuthChallengeRef());
...@@ -483,7 +481,7 @@ void ResourceHandle::receivedRequestToContinueWithoutCredential(const Authentica ...@@ -483,7 +481,7 @@ void ResourceHandle::receivedRequestToContinueWithoutCredential(const Authentica
void ResourceHandle::receivedCancellation(const AuthenticationChallenge& challenge) void ResourceHandle::receivedCancellation(const AuthenticationChallenge& challenge)
{ {
LOG(Network, "CFNet - receivedCancellation()"); LOG(Network, "CFNet - receivedCancellation()");
if (challenge != d->m_currentWebChallenge) if (challenge != d->m_currentChallenge)
return; return;
if (client()) if (client())
......
...@@ -406,8 +406,7 @@ bool ResourceHandle::shouldUseCredentialStorage() ...@@ -406,8 +406,7 @@ bool ResourceHandle::shouldUseCredentialStorage()
void ResourceHandle::didReceiveAuthenticationChallenge(const AuthenticationChallenge& challenge) void ResourceHandle::didReceiveAuthenticationChallenge(const AuthenticationChallenge& challenge)
{ {
ASSERT(!d->m_currentMacChallenge); ASSERT(d->m_currentChallenge.isNull());
ASSERT(d->m_currentWebChallenge.isNull());
// Since NSURLConnection networking relies on keeping a reference to the original NSURLAuthenticationChallenge, // Since NSURLConnection networking relies on keeping a reference to the original NSURLAuthenticationChallenge,
// we make sure that is actually present // we make sure that is actually present
ASSERT(challenge.nsURLAuthenticationChallenge()); ASSERT(challenge.nsURLAuthenticationChallenge());
...@@ -416,8 +415,7 @@ void ResourceHandle::didReceiveAuthenticationChallenge(const AuthenticationChall ...@@ -416,8 +415,7 @@ void ResourceHandle::didReceiveAuthenticationChallenge(const AuthenticationChall
NSURLCredential *credential = [[NSURLCredential alloc] initWithUser:d->m_user NSURLCredential *credential = [[NSURLCredential alloc] initWithUser:d->m_user
password:d->m_pass password:d->m_pass
persistence:NSURLCredentialPersistenceNone]; persistence:NSURLCredentialPersistenceNone];
d->m_currentMacChallenge = challenge.nsURLAuthenticationChallenge(); d->m_currentChallenge = challenge;
d->m_currentWebChallenge = challenge;
receivedCredential(challenge, core(credential)); receivedCredential(challenge, core(credential));
[credential release]; [credential release];
// FIXME: Per the specification, the user shouldn't be asked for credentials if there were incorrect ones provided explicitly. // FIXME: Per the specification, the user shouldn't be asked for credentials if there were incorrect ones provided explicitly.
...@@ -434,21 +432,19 @@ void ResourceHandle::didReceiveAuthenticationChallenge(const AuthenticationChall ...@@ -434,21 +432,19 @@ void ResourceHandle::didReceiveAuthenticationChallenge(const AuthenticationChall
} }
} }
d->m_currentMacChallenge = challenge.nsURLAuthenticationChallenge(); NSURLAuthenticationChallenge *webChallenge = [[NSURLAuthenticationChallenge alloc] initWithAuthenticationChallenge:challenge.nsURLAuthenticationChallenge()
NSURLAuthenticationChallenge *webChallenge = [[NSURLAuthenticationChallenge alloc] initWithAuthenticationChallenge:d->m_currentMacChallenge
sender:(id<NSURLAuthenticationChallengeSender>)delegate()]; sender:(id<NSURLAuthenticationChallengeSender>)delegate()];
d->m_currentWebChallenge = core(webChallenge); d->m_currentChallenge = core(webChallenge);
[webChallenge release]; [webChallenge release];
if (client()) if (client())
client()->didReceiveAuthenticationChallenge(this, d->m_currentWebChallenge); client()->didReceiveAuthenticationChallenge(this, d->m_currentChallenge);
} }
void ResourceHandle::didCancelAuthenticationChallenge(const AuthenticationChallenge& challenge) void ResourceHandle::didCancelAuthenticationChallenge(const AuthenticationChallenge& challenge)
{ {
ASSERT(d->m_currentMacChallenge); ASSERT(!d->m_currentChallenge.isNull());
ASSERT(!d->m_currentWebChallenge.isNull()); ASSERT(d->m_currentChallenge == challenge);
ASSERT(d->m_currentWebChallenge == challenge);
if (client()) if (client())
client()->didCancelAuthenticationChallenge(this, challenge); client()->didCancelAuthenticationChallenge(this, challenge);
...@@ -457,26 +453,28 @@ void ResourceHandle::didCancelAuthenticationChallenge(const AuthenticationChalle ...@@ -457,26 +453,28 @@ void ResourceHandle::didCancelAuthenticationChallenge(const AuthenticationChalle
void ResourceHandle::receivedCredential(const AuthenticationChallenge& challenge, const Credential& credential) void ResourceHandle::receivedCredential(const AuthenticationChallenge& challenge, const Credential& credential)
{ {
ASSERT(!challenge.isNull()); ASSERT(!challenge.isNull());
if (challenge != d->m_currentWebChallenge) if (challenge != d->m_currentChallenge)
return; return;
NSURLAuthenticationChallenge *currentMacChallenge = challenge.nsURLAuthenticationChallenge();
#ifdef BUILDING_ON_TIGER #ifdef BUILDING_ON_TIGER
if (credential.persistence() == CredentialPersistenceNone) { if (credential.persistence() == CredentialPersistenceNone) {
// NSURLCredentialPersistenceNone doesn't work on Tiger, so we have to use session persistence. // NSURLCredentialPersistenceNone doesn't work on Tiger, so we have to use session persistence.
Credential webCredential(credential.user(), credential.password(), CredentialPersistenceForSession); Credential webCredential(credential.user(), credential.password(), CredentialPersistenceForSession);
WebCoreCredentialStorage::set(mac(webCredential), [d->m_currentMacChallenge protectionSpace]); WebCoreCredentialStorage::set(mac(webCredential), [currentMacChallenge protectionSpace]);
[[d->m_currentMacChallenge sender] useCredential:mac(webCredential) forAuthenticationChallenge:d->m_currentMacChallenge]; [[currentMacChallenge sender] useCredential:mac(webCredential) forAuthenticationChallenge:currentMacChallenge];
} else } else
#else #else
if (credential.persistence() == CredentialPersistenceForSession) { if (credential.persistence() == CredentialPersistenceForSession) {
// Manage per-session credentials internally, because once NSURLCredentialPersistenceForSession is used, there is no way // Manage per-session credentials internally, because once NSURLCredentialPersistenceForSession is used, there is no way
// to ignore it for a particular request (short of removing it altogether). // to ignore it for a particular request (short of removing it altogether).
Credential webCredential(credential.user(), credential.password(), CredentialPersistenceNone); Credential webCredential(credential.user(), credential.password(), CredentialPersistenceNone);
WebCoreCredentialStorage::set(mac(webCredential), [d->m_currentMacChallenge protectionSpace]); WebCoreCredentialStorage::set(mac(webCredential), [currentMacChallenge protectionSpace]);
[[d->m_currentMacChallenge sender] useCredential:mac(webCredential) forAuthenticationChallenge:d->m_currentMacChallenge]; [[currentMacChallenge sender] useCredential:mac(webCredential) forAuthenticationChallenge:currentMacChallenge];
} else } else
#endif #endif
[[d->m_currentMacChallenge sender] useCredential:mac(credential) forAuthenticationChallenge:d->m_currentMacChallenge]; [[currentMacChallenge sender] useCredential:mac(credential) forAuthenticationChallenge:currentMacChallenge];
clearAuthentication(); clearAuthentication();
} }
...@@ -484,17 +482,18 @@ void ResourceHandle::receivedCredential(const AuthenticationChallenge& challenge ...@@ -484,17 +482,18 @@ void ResourceHandle::receivedCredential(const AuthenticationChallenge& challenge
void ResourceHandle::receivedRequestToContinueWithoutCredential(const AuthenticationChallenge& challenge) void ResourceHandle::receivedRequestToContinueWithoutCredential(const AuthenticationChallenge& challenge)
{ {
ASSERT(!challenge.isNull()); ASSERT(!challenge.isNull());
if (challenge != d->m_currentWebChallenge) if (challenge != d->m_currentChallenge)
return; return;
[[d->m_currentMacChallenge sender] continueWithoutCredentialForAuthenticationChallenge:d->m_currentMacChallenge]; NSURLAuthenticationChallenge *currentMacChallenge = challenge.nsURLAuthenticationChallenge();
[[currentMacChallenge sender] continueWithoutCredentialForAuthenticationChallenge:currentMacChallenge];
clearAuthentication(); clearAuthentication();
} }
void ResourceHandle::receivedCancellation(const AuthenticationChallenge& challenge) void ResourceHandle::receivedCancellation(const AuthenticationChallenge& challenge)
{ {
if (challenge != d->m_currentWebChallenge) if (challenge != d->m_currentChallenge)
return; return;
if (client()) if (client())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment