1563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark/*
2563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * Copyright (C) 2007 Apple Inc.  All rights reserved.
3563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark *
4563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * Redistribution and use in source and binary forms, with or without
5563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * modification, are permitted provided that the following conditions
6563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * are met:
7563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark *
8563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * 1.  Redistributions of source code must retain the above copyright
9563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark *     notice, this list of conditions and the following disclaimer.
10563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * 2.  Redistributions in binary form must reproduce the above copyright
11563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark *     notice, this list of conditions and the following disclaimer in the
12563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark *     documentation and/or other materials provided with the distribution.
13563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark *     its contributors may be used to endorse or promote products derived
15563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark *     from this software without specific prior written permission.
16563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark *
17563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark */
28563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
29563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark#ifndef ResourceLoadDelegate_h
30563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark#define ResourceLoadDelegate_h
31563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
32563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark#include <WebKit/WebKit.h>
3328040489d744e0c5d475a88663056c9040ed5320Teng-Hui Zhu#include <string>
3428040489d744e0c5d475a88663056c9040ed5320Teng-Hui Zhu#include <wtf/HashMap.h>
35563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
3628040489d744e0c5d475a88663056c9040ed5320Teng-Hui Zhuclass ResourceLoadDelegate : public IWebResourceLoadDelegate, public IWebResourceLoadDelegatePrivate2 {
37563af33bc48281d19dce701398dbb88cb54fd7ecCary Clarkpublic:
38563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    ResourceLoadDelegate();
39563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    virtual ~ResourceLoadDelegate();
40563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
41563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    // IUnknown
42563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
43563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    virtual ULONG STDMETHODCALLTYPE AddRef(void);
44563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    virtual ULONG STDMETHODCALLTYPE Release(void);
45563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
46563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    // IWebResourceLoadDelegate
47563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    virtual HRESULT STDMETHODCALLTYPE identifierForInitialRequest(
48563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [in] */ IWebView *webView,
49563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [in] */ IWebURLRequest *request,
50563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [in] */ IWebDataSource *dataSource,
51563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [in] */ unsigned long identifier);
52563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
53563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    virtual HRESULT STDMETHODCALLTYPE willSendRequest(
54563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [in] */ IWebView *webView,
55563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [in] */ unsigned long identifier,
56563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [in] */ IWebURLRequest *request,
57563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [in] */ IWebURLResponse *redirectResponse,
58563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [in] */ IWebDataSource *dataSource,
59563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [retval][out] */ IWebURLRequest **newRequest);
60563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
61563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    virtual HRESULT STDMETHODCALLTYPE didReceiveAuthenticationChallenge(
62563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [in] */ IWebView *webView,
63563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [in] */ unsigned long identifier,
64563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [in] */ IWebURLAuthenticationChallenge *challenge,
65231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block        /* [in] */ IWebDataSource *dataSource);
66563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
67563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    virtual HRESULT STDMETHODCALLTYPE didCancelAuthenticationChallenge(
68563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [in] */ IWebView *webView,
69563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [in] */ unsigned long identifier,
70563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [in] */ IWebURLAuthenticationChallenge *challenge,
71563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [in] */ IWebDataSource *dataSource) { return E_NOTIMPL; }
72563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
73563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    virtual HRESULT STDMETHODCALLTYPE didReceiveResponse(
74563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [in] */ IWebView *webView,
75563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [in] */ unsigned long identifier,
76563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [in] */ IWebURLResponse *response,
770bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5Ben Murdoch        /* [in] */ IWebDataSource *dataSource);
78563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
79563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    virtual HRESULT STDMETHODCALLTYPE didReceiveContentLength(
80563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [in] */ IWebView *webView,
81563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [in] */ unsigned long identifier,
82563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [in] */ UINT length,
83563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [in] */ IWebDataSource *dataSource) { return E_NOTIMPL; }
84563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
85563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    virtual HRESULT STDMETHODCALLTYPE didFinishLoadingFromDataSource(
86563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [in] */ IWebView *webView,
87563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [in] */ unsigned long identifier,
88563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [in] */ IWebDataSource *dataSource);
89563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
90563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    virtual HRESULT STDMETHODCALLTYPE didFailLoadingWithError(
91563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [in] */ IWebView *webView,
92563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [in] */ unsigned long identifier,
93563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [in] */ IWebError *error,
94563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [in] */ IWebDataSource *dataSource);
95563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
96563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    virtual HRESULT STDMETHODCALLTYPE plugInFailedWithError(
97563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [in] */ IWebView *webView,
98563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [in] */ IWebError *error,
99563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        /* [in] */ IWebDataSource *dataSource) { return E_NOTIMPL; }
10028040489d744e0c5d475a88663056c9040ed5320Teng-Hui Zhu
10128040489d744e0c5d475a88663056c9040ed5320Teng-Hui Zhu    // IWebResourceLoadDelegatePrivate2
10228040489d744e0c5d475a88663056c9040ed5320Teng-Hui Zhu    virtual HRESULT STDMETHODCALLTYPE removeIdentifierForRequest(
10328040489d744e0c5d475a88663056c9040ed5320Teng-Hui Zhu        /* [in] */ IWebView *webView,
10428040489d744e0c5d475a88663056c9040ed5320Teng-Hui Zhu        /* [in] */ unsigned long identifier);
105563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
10628040489d744e0c5d475a88663056c9040ed5320Teng-Hui Zhuprivate:
10728040489d744e0c5d475a88663056c9040ed5320Teng-Hui Zhu    static std::wstring descriptionSuitableForTestResult(IWebURLRequest*);
10828040489d744e0c5d475a88663056c9040ed5320Teng-Hui Zhu    static std::wstring descriptionSuitableForTestResult(IWebURLResponse*);
10928040489d744e0c5d475a88663056c9040ed5320Teng-Hui Zhu    std::wstring descriptionSuitableForTestResult(unsigned long) const;
11028040489d744e0c5d475a88663056c9040ed5320Teng-Hui Zhu    std::wstring descriptionSuitableForTestResult(IWebError*, unsigned long) const;
11128040489d744e0c5d475a88663056c9040ed5320Teng-Hui Zhu
11228040489d744e0c5d475a88663056c9040ed5320Teng-Hui Zhu    typedef HashMap<unsigned long, std::wstring> IdentifierMap;
11328040489d744e0c5d475a88663056c9040ed5320Teng-Hui Zhu    IdentifierMap& urlMap() { return m_urlMap; }
11428040489d744e0c5d475a88663056c9040ed5320Teng-Hui Zhu    IdentifierMap m_urlMap;
11528040489d744e0c5d475a88663056c9040ed5320Teng-Hui Zhu
116563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    ULONG m_refCount;
117563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark};
118563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
119563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark#endif // ResourceLoadDelegate_h
120