[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373
ap at apple.com
ap at apple.com
Wed Apr 7 23:34:04 UTC 2010
The following commit has been merged in the webkit-1.2 branch:
commit 90970c5aa2a501db3f0a75dfbdae5a7a78c60c53
Author: ap at apple.com <ap at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Nov 12 17:18:02 2009 +0000
Reviewed by Darin Adler.
https://bugs.webkit.org/show_bug.cgi?id=31386
Make Mac AuthenticationChallenge usable from cross-platform code
No change in behavior, so no tests.
* platform/network/ResourceHandle.cpp:
(WebCore::ResourceHandle::clearAuthentication):
* platform/network/ResourceHandleInternal.h:
(WebCore::ResourceHandleInternal::ResourceHandleInternal):
Don't store m_currentCFChallenge, which was only used for a single assertion. Unlike the
NSURLConnection case, CF challenge doesn't carry a sender with it, so the copy in web challenge
is identical.
* platform/network/cf/AuthenticationChallenge.h:
(WebCore::AuthenticationChallenge::setAuthenticationClient): Added a setter to match the new
Mac interface. Previously, one had to create a new AuthenticationChallenge to replace client.
* platform/network/cf/ResourceHandleCFNet.cpp:
(WebCore::ResourceHandle::didReceiveAuthenticationChallenge): Fixed assertions after removal
of m_currentCFChallenge. Also, there is no need to set client now, as it's guaranteed to
be already set.
* platform/network/mac/AuthenticationChallenge.h:
(WebCore::AuthenticationChallenge::m_sender): Explained the existence of this member to the
best of my understanding.
(WebCore::AuthenticationChallenge::m_nsChallenge): Renamed from m_macChallenge to prevent
confusion with "mac" and "web" challenges in ResourceHandleInternal.
* platform/network/mac/AuthenticationMac.mm:
(WebCoreAuthenticationClientAsChallengeSender): Added a Obj-C wrapper for AuthenticationClient,
making it possible to use the latter with NSURLAuthenticationChallenge.
(WebCore::AuthenticationChallenge::AuthenticationChallenge): Updated for m_macChallenge ->
m_nsChallenge renaming.
(WebCore::AuthenticationChallenge::setAuthenticationClient): Wrap the client in Obj-C and
set it as sender (or unset, if client is null).
* platform/network/mac/ResourceHandleMac.mm:
(WebCoreResourceHandleAsDelegate) WebCoreResourceHandleAsDelegate no longer doubles as
authentication challenge sender.
(WebCore::ResourceHandle::~ResourceHandle): A navigation can happen underneath an
authentication sheet.
(WebCore::ResourceHandle::didReceiveAuthenticationChallenge): Form m_currentWebChallenge
using the new setAuthenticationClient() method.
(WebCore::ResourceHandle::didCancelAuthenticationChallenge): Fixed an incorrect assertion.
Since didCancelAuthenticationChallenge is called by connection, the passed challenge is
the original Mac one, not the one we created for use with authentication sheet. I don't
know when a connection would cancel authentication in practice, so I haven't tested this.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@50882 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 3d6ef45..fcc894f 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,55 @@
+2009-11-11 Alexey Proskuryakov <ap at apple.com>
+
+ Reviewed by Darin Adler.
+
+ https://bugs.webkit.org/show_bug.cgi?id=31386
+ Make Mac AuthenticationChallenge usable from cross-platform code
+
+ No change in behavior, so no tests.
+
+ * platform/network/ResourceHandle.cpp:
+ (WebCore::ResourceHandle::clearAuthentication):
+ * platform/network/ResourceHandleInternal.h:
+ (WebCore::ResourceHandleInternal::ResourceHandleInternal):
+ Don't store m_currentCFChallenge, which was only used for a single assertion. Unlike the
+ NSURLConnection case, CF challenge doesn't carry a sender with it, so the copy in web challenge
+ is identical.
+
+ * platform/network/cf/AuthenticationChallenge.h:
+ (WebCore::AuthenticationChallenge::setAuthenticationClient): Added a setter to match the new
+ Mac interface. Previously, one had to create a new AuthenticationChallenge to replace client.
+
+ * platform/network/cf/ResourceHandleCFNet.cpp:
+ (WebCore::ResourceHandle::didReceiveAuthenticationChallenge): Fixed assertions after removal
+ of m_currentCFChallenge. Also, there is no need to set client now, as it's guaranteed to
+ be already set.
+
+ * platform/network/mac/AuthenticationChallenge.h:
+ (WebCore::AuthenticationChallenge::m_sender): Explained the existence of this member to the
+ best of my understanding.
+ (WebCore::AuthenticationChallenge::m_nsChallenge): Renamed from m_macChallenge to prevent
+ confusion with "mac" and "web" challenges in ResourceHandleInternal.
+
+ * platform/network/mac/AuthenticationMac.mm:
+ (WebCoreAuthenticationClientAsChallengeSender): Added a Obj-C wrapper for AuthenticationClient,
+ making it possible to use the latter with NSURLAuthenticationChallenge.
+ (WebCore::AuthenticationChallenge::AuthenticationChallenge): Updated for m_macChallenge ->
+ m_nsChallenge renaming.
+ (WebCore::AuthenticationChallenge::setAuthenticationClient): Wrap the client in Obj-C and
+ set it as sender (or unset, if client is null).
+
+ * platform/network/mac/ResourceHandleMac.mm:
+ (WebCoreResourceHandleAsDelegate) WebCoreResourceHandleAsDelegate no longer doubles as
+ authentication challenge sender.
+ (WebCore::ResourceHandle::~ResourceHandle): A navigation can happen underneath an
+ authentication sheet.
+ (WebCore::ResourceHandle::didReceiveAuthenticationChallenge): Form m_currentWebChallenge
+ using the new setAuthenticationClient() method.
+ (WebCore::ResourceHandle::didCancelAuthenticationChallenge): Fixed an incorrect assertion.
+ Since didCancelAuthenticationChallenge is called by connection, the passed challenge is
+ the original Mac one, not the one we created for use with authentication sheet. I don't
+ know when a connection would cancel authentication in practice, so I haven't tested this.
+
2009-11-12 Patrick Mueller <Patrick_Mueller at us.ibm.com>
Reviewed by Timothy Hatcher.
diff --git a/WebCore/platform/network/ResourceHandle.cpp b/WebCore/platform/network/ResourceHandle.cpp
index 5a40b21..d3ab582 100644
--- a/WebCore/platform/network/ResourceHandle.cpp
+++ b/WebCore/platform/network/ResourceHandle.cpp
@@ -110,8 +110,6 @@ void ResourceHandle::clearAuthentication()
{
#if PLATFORM(MAC)
d->m_currentMacChallenge = nil;
-#elif USE(CFNETWORK)
- d->m_currentCFChallenge = 0;
#endif
d->m_currentWebChallenge.nullify();
}
diff --git a/WebCore/platform/network/ResourceHandleInternal.h b/WebCore/platform/network/ResourceHandleInternal.h
index 1733dea..cec4ff7 100644
--- a/WebCore/platform/network/ResourceHandleInternal.h
+++ b/WebCore/platform/network/ResourceHandleInternal.h
@@ -128,8 +128,6 @@ namespace WebCore {
, m_startWhenScheduled(false)
, m_needsSiteSpecificQuirks(false)
, m_currentMacChallenge(nil)
-#elif USE(CFNETWORK)
- , m_currentCFChallenge(0)
#endif
, m_failureTimer(loader, &ResourceHandle::fireFailure)
{
@@ -212,13 +210,11 @@ namespace WebCore {
QWebFrame* m_frame;
#endif
- // FIXME: The platform challenge is almost identical to the one stored in m_currentWebChallenge, but it has a different sender. We only need to store a sender reference here.
#if PLATFORM(MAC)
+ // We need to keep a reference to the original challenge to be able to cancel it.
+ // It is almost identical to m_currentWebChallenge.nsURLAuthenticationChallenge(), but has a different sender.
NSURLAuthenticationChallenge *m_currentMacChallenge;
#endif
-#if USE(CFNETWORK)
- CFURLAuthChallengeRef m_currentCFChallenge;
-#endif
AuthenticationChallenge m_currentWebChallenge;
ResourceHandle::FailureType m_failureType;
diff --git a/WebCore/platform/network/cf/AuthenticationChallenge.h b/WebCore/platform/network/cf/AuthenticationChallenge.h
index 61e0c10..58fb836 100644
--- a/WebCore/platform/network/cf/AuthenticationChallenge.h
+++ b/WebCore/platform/network/cf/AuthenticationChallenge.h
@@ -40,6 +40,8 @@ public:
AuthenticationChallenge(CFURLAuthChallengeRef, AuthenticationClient*);
AuthenticationClient* authenticationClient() const { return m_authenticationClient.get(); }
+ void setAuthenticationClient(AuthenticationClient* client) { m_authenticationClient = client; }
+
CFURLAuthChallengeRef cfURLAuthChallengeRef() const { return m_cfChallenge.get(); }
private:
diff --git a/WebCore/platform/network/cf/ResourceHandleCFNet.cpp b/WebCore/platform/network/cf/ResourceHandleCFNet.cpp
index 38a9705..fdc57c5 100644
--- a/WebCore/platform/network/cf/ResourceHandleCFNet.cpp
+++ b/WebCore/platform/network/cf/ResourceHandleCFNet.cpp
@@ -479,11 +479,11 @@ bool ResourceHandle::shouldUseCredentialStorage()
void ResourceHandle::didReceiveAuthenticationChallenge(const AuthenticationChallenge& challenge)
{
LOG(Network, "CFNet - didReceiveAuthenticationChallenge()");
- ASSERT(!d->m_currentCFChallenge);
ASSERT(d->m_currentWebChallenge.isNull());
// Since CFURLConnection networking relies on keeping a reference to the original CFURLAuthChallengeRef,
// we make sure that is actually present
ASSERT(challenge.cfURLAuthChallengeRef());
+ ASSERT(challenge.authenticationClient() == this); // Should be already set.
if (!d->m_user.isNull() && !d->m_pass.isNull()) {
RetainPtr<CFStringRef> user(AdoptCF, d->m_user.createCFString());
@@ -513,8 +513,7 @@ void ResourceHandle::didReceiveAuthenticationChallenge(const AuthenticationChall
}
}
- d->m_currentCFChallenge = challenge.cfURLAuthChallengeRef();
- d->m_currentWebChallenge = AuthenticationChallenge(d->m_currentCFChallenge, this);
+ d->m_currentWebChallenge = challenge;
if (client())
client()->didReceiveAuthenticationChallenge(this, d->m_currentWebChallenge);
diff --git a/WebCore/platform/network/mac/AuthenticationChallenge.h b/WebCore/platform/network/mac/AuthenticationChallenge.h
index e8f3a2d..d74a92c 100644
--- a/WebCore/platform/network/mac/AuthenticationChallenge.h
+++ b/WebCore/platform/network/mac/AuthenticationChallenge.h
@@ -37,21 +37,25 @@ class NSURLAuthenticationChallenge;
namespace WebCore {
+class AuthenticationClient;
+
class AuthenticationChallenge : public AuthenticationChallengeBase {
public:
- AuthenticationChallenge() {}
+ AuthenticationChallenge() { }
AuthenticationChallenge(const ProtectionSpace& protectionSpace, const Credential& proposedCredential, unsigned previousFailureCount, const ResourceResponse& response, const ResourceError& error);
AuthenticationChallenge(NSURLAuthenticationChallenge *);
id sender() const { return m_sender.get(); }
- NSURLAuthenticationChallenge *nsURLAuthenticationChallenge() const { return m_macChallenge.get(); }
+ NSURLAuthenticationChallenge *nsURLAuthenticationChallenge() const { return m_nsChallenge.get(); }
+
+ void setAuthenticationClient(AuthenticationClient*); // Changes sender to one that invokes client methods.
private:
friend class AuthenticationChallengeBase;
static bool platformCompare(const AuthenticationChallenge& a, const AuthenticationChallenge& b);
- RetainPtr<id> m_sender;
- RetainPtr<NSURLAuthenticationChallenge *> m_macChallenge;
+ RetainPtr<id> m_sender; // Always the same as [m_macChallenge.get() sender], cached here for performance.
+ RetainPtr<NSURLAuthenticationChallenge *> m_nsChallenge;
};
}
diff --git a/WebCore/platform/network/mac/AuthenticationMac.mm b/WebCore/platform/network/mac/AuthenticationMac.mm
index 8208e52..58022f7 100644
--- a/WebCore/platform/network/mac/AuthenticationMac.mm
+++ b/WebCore/platform/network/mac/AuthenticationMac.mm
@@ -26,6 +26,7 @@
#import "AuthenticationMac.h"
#import "AuthenticationChallenge.h"
+#import "AuthenticationClient.h"
#import "Credential.h"
#import "ProtectionSpace.h"
@@ -33,6 +34,51 @@
#import <Foundation/NSURLCredential.h>
#import <Foundation/NSURLProtectionSpace.h>
+using namespace WebCore;
+
+ at interface WebCoreAuthenticationClientAsChallengeSender : NSObject <NSURLAuthenticationChallengeSender>
+{
+ AuthenticationClient* m_client;
+}
+- (id)initWithClient:(AuthenticationClient*)client;
+- (void)detachClient;
+ at end
+
+ at implementation WebCoreAuthenticationClientAsChallengeSender
+
+- (id)initWithClient:(AuthenticationClient*)client
+{
+ self = [self init];
+ if (!self)
+ return nil;
+ m_client = client;
+ return self;
+}
+
+- (void)detachClient
+{
+ m_client = 0;
+}
+
+- (void)useCredential:(NSURLCredential *)credential forAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
+{
+ if (m_client)
+ m_client->receivedCredential(core(challenge), core(credential));
+}
+
+- (void)continueWithoutCredentialForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
+{
+ if (m_client)
+ m_client->receivedRequestToContinueWithoutCredential(core(challenge));
+}
+
+- (void)cancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
+{
+ if (m_client)
+ m_client->receivedCancellation(core(challenge));
+}
+
+ at end
namespace WebCore {
@@ -49,15 +95,26 @@ AuthenticationChallenge::AuthenticationChallenge(const ProtectionSpace& protecti
{
}
-AuthenticationChallenge::AuthenticationChallenge(NSURLAuthenticationChallenge *macChallenge)
- : AuthenticationChallengeBase(core([macChallenge protectionSpace]),
- core([macChallenge proposedCredential]),
- [macChallenge previousFailureCount],
- [macChallenge failureResponse],
- [macChallenge error])
- , m_sender([macChallenge sender])
- , m_macChallenge(macChallenge)
+AuthenticationChallenge::AuthenticationChallenge(NSURLAuthenticationChallenge *challenge)
+ : AuthenticationChallengeBase(core([challenge protectionSpace]),
+ core([challenge proposedCredential]),
+ [challenge previousFailureCount],
+ [challenge failureResponse],
+ [challenge error])
+ , m_sender([challenge sender])
+ , m_nsChallenge(challenge)
+{
+}
+
+void AuthenticationChallenge::setAuthenticationClient(AuthenticationClient* client)
{
+ if (client) {
+ m_sender.adoptNS([[WebCoreAuthenticationClientAsChallengeSender alloc] initWithClient:client]);
+ m_nsChallenge.adoptNS([[NSURLAuthenticationChallenge alloc] initWithAuthenticationChallenge:m_nsChallenge.get() sender:m_sender.get()]);
+ } else {
+ if ([m_sender.get() isMemberOfClass:[WebCoreAuthenticationClientAsChallengeSender class]])
+ [(WebCoreAuthenticationClientAsChallengeSender *)m_sender.get() detachClient];
+ }
}
bool AuthenticationChallenge::platformCompare(const AuthenticationChallenge& a, const AuthenticationChallenge& b)
diff --git a/WebCore/platform/network/mac/ResourceHandleMac.mm b/WebCore/platform/network/mac/ResourceHandleMac.mm
index 3630b30..12bd659 100644
--- a/WebCore/platform/network/mac/ResourceHandleMac.mm
+++ b/WebCore/platform/network/mac/ResourceHandleMac.mm
@@ -55,7 +55,7 @@ typedef int NSInteger;
using namespace WebCore;
- at interface WebCoreResourceHandleAsDelegate : NSObject <NSURLAuthenticationChallengeSender>
+ at interface WebCoreResourceHandleAsDelegate : NSObject
{
ResourceHandle* m_handle;
}
@@ -138,6 +138,7 @@ ResourceHandleInternal::~ResourceHandleInternal()
ResourceHandle::~ResourceHandle()
{
releaseDelegate();
+ d->m_currentWebChallenge.setAuthenticationClient(0);
LOG(Network, "Handle %p destroyed", this);
}
@@ -511,10 +512,8 @@ void ResourceHandle::didReceiveAuthenticationChallenge(const AuthenticationChall
#endif
d->m_currentMacChallenge = challenge.nsURLAuthenticationChallenge();
- NSURLAuthenticationChallenge *webChallenge = [[NSURLAuthenticationChallenge alloc] initWithAuthenticationChallenge:d->m_currentMacChallenge
- sender:(id<NSURLAuthenticationChallengeSender>)delegate()];
- d->m_currentWebChallenge = core(webChallenge);
- [webChallenge release];
+ d->m_currentWebChallenge = core(d->m_currentMacChallenge);
+ d->m_currentWebChallenge.setAuthenticationClient(this);
if (client())
client()->didReceiveAuthenticationChallenge(this, d->m_currentWebChallenge);
@@ -523,8 +522,8 @@ void ResourceHandle::didReceiveAuthenticationChallenge(const AuthenticationChall
void ResourceHandle::didCancelAuthenticationChallenge(const AuthenticationChallenge& challenge)
{
ASSERT(d->m_currentMacChallenge);
+ ASSERT(d->m_currentMacChallenge == challenge.nsURLAuthenticationChallenge());
ASSERT(!d->m_currentWebChallenge.isNull());
- ASSERT(d->m_currentWebChallenge == challenge);
if (client())
client()->didCancelAuthenticationChallenge(this, challenge);
@@ -868,27 +867,6 @@ void ResourceHandle::receivedCancellation(const AuthenticationChallenge& challen
return newResponse;
}
-- (void)useCredential:(NSURLCredential *)credential forAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
-{
- if (!m_handle)
- return;
- m_handle->receivedCredential(core(challenge), core(credential));
-}
-
-- (void)continueWithoutCredentialForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
-{
- if (!m_handle)
- return;
- m_handle->receivedRequestToContinueWithoutCredential(core(challenge));
-}
-
-- (void)cancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
-{
- if (!m_handle)
- return;
- m_handle->receivedCancellation(core(challenge));
-}
-
@end
#ifndef BUILDING_ON_TIGER
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list