Modified: releases/WebKitGTK/webkit-2.10/Source/WebKit2/ChangeLog (195106 => 195107)
--- releases/WebKitGTK/webkit-2.10/Source/WebKit2/ChangeLog 2016-01-15 10:06:27 UTC (rev 195106)
+++ releases/WebKitGTK/webkit-2.10/Source/WebKit2/ChangeLog 2016-01-15 10:30:27 UTC (rev 195107)
@@ -1,3 +1,52 @@
+2015-11-10 Alex Christensen <[email protected]>
+
+ Implement authentication challenge handling when using NETWORK_SESSION
+ https://bugs.webkit.org/show_bug.cgi?id=150968
+
+ Reviewed by Antti Koivisto.
+
+ * NetworkProcess/NetworkLoad.cpp:
+ (WebKit::NetworkLoad::didReceiveChallenge):
+ Copy functionality from NetworkLoad::canAuthenticateAgainstProtectionSpaceAsync (which is used when we don't use NETWORK_SESSION)
+ because there is no canAuthenticateAgainstProtectionSpace delegate callback when using NSURLSession, according to
+ https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/URLLoadingSystem/Articles/AuthenticationChallenges.html
+ Instead, all authentication challenge callbacks go to URLSession:task:didReceiveChallenge:completionHandler:
+ because we do not implement URLSession:didReceiveChallenge:completionHandler:
+ * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+ (-[NetworkSessionDelegate URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:]):
+ (-[NetworkSessionDelegate URLSession:task:didReceiveChallenge:completionHandler:]):
+ (-[NetworkSessionDelegate URLSession:dataTask:didReceiveResponse:completionHandler:]):
+ Make a block copy of the completion handlers so we can copy the std::functions that wrap them into HashMaps and call them later,
+ in this case we call the completion handler after the UIProcess gives us credentials for an authentication challenge.
+ * Shared/Authentication/AuthenticationManager.cpp:
+ (WebKit::AuthenticationManager::AuthenticationManager):
+ (WebKit::AuthenticationManager::addChallengeToChallengeMap):
+ (WebKit::AuthenticationManager::shouldCoalesceChallenge):
+ (WebKit::AuthenticationManager::coalesceChallengesMatching):
+ (WebKit::AuthenticationManager::didReceiveAuthenticationChallenge):
+ Fix an existing bug that caused multiple calls to addChallengeToChallengeMap for one challenge. This caused too many calls to
+ the AuthenticationClient methods, which did not cause a problem because they were not one-time-use block copies of completion handlers before.
+ (WebKit::AuthenticationManager::useCredentialForSingleChallenge):
+ (WebKit::AuthenticationManager::continueWithoutCredentialForChallenge):
+ (WebKit::AuthenticationManager::continueWithoutCredentialForSingleChallenge):
+ (WebKit::AuthenticationManager::cancelChallenge):
+ (WebKit::AuthenticationManager::cancelSingleChallenge):
+ (WebKit::AuthenticationManager::performDefaultHandling):
+ (WebKit::AuthenticationManager::performDefaultHandlingForSingleChallenge):
+ (WebKit::AuthenticationManager::rejectProtectionSpaceAndContinue):
+ (WebKit::AuthenticationManager::rejectProtectionSpaceAndContinueForSingleChallenge):
+ Call completion handlers which we stored in a HashMap before doing IPC if we are using NETWORK_SESSION,
+ which has completion handlers instead of continueSomething client calls.
+ * Shared/Authentication/AuthenticationManager.h:
+ (WebKit::AuthenticationManager::outstandingAuthenticationChallengeCount):
+ * Shared/Downloads/Download.cpp:
+ (WebKit::Download::didReceiveAuthenticationChallenge):
+ (WebKit::Download::didReceiveResponse):
+ * Shared/Downloads/DownloadAuthenticationClient.cpp:
+ (WebKit::DownloadAuthenticationClient::receivedChallengeRejection):
+ * Shared/Downloads/DownloadAuthenticationClient.h:
+ Add ifdefs for code related to downloading I will implement later.
+
2015-11-30 Jiewen Tan <[email protected]>
Null dereference loading Blink layout test http/tests/misc/detach-during-notifyDone.html
Modified: releases/WebKitGTK/webkit-2.10/Source/WebKit2/Shared/Authentication/AuthenticationManager.cpp (195106 => 195107)
--- releases/WebKitGTK/webkit-2.10/Source/WebKit2/Shared/Authentication/AuthenticationManager.cpp 2016-01-15 10:06:27 UTC (rev 195106)
+++ releases/WebKitGTK/webkit-2.10/Source/WebKit2/Shared/Authentication/AuthenticationManager.cpp 2016-01-15 10:30:27 UTC (rev 195107)
@@ -70,12 +70,12 @@
m_process->addMessageReceiver(Messages::AuthenticationManager::messageReceiverName(), *this);
}
-uint64_t AuthenticationManager::addChallengeToChallengeMap(const WebCore::AuthenticationChallenge& authenticationChallenge)
+uint64_t AuthenticationManager::addChallengeToChallengeMap(const Challenge& challenge)
{
ASSERT(RunLoop::isMain());
uint64_t challengeID = generateAuthenticationChallengeID();
- m_challenges.set(challengeID, authenticationChallenge);
+ m_challenges.set(challengeID, challenge);
return challengeID;
}
@@ -85,7 +85,7 @@
return false;
for (auto& item : m_challenges) {
- if (item.key != challengeID && ProtectionSpace::compare(challenge.protectionSpace(), item.value.protectionSpace()))
+ if (item.key != challengeID && ProtectionSpace::compare(challenge.protectionSpace(), item.value.challenge.protectionSpace()))
return true;
}
return false;
@@ -93,17 +93,17 @@
Vector<uint64_t> AuthenticationManager::coalesceChallengesMatching(uint64_t challengeID) const
{
- AuthenticationChallenge challenge = m_challenges.get(challengeID);
- ASSERT(!challenge.isNull());
+ auto challenge = m_challenges.get(challengeID);
+ ASSERT(!challenge.challenge.isNull());
Vector<uint64_t> challengesToCoalesce;
challengesToCoalesce.append(challengeID);
- if (!canCoalesceChallenge(challenge))
+ if (!canCoalesceChallenge(challenge.challenge))
return challengesToCoalesce;
for (auto& item : m_challenges) {
- if (item.key != challengeID && ProtectionSpace::compare(challenge.protectionSpace(), item.value.protectionSpace()))
+ if (item.key != challengeID && ProtectionSpace::compare(challenge.challenge.protectionSpace(), item.value.challenge.protectionSpace()))
challengesToCoalesce.append(item.key);
}
@@ -115,7 +115,11 @@
ASSERT(frame);
ASSERT(frame->page());
- uint64_t challengeID = addChallengeToChallengeMap(authenticationChallenge);
+ uint64_t challengeID = addChallengeToChallengeMap({authenticationChallenge
+#if USE(NETWORK_SESSION)
+ , ChallengeCompletionHandler()
+#endif
+ });
// Coalesce challenges in the same protection space.
if (shouldCoalesceChallenge(challengeID, authenticationChallenge))
@@ -125,27 +129,46 @@
}
#if ENABLE(NETWORK_PROCESS)
+#if USE(NETWORK_SESSION)
+void AuthenticationManager::didReceiveAuthenticationChallenge(uint64_t pageID, uint64_t frameID, const AuthenticationChallenge& authenticationChallenge, ChallengeCompletionHandler completionHandler)
+{
+ ASSERT(pageID);
+ ASSERT(frameID);
+
+ uint64_t challengeID = addChallengeToChallengeMap({authenticationChallenge, completionHandler});
+ if (shouldCoalesceChallenge(challengeID, authenticationChallenge))
+ return;
+
+ m_process->send(Messages::NetworkProcessProxy::DidReceiveAuthenticationChallenge(pageID, frameID, authenticationChallenge, challengeID));
+}
+#endif
void AuthenticationManager::didReceiveAuthenticationChallenge(uint64_t pageID, uint64_t frameID, const AuthenticationChallenge& authenticationChallenge)
{
ASSERT(pageID);
ASSERT(frameID);
- uint64_t challengeID = addChallengeToChallengeMap(authenticationChallenge);
+ uint64_t challengeID = addChallengeToChallengeMap({authenticationChallenge
+#if USE(NETWORK_SESSION)
+ , ChallengeCompletionHandler()
+#endif
+ });
if (shouldCoalesceChallenge(challengeID, authenticationChallenge))
return;
- m_process->send(Messages::NetworkProcessProxy::DidReceiveAuthenticationChallenge(pageID, frameID, authenticationChallenge, addChallengeToChallengeMap(authenticationChallenge)));
+ m_process->send(Messages::NetworkProcessProxy::DidReceiveAuthenticationChallenge(pageID, frameID, authenticationChallenge, challengeID));
}
#endif
+#if !USE(NETWORK_SESSION)
void AuthenticationManager::didReceiveAuthenticationChallenge(Download* download, const AuthenticationChallenge& authenticationChallenge)
{
- uint64_t challengeID = addChallengeToChallengeMap(authenticationChallenge);
+ uint64_t challengeID = addChallengeToChallengeMap({authenticationChallenge});
if (shouldCoalesceChallenge(challengeID, authenticationChallenge))
return;
- download->send(Messages::DownloadProxy::DidReceiveAuthenticationChallenge(authenticationChallenge, addChallengeToChallengeMap(authenticationChallenge)));
+ download->send(Messages::DownloadProxy::DidReceiveAuthenticationChallenge(authenticationChallenge, challengeID));
}
+#endif
// Currently, only Mac knows how to respond to authentication challenges with certificate info.
#if !HAVE(SEC_IDENTITY)
@@ -165,21 +188,30 @@
void AuthenticationManager::useCredentialForSingleChallenge(uint64_t challengeID, const Credential& credential, const CertificateInfo& certificateInfo)
{
- AuthenticationChallenge challenge = m_challenges.take(challengeID);
- ASSERT(!challenge.isNull());
-
- if (tryUseCertificateInfoForChallenge(challenge, certificateInfo))
+ auto challenge = m_challenges.take(challengeID);
+ ASSERT(!challenge.challenge.isNull());
+
+ if (tryUseCertificateInfoForChallenge(challenge.challenge, certificateInfo))
return;
-
- AuthenticationClient* coreClient = challenge.authenticationClient();
+
+#if USE(NETWORK_SESSION)
+ // If there is a completion handler, then there is no AuthenticationClient.
+ // FIXME: Remove the use of AuthenticationClient in WebKit2 once NETWORK_SESSION is used for all loads.
+ if (challenge.completionHandler) {
+ challenge.completionHandler(AuthenticationChallengeDisposition::UseCredential, credential);
+ return;
+ }
+#endif
+
+ AuthenticationClient* coreClient = challenge.challenge.authenticationClient();
if (!coreClient) {
// FIXME: The authentication client is null for downloads, but it can also be null for canceled loads.
// We should not call Download::receivedCredential in the latter case.
- Download::receivedCredential(challenge, credential);
+ Download::receivedCredential(challenge.challenge, credential);
return;
}
- coreClient->receivedCredential(challenge, credential);
+ coreClient->receivedCredential(challenge.challenge, credential);
}
void AuthenticationManager::continueWithoutCredentialForChallenge(uint64_t challengeID)
@@ -192,17 +224,25 @@
void AuthenticationManager::continueWithoutCredentialForSingleChallenge(uint64_t challengeID)
{
- AuthenticationChallenge challenge = m_challenges.take(challengeID);
- ASSERT(!challenge.isNull());
- AuthenticationClient* coreClient = challenge.authenticationClient();
+ auto challenge = m_challenges.take(challengeID);
+ ASSERT(!challenge.challenge.isNull());
+
+#if USE(NETWORK_SESSION)
+ if (challenge.completionHandler) {
+ challenge.completionHandler(AuthenticationChallengeDisposition::UseCredential, Credential());
+ return;
+ }
+#endif
+
+ AuthenticationClient* coreClient = challenge.challenge.authenticationClient();
if (!coreClient) {
// FIXME: The authentication client is null for downloads, but it can also be null for canceled loads.
// We should not call Download::receivedCredential in the latter case.
- Download::receivedRequestToContinueWithoutCredential(challenge);
+ Download::receivedRequestToContinueWithoutCredential(challenge.challenge);
return;
}
- coreClient->receivedRequestToContinueWithoutCredential(challenge);
+ coreClient->receivedRequestToContinueWithoutCredential(challenge.challenge);
}
void AuthenticationManager::cancelChallenge(uint64_t challengeID)
@@ -215,17 +255,25 @@
void AuthenticationManager::cancelSingleChallenge(uint64_t challengeID)
{
- AuthenticationChallenge challenge = m_challenges.take(challengeID);
- ASSERT(!challenge.isNull());
- AuthenticationClient* coreClient = challenge.authenticationClient();
+ auto challenge = m_challenges.take(challengeID);
+ ASSERT(!challenge.challenge.isNull());
+
+#if USE(NETWORK_SESSION)
+ if (challenge.completionHandler) {
+ challenge.completionHandler(AuthenticationChallengeDisposition::Cancel, Credential());
+ return;
+ }
+#endif
+
+ AuthenticationClient* coreClient = challenge.challenge.authenticationClient();
if (!coreClient) {
// FIXME: The authentication client is null for downloads, but it can also be null for canceled loads.
// We should not call Download::receivedCredential in the latter case.
- Download::receivedCancellation(challenge);
+ Download::receivedCancellation(challenge.challenge);
return;
}
- coreClient->receivedCancellation(challenge);
+ coreClient->receivedCancellation(challenge.challenge);
}
void AuthenticationManager::performDefaultHandling(uint64_t challengeID)
@@ -238,17 +286,25 @@
void AuthenticationManager::performDefaultHandlingForSingleChallenge(uint64_t challengeID)
{
- AuthenticationChallenge challenge = m_challenges.take(challengeID);
- ASSERT(!challenge.isNull());
- AuthenticationClient* coreClient = challenge.authenticationClient();
+ auto challenge = m_challenges.take(challengeID);
+ ASSERT(!challenge.challenge.isNull());
+
+#if USE(NETWORK_SESSION)
+ if (challenge.completionHandler) {
+ challenge.completionHandler(AuthenticationChallengeDisposition::PerformDefaultHandling, Credential());
+ return;
+ }
+#endif
+
+ AuthenticationClient* coreClient = challenge.challenge.authenticationClient();
if (!coreClient) {
// FIXME: The authentication client is null for downloads, but it can also be null for canceled loads.
// We should not call Download::receivedCredential in the latter case.
- Download::receivedRequestToPerformDefaultHandling(challenge);
+ Download::receivedRequestToPerformDefaultHandling(challenge.challenge);
return;
}
- coreClient->receivedRequestToPerformDefaultHandling(challenge);
+ coreClient->receivedRequestToPerformDefaultHandling(challenge.challenge);
}
void AuthenticationManager::rejectProtectionSpaceAndContinue(uint64_t challengeID)
@@ -261,17 +317,25 @@
void AuthenticationManager::rejectProtectionSpaceAndContinueForSingleChallenge(uint64_t challengeID)
{
- AuthenticationChallenge challenge = m_challenges.take(challengeID);
- ASSERT(!challenge.isNull());
- AuthenticationClient* coreClient = challenge.authenticationClient();
+ auto challenge = m_challenges.take(challengeID);
+ ASSERT(!challenge.challenge.isNull());
+
+#if USE(NETWORK_SESSION)
+ if (challenge.completionHandler) {
+ challenge.completionHandler(AuthenticationChallengeDisposition::RejectProtectionSpace, Credential());
+ return;
+ }
+#endif
+
+ AuthenticationClient* coreClient = challenge.challenge.authenticationClient();
if (!coreClient) {
// FIXME: The authentication client is null for downloads, but it can also be null for canceled loads.
// We should not call Download::receivedCredential in the latter case.
- Download::receivedChallengeRejection(challenge);
+ Download::receivedChallengeRejection(challenge.challenge);
return;
}
- coreClient->receivedChallengeRejection(challenge);
+ coreClient->receivedChallengeRejection(challenge.challenge);
}
} // namespace WebKit
Modified: releases/WebKitGTK/webkit-2.10/Source/WebKit2/Shared/Authentication/AuthenticationManager.h (195106 => 195107)
--- releases/WebKitGTK/webkit-2.10/Source/WebKit2/Shared/Authentication/AuthenticationManager.h 2016-01-15 10:06:27 UTC (rev 195106)
+++ releases/WebKitGTK/webkit-2.10/Source/WebKit2/Shared/Authentication/AuthenticationManager.h 2016-01-15 10:30:27 UTC (rev 195107)
@@ -52,6 +52,10 @@
static const char* supplementName();
+#if USE(NETWORK_SESSION)
+ typedef std::function<void(AuthenticationChallengeDisposition, const WebCore::Credential&)> ChallengeCompletionHandler;
+ void didReceiveAuthenticationChallenge(uint64_t pageID, uint64_t frameID, const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler);
+#endif
// Called for resources in the WebProcess (NetworkProcess disabled)
void didReceiveAuthenticationChallenge(WebFrame*, const WebCore::AuthenticationChallenge&);
// Called for resources in the NetworkProcess (NetworkProcess enabled)
@@ -68,12 +72,19 @@
uint64_t outstandingAuthenticationChallengeCount() const { return m_challenges.size(); }
private:
+ struct Challenge {
+ WebCore::AuthenticationChallenge challenge;
+#if USE(NETWORK_SESSION)
+ ChallengeCompletionHandler completionHandler;
+#endif
+ };
+
// IPC::MessageReceiver
virtual void didReceiveMessage(IPC::Connection&, IPC::MessageDecoder&) override;
bool tryUseCertificateInfoForChallenge(const WebCore::AuthenticationChallenge&, const WebCore::CertificateInfo&);
- uint64_t addChallengeToChallengeMap(const WebCore::AuthenticationChallenge&);
+ uint64_t addChallengeToChallengeMap(const Challenge&);
bool shouldCoalesceChallenge(uint64_t challengeID, const WebCore::AuthenticationChallenge&) const;
void useCredentialForSingleChallenge(uint64_t challengeID, const WebCore::Credential&, const WebCore::CertificateInfo&);
@@ -86,8 +97,7 @@
ChildProcess* m_process;
- typedef HashMap<uint64_t, WebCore::AuthenticationChallenge> AuthenticationChallengeMap;
- AuthenticationChallengeMap m_challenges;
+ HashMap<uint64_t, Challenge> m_challenges;
};
} // namespace WebKit