Title: [91799] trunk/Source/WebCore
Revision
91799
Author
[email protected]
Date
2011-07-26 16:43:15 -0700 (Tue, 26 Jul 2011)

Log Message

Add protection space authentication callback code to CFNetwork loader on Mac
https://bugs.webkit.org/show_bug.cgi?id=65190
<rdar://problem/9842424>

Reviewed by Oliver Hunt.

Port over protection space authentication callback code from ResourceHandleMac.mm to
ResourceHandleCFNet.cpp.

* platform/network/ResourceHandle.h:
* platform/network/cf/ResourceHandleCFNet.cpp:
(WebCore::canRespondToProtectionSpace):
(WebCore::ResourceHandle::createCFURLConnection):
(WebCore::ResourceHandle::canAuthenticateAgainstProtectionSpace):
(WebCore::WebCoreSynchronousLoaderClient::canAuthenticateAgainstProtectionSpace):
* platform/network/mac/ResourceHandleMac.mm:
(-[WebCoreResourceHandleAsDelegate connection:canAuthenticateAgainstProtectionSpace:]): Add logging.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (91798 => 91799)


--- trunk/Source/WebCore/ChangeLog	2011-07-26 23:30:52 UTC (rev 91798)
+++ trunk/Source/WebCore/ChangeLog	2011-07-26 23:43:15 UTC (rev 91799)
@@ -1,3 +1,23 @@
+2011-07-26  Pratik Solanki  <[email protected]>
+
+        Add protection space authentication callback code to CFNetwork loader on Mac
+        https://bugs.webkit.org/show_bug.cgi?id=65190
+        <rdar://problem/9842424>
+
+        Reviewed by Oliver Hunt.
+
+        Port over protection space authentication callback code from ResourceHandleMac.mm to
+        ResourceHandleCFNet.cpp.
+
+        * platform/network/ResourceHandle.h:
+        * platform/network/cf/ResourceHandleCFNet.cpp:
+        (WebCore::canRespondToProtectionSpace):
+        (WebCore::ResourceHandle::createCFURLConnection):
+        (WebCore::ResourceHandle::canAuthenticateAgainstProtectionSpace):
+        (WebCore::WebCoreSynchronousLoaderClient::canAuthenticateAgainstProtectionSpace):
+        * platform/network/mac/ResourceHandleMac.mm:
+        (-[WebCoreResourceHandleAsDelegate connection:canAuthenticateAgainstProtectionSpace:]): Add logging.
+
 2011-07-26  Sadrul Habib Chowdhury  <[email protected]>
 
         Add support for download='filename' attribute in anchors.

Modified: trunk/Source/WebCore/platform/network/ResourceHandle.h (91798 => 91799)


--- trunk/Source/WebCore/platform/network/ResourceHandle.h	2011-07-26 23:30:52 UTC (rev 91798)
+++ trunk/Source/WebCore/platform/network/ResourceHandle.h	2011-07-26 23:43:15 UTC (rev 91799)
@@ -122,18 +122,18 @@
     virtual void receivedCancellation(const AuthenticationChallenge&);
 #endif
 
-#if PLATFORM(MAC) && !USE(CFNETWORK)
-    void didCancelAuthenticationChallenge(const AuthenticationChallenge&);
+#if PLATFORM(MAC)
 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
     bool canAuthenticateAgainstProtectionSpace(const ProtectionSpace&);
 #endif
+#if !USE(CFNETWORK)
+    void didCancelAuthenticationChallenge(const AuthenticationChallenge&);
     NSURLConnection *connection() const;
     WebCoreResourceHandleAsDelegate *delegate();
     void releaseDelegate();
     id releaseProxy();
 #endif
 
-#if PLATFORM(MAC)
     void schedule(SchedulePair*);
     void unschedule(SchedulePair*);
 #endif

Modified: trunk/Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp (91798 => 91799)


--- trunk/Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp	2011-07-26 23:30:52 UTC (rev 91798)
+++ trunk/Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp	2011-07-26 23:43:15 UTC (rev 91799)
@@ -103,6 +103,9 @@
     virtual void didReceiveData(ResourceHandle*, const char*, int, int /*encodedDataLength*/);
     virtual void didFinishLoading(ResourceHandle*, double /*finishTime*/);
     virtual void didFail(ResourceHandle*, const ResourceError&);
+#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
+    virtual bool canAuthenticateAgainstProtectionSpace(ResourceHandle*, const ProtectionSpace&);
+#endif
 
     bool m_allowStoredCredentials;
     ResourceResponse& m_response;
@@ -348,6 +351,21 @@
     handle->didReceiveAuthenticationChallenge(AuthenticationChallenge(challenge, handle));
 }
 
+#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
+static Boolean canRespondToProtectionSpace(CFURLConnectionRef conn, CFURLProtectionSpaceRef protectionSpace, const void* clientInfo)
+{
+#if LOG_DISABLED
+    UNUSED_PARAM(conn);
+#endif
+    ResourceHandle* handle = static_cast<ResourceHandle*>(const_cast<void*>(clientInfo));
+    ASSERT(handle);
+
+    LOG(Network, "CFNet - canRespondToProtectionSpace(conn=%p, handle=%p (%s)", conn, handle, handle->firstRequest().url().string().utf8().data());
+
+    return handle->canAuthenticateAgainstProtectionSpace(core(protectionSpace));
+}
+#endif
+
 ResourceHandleInternal::~ResourceHandleInternal()
 {
     if (m_connection) {
@@ -458,8 +476,8 @@
 
     RetainPtr<CFURLRequestRef> request(AdoptCF, makeFinalRequest(firstRequest(), shouldContentSniff));
 
-#if HAVE(CFNETWORK_DATA_ARRAY_CALLBACK)
-    CFURLConnectionClient_V6 client = { 6, this, 0, 0, 0, WebCore::willSendRequest, didReceiveResponse, didReceiveData, 0, didFinishLoading, didFail, willCacheResponse, didReceiveChallenge, didSendBodyData, shouldUseCredentialStorageCallback, 0, 0, 0, didReceiveDataArray};
+#if HAVE(CFNETWORK_DATA_ARRAY_CALLBACK) && USE(PROTECTION_SPACE_AUTH_CALLBACK)
+    CFURLConnectionClient_V6 client = { 6, this, 0, 0, 0, WebCore::willSendRequest, didReceiveResponse, didReceiveData, 0, didFinishLoading, didFail, willCacheResponse, didReceiveChallenge, didSendBodyData, shouldUseCredentialStorageCallback, 0, canRespondToProtectionSpace, 0, didReceiveDataArray};
 #else
     CFURLConnectionClient_V3 client = { 3, this, 0, 0, 0, WebCore::willSendRequest, didReceiveResponse, didReceiveData, 0, didFinishLoading, didFail, willCacheResponse, didReceiveChallenge, didSendBodyData, shouldUseCredentialStorageCallback, 0};
 #endif
@@ -596,6 +614,16 @@
         client()->didReceiveAuthenticationChallenge(this, d->m_currentWebChallenge);
 }
 
+#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
+bool ResourceHandle::canAuthenticateAgainstProtectionSpace(const ProtectionSpace& protectionSpace)
+{
+    if (client())
+        return client()->canAuthenticateAgainstProtectionSpace(this, protectionSpace);
+
+    return false;
+}
+#endif
+
 void ResourceHandle::receivedCredential(const AuthenticationChallenge& challenge, const Credential& credential)
 {
     LOG(Network, "CFNet - receivedCredential()");
@@ -887,6 +915,14 @@
     return m_allowStoredCredentials;
 }
 
+#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
+bool WebCoreSynchronousLoaderClient::canAuthenticateAgainstProtectionSpace(ResourceHandle*, const ProtectionSpace&)
+{
+    // FIXME: We should ask FrameLoaderClient. <http://webkit.org/b/65196>
+    return true;
+}
+#endif
+
 #endif // USE(CFNETWORK)
 
 #if HAVE(CFNETWORK_DATA_ARRAY_CALLBACK)

Modified: trunk/Source/WebCore/platform/network/mac/ResourceHandleMac.mm (91798 => 91799)


--- trunk/Source/WebCore/platform/network/mac/ResourceHandleMac.mm	2011-07-26 23:30:52 UTC (rev 91798)
+++ trunk/Source/WebCore/platform/network/mac/ResourceHandleMac.mm	2011-07-26 23:43:15 UTC (rev 91799)
@@ -765,13 +765,17 @@
 }
 
 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
-- (BOOL)connection:(NSURLConnection *)unusedConnection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace
+- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace
 {
-    UNUSED_PARAM(unusedConnection);
-    
+#if LOG_DISABLED
+    UNUSED_PARAM(connection);
+#endif
+
+    LOG(Network, "Handle %p delegate connection:%p canAuthenticateAgainstProtectionSpace:%p", m_handle, connection);
+
     if (!m_handle)
         return NO;
-        
+
     return m_handle->canAuthenticateAgainstProtectionSpace(core(protectionSpace));
 }
 #endif
@@ -951,7 +955,7 @@
 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
 bool WebCoreSynchronousLoaderClient::canAuthenticateAgainstProtectionSpace(ResourceHandle*, const ProtectionSpace&)
 {
-    // FIXME: We should ask FrameLoaderClient.
+    // FIXME: We should ask FrameLoaderClient. <http://webkit.org/b/65196>
     return true;
 }
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to