Reviewed by Steve.
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Sep 2007 21:36:03 +0000 (21:36 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Sep 2007 21:36:03 +0000 (21:36 +0000)
        - fix <rdar://problem/5095701> Download requring HTTP auth fails
          (progress bar forever)

        The functions in WebDownload relating to authentication challenges needed
        to be implemented.

        * WebDownload.cpp:
        (WebDownload::cancelAuthenticationChallenge): Implement.
        (WebDownload::continueWithoutCredentialForAuthenticationChallenge): Ditto.
        (WebDownload::useCredential): Ditto.
        (WebDownload::willSendRequest): Fix storage leak by adopting request
        and response after creating them. Also retain the result before returning
        it, since that's the API contract with CFNetwork.
        (WebDownload::didReceiveAuthenticationChallenge): Implement.
        (WebDownload::didReceiveResponse): Fix storage leak by adopting response.
        (WebDownload::willResumeWithResponse): Ditto.
        (WebDownload::didFail): Ditto.

        * WebURLAuthenticationChallenge.h: Get rid of the IID #define,
        instead using __declspec(uuid). Added a sender parameter to the
        create function and an m_sender data member.
        * WebURLAuthenticationChallenge.cpp:
        (WebURLAuthenticationChallenge::WebURLAuthenticationChallenge): Added an
        explicit sender parameter so this can be used with a WebDownload, which
        does not involve a ResourceHandle. Later we should clean this up and not
        involve WebCore or ResourceHandle directly even for the non-download case.
        (WebURLAuthenticationChallenge::createInstance): Added an overload for the
        case with an explicit sender parameter.
        (WebURLAuthenticationChallenge::QueryInterface): Use __uuidof for the ID
        of this class. In general, we should move to __uuidof as much as possible
        and keep the separate macros to a minimum -- but we should do this for all
        uses of each class at one time to make sure we don't run into problems
        with two different UUIDs for the same class. This patch does it for three
        classes.
        (WebURLAuthenticationChallenge::initWithProtectionSpace): Use the query
        constructor instead of an explicit QueryInterface for WebURLCredential.
        This is another class where I'm switching from CLSID/IID macros to the
        use of __uuidof, but in this case the use of __uuidof is implicit.
        (WebURLAuthenticationChallenge::initWithAuthenticationChallenge): Ditto,
        but for WebURLAuthenticationChallenge and WebURLAuthenticationChallengeSender.
        (WebURLAuthenticationChallenge::sender): Use the new m_sender member to
        cache the sender object and also use the one that was passed into the
        constructor, if any.

        * WebURLAuthenticationChallengeSender.h: Get rid of the IID #define,
        instead using __declspec(uuid). Also minimize includes and make data
        members private instead of protected.
        * WebURLAuthenticationChallengeSender.cpp:
        (WebURLAuthenticationChallengeSender::QueryInterface): Use __uuidof instead
        of IID macro.
        (WebURLAuthenticationChallengeSender::cancelAuthenticationChallenge):
        Use query constructor instead of QueryInterface.
        (WebURLAuthenticationChallengeSender::continueWithoutCredentialForAuthenticationChallenge):
        Ditto.
        (WebURLAuthenticationChallengeSender::useCredential): Ditto.

        * WebURLCredential.cpp: (WebURLCredential::QueryInterface): Use __uuidof
        instead of CLSID_WebURLCredential.

        - tangentially-related cleanup

        * WebFrame.cpp:
        (WebFrame::dispatchDidReceiveAuthenticationChallenge): Use the adopt
        constructor instead of a separate adoptRef call.
        (WebFrame::dispatchDidCancelAuthenticationChallenge): Ditto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@25716 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/win/ChangeLog
WebKit/win/WebDownload.cpp
WebKit/win/WebFrame.cpp
WebKit/win/WebURLAuthenticationChallenge.cpp
WebKit/win/WebURLAuthenticationChallenge.h
WebKit/win/WebURLAuthenticationChallengeSender.cpp
WebKit/win/WebURLAuthenticationChallengeSender.h
WebKit/win/WebURLCredential.cpp

index d318597..e8cb58a 100644 (file)
@@ -1,3 +1,73 @@
+2007-09-25  Darin Adler  <darin@apple.com>
+
+        Reviewed by Steve.
+
+        - fix <rdar://problem/5095701> Download requring HTTP auth fails
+          (progress bar forever)
+
+        The functions in WebDownload relating to authentication challenges needed
+        to be implemented.
+
+        * WebDownload.cpp:
+        (WebDownload::cancelAuthenticationChallenge): Implement.
+        (WebDownload::continueWithoutCredentialForAuthenticationChallenge): Ditto.
+        (WebDownload::useCredential): Ditto.
+        (WebDownload::willSendRequest): Fix storage leak by adopting request
+        and response after creating them. Also retain the result before returning
+        it, since that's the API contract with CFNetwork.
+        (WebDownload::didReceiveAuthenticationChallenge): Implement.
+        (WebDownload::didReceiveResponse): Fix storage leak by adopting response.
+        (WebDownload::willResumeWithResponse): Ditto.
+        (WebDownload::didFail): Ditto.
+
+        * WebURLAuthenticationChallenge.h: Get rid of the IID #define,
+        instead using __declspec(uuid). Added a sender parameter to the
+        create function and an m_sender data member.
+        * WebURLAuthenticationChallenge.cpp:
+        (WebURLAuthenticationChallenge::WebURLAuthenticationChallenge): Added an
+        explicit sender parameter so this can be used with a WebDownload, which
+        does not involve a ResourceHandle. Later we should clean this up and not
+        involve WebCore or ResourceHandle directly even for the non-download case.
+        (WebURLAuthenticationChallenge::createInstance): Added an overload for the
+        case with an explicit sender parameter.
+        (WebURLAuthenticationChallenge::QueryInterface): Use __uuidof for the ID
+        of this class. In general, we should move to __uuidof as much as possible
+        and keep the separate macros to a minimum -- but we should do this for all
+        uses of each class at one time to make sure we don't run into problems
+        with two different UUIDs for the same class. This patch does it for three
+        classes.
+        (WebURLAuthenticationChallenge::initWithProtectionSpace): Use the query
+        constructor instead of an explicit QueryInterface for WebURLCredential.
+        This is another class where I'm switching from CLSID/IID macros to the
+        use of __uuidof, but in this case the use of __uuidof is implicit.
+        (WebURLAuthenticationChallenge::initWithAuthenticationChallenge): Ditto,
+        but for WebURLAuthenticationChallenge and WebURLAuthenticationChallengeSender.
+        (WebURLAuthenticationChallenge::sender): Use the new m_sender member to
+        cache the sender object and also use the one that was passed into the
+        constructor, if any.
+
+        * WebURLAuthenticationChallengeSender.h: Get rid of the IID #define,
+        instead using __declspec(uuid). Also minimize includes and make data
+        members private instead of protected.
+        * WebURLAuthenticationChallengeSender.cpp:
+        (WebURLAuthenticationChallengeSender::QueryInterface): Use __uuidof instead
+        of IID macro.
+        (WebURLAuthenticationChallengeSender::cancelAuthenticationChallenge):
+        Use query constructor instead of QueryInterface.
+        (WebURLAuthenticationChallengeSender::continueWithoutCredentialForAuthenticationChallenge):
+        Ditto.
+        (WebURLAuthenticationChallengeSender::useCredential): Ditto.
+
+        * WebURLCredential.cpp: (WebURLCredential::QueryInterface): Use __uuidof
+        instead of CLSID_WebURLCredential.
+
+        - tangentially-related cleanup
+
+        * WebFrame.cpp:
+        (WebFrame::dispatchDidReceiveAuthenticationChallenge): Use the adopt
+        constructor instead of a separate adoptRef call.
+        (WebFrame::dispatchDidCancelAuthenticationChallenge): Ditto.
+
 2007-09-24  Brady Eidson  <beidson@apple.com>
 
         Reviewed by John Sullivan
index 2576bab..f51a6a1 100644 (file)
@@ -22,6 +22,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
+
 #include "config.h"
 #include "WebKitDLL.h"
 #include "WebDownload.h"
@@ -32,6 +33,8 @@
 #include "WebKit.h"
 #include "WebKitLogging.h"
 #include "WebMutableURLRequest.h"
+#include "WebURLAuthenticationChallenge.h"
+#include "WebURLCredential.h"
 #include "WebURLResponse.h"
 
 #include <io.h>
@@ -39,6 +42,7 @@
 #include <sys/types.h>
 
 #pragma warning(push, 0)
+#include <WebCore/AuthenticationCF.h>
 #include <WebCore/BString.h>
 #include <WebCore/NotImplemented.h>
 #include <WebCore/ResourceError.h>
@@ -403,9 +407,7 @@ HRESULT STDMETHODCALLTYPE WebDownload::setDestination(
     CFURLDownloadSetDestination(m_download.get(), pathURL, !!allowOverwrite);
     CFRelease(pathURL);
 
-#ifndef NDEBUG
     LOG(Download, "WebDownload - Set destination to %s", m_bundlePath.ascii().data());
-#endif
 
     return S_OK;
 }
@@ -415,23 +417,48 @@ HRESULT STDMETHODCALLTYPE WebDownload::setDestination(
 HRESULT STDMETHODCALLTYPE WebDownload::cancelAuthenticationChallenge(
         /* [in] */ IWebURLAuthenticationChallenge*)
 {
-    notImplemented();
-    return E_FAIL;
+    if (m_download) {
+        CFURLDownloadCancel(m_download.get());
+        m_download = 0;
+    }
+
+    // FIXME: Do we need a URL or description for this error code?
+    ResourceError error(String(WebURLErrorDomain), WebURLErrorUserCancelledAuthentication, "", "");
+    COMPtr<WebError> webError(AdoptCOM, WebError::createInstance(error));
+    m_delegate->didFailWithError(this, webError.get());
+
+    return S_OK;
 }
 
 HRESULT STDMETHODCALLTYPE WebDownload::continueWithoutCredentialForAuthenticationChallenge(
-        /* [in] */ IWebURLAuthenticationChallenge*)
+        /* [in] */ IWebURLAuthenticationChallenge* challenge)
 {
-    notImplemented();
-    return E_FAIL;
+    COMPtr<WebURLAuthenticationChallenge> webChallenge(Query, challenge);
+    if (!webChallenge)
+        return E_NOINTERFACE;
+
+    if (m_download)
+        CFURLDownloadUseCredential(m_download.get(), 0, webChallenge->authenticationChallenge().cfURLAuthChallengeRef());
+    return S_OK;
 }
 
 HRESULT STDMETHODCALLTYPE WebDownload::useCredential(
-        /* [in] */ IWebURLCredential*, 
-        /* [in] */ IWebURLAuthenticationChallenge*)
+        /* [in] */ IWebURLCredential* credential
+        /* [in] */ IWebURLAuthenticationChallenge* challenge)
 {
-    notImplemented();
-    return E_FAIL;
+    COMPtr<WebURLAuthenticationChallenge> webChallenge(Query, challenge);
+    if (!webChallenge)
+        return E_NOINTERFACE;
+
+    COMPtr<WebURLCredential> webCredential(Query, credential);
+    if (!webCredential)
+        return E_NOINTERFACE;
+
+    RetainPtr<CFURLCredentialRef> cfCredential(AdoptCF, createCF(webCredential->credential()));
+
+    if (m_download)
+        CFURLDownloadUseCredential(m_download.get(), cfCredential.get(), webChallenge->authenticationChallenge().cfURLAuthChallengeRef());
+    return S_OK;
 }
 
 // CFURLDownload Callbacks -------------------------------------------------------------------
@@ -448,8 +475,8 @@ void WebDownload::didStart()
 
 CFURLRequestRef WebDownload::willSendRequest(CFURLRequestRef request, CFURLResponseRef response)
 {
-    COMPtr<WebMutableURLRequest> webRequest = WebMutableURLRequest::createInstance(ResourceRequest(request));
-    COMPtr<WebURLResponse> webResponse = WebURLResponse::createInstance(ResourceResponse(response));
+    COMPtr<WebMutableURLRequest> webRequest(AdoptCOM, WebMutableURLRequest::createInstance(ResourceRequest(request)));
+    COMPtr<WebURLResponse> webResponse(AdoptCOM, WebURLResponse::createInstance(ResourceResponse(response)));
     COMPtr<IWebMutableURLRequest> finalRequest;
 
     if (FAILED(m_delegate->willSendRequest(this, webRequest.get(), webResponse.get(), &finalRequest)))
@@ -458,26 +485,34 @@ CFURLRequestRef WebDownload::willSendRequest(CFURLRequestRef request, CFURLRespo
     if (!finalRequest)
         return 0;
 
-    COMPtr<WebMutableURLRequest> finalWebRequest = WebMutableURLRequest::createInstance(finalRequest.get());
+    COMPtr<WebMutableURLRequest> finalWebRequest(AdoptCOM, WebMutableURLRequest::createInstance(finalRequest.get()));
     m_request = finalWebRequest.get();
-    return finalWebRequest->resourceRequest().cfURLRequest();
+    CFURLRequestRef result = finalWebRequest->resourceRequest().cfURLRequest();
+    CFRetain(result);
+    return result;
 }
 
-void WebDownload::didReceiveAuthenticationChallenge(CFURLAuthChallengeRef )
+void WebDownload::didReceiveAuthenticationChallenge(CFURLAuthChallengeRef challenge)
 {
-    notImplemented();
+    COMPtr<IWebURLAuthenticationChallenge> webChallenge(AdoptCOM,
+        WebURLAuthenticationChallenge::createInstance(AuthenticationChallenge(challenge, 0), this));
+
+    if (SUCCEEDED(m_delegate->didReceiveAuthenticationChallenge(this, webChallenge.get())))
+        return;
+
+    cancelAuthenticationChallenge(webChallenge.get());
 }
 
 void WebDownload::didReceiveResponse(CFURLResponseRef response)
 {
-    COMPtr<WebURLResponse> webResponse = WebURLResponse::createInstance(ResourceResponse(response));
+    COMPtr<WebURLResponse> webResponse(AdoptCOM, WebURLResponse::createInstance(ResourceResponse(response)));
     if (FAILED(m_delegate->didReceiveResponse(this, webResponse.get())))
         LOG_ERROR("DownloadDelegate->didReceiveResponse failed");
 }
 
 void WebDownload::willResumeWithResponse(CFURLResponseRef response, UInt64 fromByte)
 {
-    COMPtr<WebURLResponse> webResponse = WebURLResponse::createInstance(ResourceResponse(response));
+    COMPtr<WebURLResponse> webResponse(AdoptCOM, WebURLResponse::createInstance(ResourceResponse(response)));
     if (FAILED(m_delegate->willResumeWithResponse(this, webResponse.get(), fromByte)))
         LOG_ERROR("DownloadDelegate->willResumeWithResponse failed");
 }
@@ -576,7 +611,7 @@ void WebDownload::didFinish()
 
 void WebDownload::didFail(CFErrorRef error)
 {
-    COMPtr<WebError> webError = WebError::createInstance(ResourceError(error));
+    COMPtr<WebError> webError(AdoptCOM, WebError::createInstance(ResourceError(error)));
     if (FAILED(m_delegate->didFailWithError(this, webError.get())))
         LOG_ERROR("DownloadDelegate->didFailWithError failed");
 }
index d29124c..8ff2178 100644 (file)
@@ -2209,8 +2209,7 @@ void WebFrame::dispatchDidReceiveAuthenticationChallenge(DocumentLoader* loader,
 
     COMPtr<IWebResourceLoadDelegate> resourceLoadDelegate;
     if (SUCCEEDED(d->webView->resourceLoadDelegate(&resourceLoadDelegate))) {
-        COMPtr<IWebURLAuthenticationChallenge> webChallenge;
-        webChallenge.adoptRef(WebURLAuthenticationChallenge::createInstance(challenge));
+        COMPtr<IWebURLAuthenticationChallenge> webChallenge(AdoptCOM, WebURLAuthenticationChallenge::createInstance(challenge));
 
         if (SUCCEEDED(resourceLoadDelegate->didReceiveAuthenticationChallenge(d->webView, identifier, webChallenge.get(), getWebDataSource(loader))))
             return;
@@ -2225,8 +2224,7 @@ void WebFrame::dispatchDidCancelAuthenticationChallenge(DocumentLoader* loader,
 {
     COMPtr<IWebResourceLoadDelegate> resourceLoadDelegate;
     if (SUCCEEDED(d->webView->resourceLoadDelegate(&resourceLoadDelegate))) {
-        COMPtr<IWebURLAuthenticationChallenge> webChallenge;
-        webChallenge.adoptRef(WebURLAuthenticationChallenge::createInstance(challenge));
+        COMPtr<IWebURLAuthenticationChallenge> webChallenge(AdoptCOM, WebURLAuthenticationChallenge::createInstance(challenge));
 
         if (SUCCEEDED(resourceLoadDelegate->didCancelAuthenticationChallenge(d->webView, identifier, webChallenge.get(), getWebDataSource(loader))))
             return;
index 04cabe5..dde81c8 100644 (file)
@@ -46,9 +46,11 @@ using namespace WebCore;
 
 // WebURLAuthenticationChallenge ----------------------------------------------------------------
 
-WebURLAuthenticationChallenge::WebURLAuthenticationChallenge(const AuthenticationChallenge& authenticationChallenge)
+WebURLAuthenticationChallenge::WebURLAuthenticationChallenge(const AuthenticationChallenge& authenticationChallenge,
+                                                             IWebURLAuthenticationChallengeSender* sender)
     : m_refCount(0)
     , m_authenticationChallenge(authenticationChallenge)
+    , m_sender(sender)
 {
     gClassCount++;
 }
@@ -58,16 +60,17 @@ WebURLAuthenticationChallenge::~WebURLAuthenticationChallenge()
     gClassCount--;
 }
 
-WebURLAuthenticationChallenge* WebURLAuthenticationChallenge::createInstance()
+WebURLAuthenticationChallenge* WebURLAuthenticationChallenge::createInstance(const AuthenticationChallenge& authenticationChallenge)
 {
-    WebURLAuthenticationChallenge* instance = new WebURLAuthenticationChallenge(AuthenticationChallenge());
+    WebURLAuthenticationChallenge* instance = new WebURLAuthenticationChallenge(authenticationChallenge, 0);
     instance->AddRef();
     return instance;
 }
 
-WebURLAuthenticationChallenge* WebURLAuthenticationChallenge::createInstance(const AuthenticationChallenge& authenticationChallenge)
+WebURLAuthenticationChallenge* WebURLAuthenticationChallenge::createInstance(const AuthenticationChallenge& authenticationChallenge,
+                                                                             IWebURLAuthenticationChallengeSender* sender)
 {
-    WebURLAuthenticationChallenge* instance = new WebURLAuthenticationChallenge(authenticationChallenge);
+    WebURLAuthenticationChallenge* instance = new WebURLAuthenticationChallenge(authenticationChallenge, sender);
     instance->AddRef();
     return instance;
 }
@@ -79,7 +82,7 @@ HRESULT STDMETHODCALLTYPE WebURLAuthenticationChallenge::QueryInterface(REFIID r
     *ppvObject = 0;
     if (IsEqualGUID(riid, IID_IUnknown))
         *ppvObject = static_cast<IUnknown*>(this);
-    else if (IsEqualGUID(riid, IID_WebURLAuthenticationChallenge))
+    else if (IsEqualGUID(riid, __uuidof(WebURLAuthenticationChallenge)))
         *ppvObject = static_cast<WebURLAuthenticationChallenge*>(this);
     else if (IsEqualGUID(riid, IID_IWebURLAuthenticationChallenge))
         *ppvObject = static_cast<IWebURLAuthenticationChallenge*>(this);
@@ -125,10 +128,9 @@ HRESULT STDMETHODCALLTYPE WebURLAuthenticationChallenge::initWithProtectionSpace
     if (FAILED(hr))
         return hr;
 
-    COMPtr<WebURLCredential> webCredential;
-    hr = proposedCredential->QueryInterface(CLSID_WebURLCredential, (void**)&webCredential);
-    if (FAILED(hr))
-        return hr;
+    COMPtr<WebURLCredential> webCredential(Query, proposedCredential);
+    if (!webCredential)
+        return E_NOINTERFACE;
 
     COMPtr<WebURLResponse> webResponse;
     hr = failureResponse->QueryInterface(IID_WebURLResponse, (void**)&webResponse);
@@ -140,10 +142,9 @@ HRESULT STDMETHODCALLTYPE WebURLAuthenticationChallenge::initWithProtectionSpace
     if (FAILED(hr))
         return hr;
     
-    COMPtr<WebURLAuthenticationChallengeSender> webSender;
-    hr = sender->QueryInterface(IID_WebURLAuthenticationChallengeSender, (void**)&webSender);
-    if (FAILED(hr))
-        return hr;
+    COMPtr<WebURLAuthenticationChallengeSender> webSender(Query, sender);
+    if (!webSender)
+        return E_NOINTERFACE;
 
     // FIXME: After we change AuthenticationChallenge to use "ResourceHandle" as the abstract "Sender" or "Source of this Auth Challenge", then we'll
     // construct the AuthenticationChallenge with that as obtained from the webSender
@@ -160,17 +161,13 @@ HRESULT STDMETHODCALLTYPE WebURLAuthenticationChallenge::initWithAuthenticationC
     if (!challenge || !sender)
         return E_POINTER;
 
-    HRESULT hr = S_OK;
-
-    COMPtr<WebURLAuthenticationChallenge> webChallenge;
-    hr = challenge->QueryInterface(IID_WebURLAuthenticationChallenge, (void**)&webChallenge);
-    if (FAILED(hr))
-        return hr;
+    COMPtr<WebURLAuthenticationChallenge> webChallenge(Query, challenge);
+    if (!webChallenge)
+        return E_NOINTERFACE;
 
-    COMPtr<WebURLAuthenticationChallengeSender> webSender;
-    hr = sender->QueryInterface(IID_WebURLAuthenticationChallengeSender, (void**)&webSender);
-    if (FAILED(hr))
-        return hr;
+    COMPtr<WebURLAuthenticationChallengeSender> webSender(Query, sender);
+    if (!webSender)
+        return E_NOINTERFACE;
 
     m_authenticationChallenge = AuthenticationChallenge(webChallenge->authenticationChallenge().cfURLAuthChallengeRef(), webSender->resourceHandle());
 
@@ -215,10 +212,12 @@ HRESULT STDMETHODCALLTYPE WebURLAuthenticationChallenge::protectionSpace(
 HRESULT STDMETHODCALLTYPE WebURLAuthenticationChallenge::sender(
     /* [out, retval] */ IWebURLAuthenticationChallengeSender** sender)
 {
-    ResourceHandle* handle = m_authenticationChallenge.sourceHandle();
-    *sender = WebURLAuthenticationChallengeSender::createInstance(handle);
+    if (!m_sender) {
+        ResourceHandle* handle = m_authenticationChallenge.sourceHandle();
+        m_sender.adoptRef(WebURLAuthenticationChallengeSender::createInstance(handle));
+    }
 
-    return S_OK;
+    return m_sender.copyRefTo(sender);
 }
 
 // WebURLAuthenticationChallenge -------------------------------------------------------------------
index f667540..8463e6e 100644 (file)
 
 #pragma warning(push, 0)
 #include <WebCore/AuthenticationChallenge.h>
+#include <WebCore/COMPtr.h>
 #pragma warning(pop)
 
-// {FD3B2381-0BB6-4b59-AF09-0E599C8901CF}
-DEFINE_GUID(IID_WebURLAuthenticationChallenge, 0xfd3b2381, 0xbb6, 0x4b59, 0xaf, 0x9, 0xe, 0x59, 0x9c, 0x89, 0x1, 0xcf);
-
-class WebURLAuthenticationChallenge : public IWebURLAuthenticationChallenge
-{
+class __declspec(uuid("FD3B2381-0BB6-4B59-AF09-0E599C8901CF")) WebURLAuthenticationChallenge : public IWebURLAuthenticationChallenge {
 public:
-    static WebURLAuthenticationChallenge* createInstance();
     static WebURLAuthenticationChallenge* createInstance(const WebCore::AuthenticationChallenge&);
+    static WebURLAuthenticationChallenge* createInstance(const WebCore::AuthenticationChallenge&, IWebURLAuthenticationChallengeSender*);
 private:
-    WebURLAuthenticationChallenge(const WebCore::AuthenticationChallenge&);
+    WebURLAuthenticationChallenge(const WebCore::AuthenticationChallenge&, IWebURLAuthenticationChallengeSender*);
     ~WebURLAuthenticationChallenge();
 public:
     // IUnknown
@@ -87,6 +84,7 @@ protected:
     ULONG m_refCount;
 
     WebCore::AuthenticationChallenge m_authenticationChallenge;
+    COMPtr<IWebURLAuthenticationChallengeSender> m_sender;
 };
 
 
index 40d6172..57d9576 100644 (file)
@@ -68,7 +68,7 @@ HRESULT STDMETHODCALLTYPE WebURLAuthenticationChallengeSender::QueryInterface(RE
     *ppvObject = 0;
     if (IsEqualGUID(riid, IID_IUnknown))
         *ppvObject = static_cast<IUnknown*>(this);
-    else if (IsEqualGUID(riid, IID_WebURLAuthenticationChallengeSender))
+    else if (IsEqualGUID(riid, __uuidof(WebURLAuthenticationChallengeSender)))
         *ppvObject = static_cast<WebURLAuthenticationChallengeSender*>(this);
     else if (IsEqualGUID(riid, IID_IWebURLAuthenticationChallengeSender))
         *ppvObject = static_cast<IWebURLAuthenticationChallengeSender*>(this);
@@ -98,8 +98,8 @@ ULONG STDMETHODCALLTYPE WebURLAuthenticationChallengeSender::Release(void)
 HRESULT STDMETHODCALLTYPE WebURLAuthenticationChallengeSender::cancelAuthenticationChallenge(
         /* [in] */ IWebURLAuthenticationChallenge* challenge)
 {
-    COMPtr<WebURLAuthenticationChallenge> webChallenge;
-    if (!challenge || FAILED(challenge->QueryInterface(IID_WebURLAuthenticationChallenge, (void**)&webChallenge)))
+    COMPtr<WebURLAuthenticationChallenge> webChallenge(Query, challenge);
+    if (!webChallenge)
         return E_FAIL;
 
     m_handle->receivedCancellation(webChallenge->authenticationChallenge());
@@ -109,8 +109,8 @@ HRESULT STDMETHODCALLTYPE WebURLAuthenticationChallengeSender::cancelAuthenticat
 HRESULT STDMETHODCALLTYPE WebURLAuthenticationChallengeSender::continueWithoutCredentialForAuthenticationChallenge(
         /* [in] */ IWebURLAuthenticationChallenge* challenge)
 {
-    COMPtr<WebURLAuthenticationChallenge> webChallenge;
-    if (!challenge || FAILED(challenge->QueryInterface(IID_WebURLAuthenticationChallenge, (void**)&webChallenge)))
+    COMPtr<WebURLAuthenticationChallenge> webChallenge(Query, challenge);
+    if (!webChallenge)
         return E_FAIL;
 
     m_handle->receivedRequestToContinueWithoutCredential(webChallenge->authenticationChallenge());
@@ -121,12 +121,12 @@ HRESULT STDMETHODCALLTYPE WebURLAuthenticationChallengeSender::useCredential(
         /* [in] */ IWebURLCredential* credential, 
         /* [in] */ IWebURLAuthenticationChallenge* challenge)
 {
-    COMPtr<WebURLAuthenticationChallenge> webChallenge;
-    if (!challenge || FAILED(challenge->QueryInterface(IID_WebURLAuthenticationChallenge, (void**)&webChallenge)))
+    COMPtr<WebURLAuthenticationChallenge> webChallenge(Query, challenge);
+    if (!webChallenge)
         return E_FAIL;
     
     COMPtr<WebURLCredential> webCredential;
-    if (!credential || FAILED(credential->QueryInterface(CLSID_WebURLCredential, (void**)&webCredential)))
+    if (!credential || FAILED(credential->QueryInterface(__uuidof(WebURLCredential), (void**)&webCredential)))
         return E_FAIL;
 
     m_handle->receivedCredential(webChallenge->authenticationChallenge(), webCredential->credential());
index 01af22f..25235c3 100644 (file)
 
 #include "IWebURLAuthenticationChallenge.h"
 
-#include <wtf/PassRefPtr.h>
+#include <wtf/Forward.h>
 #include <wtf/RefPtr.h>
 
-
 namespace WebCore {
     class ResourceHandle;
-};
-
-// {5CACD637-F82F-491f-947A-5DCA38AA0FEA}
-DEFINE_GUID(IID_WebURLAuthenticationChallengeSender, 0x5cacd637, 0xf82f, 0x491f, 0x94, 0x7a, 0x5d, 0xca, 0x38, 0xaa, 0xf, 0xea);
+}
 
-class WebURLAuthenticationChallengeSender : public IWebURLAuthenticationChallengeSender
+class __declspec(uuid("5CACD637-F82F-491F-947A-5DCA38AA0FEA")) WebURLAuthenticationChallengeSender
+    : public IWebURLAuthenticationChallengeSender
 {
 public:
     static WebURLAuthenticationChallengeSender* createInstance(PassRefPtr<WebCore::ResourceHandle>);
@@ -64,11 +61,11 @@ public:
         /* [in] */ IWebURLAuthenticationChallenge* challenge);
 
     WebCore::ResourceHandle* resourceHandle() const;
-protected:
+
+private:
     ULONG m_refCount;
 
     RefPtr<WebCore::ResourceHandle> m_handle;
 };
 
-
 #endif
index 95e945d..a6cc35c 100644 (file)
@@ -69,7 +69,7 @@ HRESULT STDMETHODCALLTYPE WebURLCredential::QueryInterface(REFIID riid, void** p
     *ppvObject = 0;
     if (IsEqualGUID(riid, IID_IUnknown))
         *ppvObject = static_cast<IUnknown*>(this);
-    else if (IsEqualGUID(riid, CLSID_WebURLCredential))
+    else if (IsEqualGUID(riid, __uuidof(WebURLCredential)))
         *ppvObject = static_cast<WebURLCredential*>(this);
     else if (IsEqualGUID(riid, IID_IWebURLCredential))
         *ppvObject = static_cast<IWebURLCredential*>(this);