1/*
2 * Copyright (C) 2006, 2007, 2008 Apple Inc.  All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 *    notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 *    notice, this list of conditions and the following disclaimer in the
11 *    documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#ifndef DO_NO_IMPORTS
27import "oaidl.idl";
28import "ocidl.idl";
29import "IWebURLAuthenticationChallenge.idl";
30import "IWebDataSource.idl";
31import "IWebURLResponse.idl";
32import "IWebError.idl";
33#endif
34
35interface IWebView;
36interface IWebDataSource;
37interface IWebURLAuthenticationChallenge;
38interface IWebURLResponse;
39interface IWebURLRequest;
40
41interface IWebError;
42
43/*!
44    @category  WebResourceLoadDelegate
45    @discussion Implementors of this protocol will receive messages indicating
46    that a resource is about to be loaded, data has been received for a resource,
47    an error has been received for a resource, and completion of a resource load.
48    Implementors are also given the opportunity to mutate requests before they are sent.
49    The various progress methods of this protocol all receive an identifier as the
50    parameter.  This identifier can be used to track messages associated with a single
51    resource.  For example, a single resource may generate multiple
52    resource:willSendRequest:redirectResponse:fromDataSource: messages as it's URL is redirected.
53    @interface NSObject (WebResourceLoadDelegate)
54*/
55
56[
57    object,
58    oleautomation,
59    uuid(AF3289AA-90DB-4ca4-A112-A1E5F0517953),
60    pointer_default(unique)
61]
62interface IWebResourceLoadDelegate : IUnknown
63{
64    /*!
65        @method webView:identifierForInitialRequest:fromDataSource:
66        @param webView The WebView sending the message.
67        @param request The request about to be sent.
68        @param dataSource The datasource that initiated the load.
69        @discussion An implementor of WebResourceLoadDelegate should provide an identifier
70        that can be used to track the load of a single resource.  This identifier will be
71        passed as the first argument for all of the other WebResourceLoadDelegate methods.  The
72        identifier is useful to track changes to a resources request, which will be
73        provided by one or more calls to resource:willSendRequest:redirectResponse:fromDataSource:.
74        @result An identifier that will be passed back to the implementor for each callback.
75        The identifier will be retained.
76        - (id)webView:(WebView *)sender identifierForInitialRequest:(NSURLRequest *)request fromDataSource:(WebDataSource *)dataSource;
77    */
78    HRESULT identifierForInitialRequest([in] IWebView* webView, [in] IWebURLRequest* request, [in] IWebDataSource* dataSource, [in] unsigned long identifier);
79
80    /*!
81        @method resource:willSendRequest:redirectResponse:fromDataSource:
82        @discussion This message is sent before a load is initiated.  The request may be modified
83        as necessary by the receiver.
84        @param webView The WebView sending the message.
85        @param identifier An identifier that can be used to track the progress of a resource load across
86        multiple call backs.
87        @param request The request about to be sent.
88        @param redirectResponse If the request is being made in response to a redirect we received,
89        the response that conveyed that redirect.
90        @param dataSource The dataSource that initiated the load.
91        @result Returns the request, which may be mutated by the implementor, although typically
92        will be request.
93        - (NSURLRequest *)webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)dataSource;
94    */
95    HRESULT willSendRequest([in] IWebView* webView, [in] unsigned long identifier, [in] IWebURLRequest* request, [in] IWebURLResponse* redirectResponse, [in] IWebDataSource* dataSource, [out, retval] IWebURLRequest** newRequest);
96
97    /*!
98        @method webView:resource:didReceiveAuthenticationChallenge:fromDataSource:
99        @abstract Start authentication for the resource, providing a challenge
100        @discussion Call useCredential::, continueWithoutCredential or
101        cancel on the challenge when done.
102        @param challenge The NSURLAuthenticationChallenge to start authentication for
103        @discussion If you do not implement this delegate method, WebKit will handle authentication
104        automatically by prompting with a sheet on the window that the WebView is associated with.
105        - (void)webView:(WebView *)sender resource:(id)identifier didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)dataSource;
106    */
107    HRESULT didReceiveAuthenticationChallenge([in] IWebView* webView,  [in] unsigned long identifier,[in] IWebURLAuthenticationChallenge* challenge, [in] IWebDataSource* dataSource);
108
109    /*!
110        @method webView:resource:didCancelAuthenticationChallenge:fromDataSource:
111        @abstract Cancel authentication for a given request
112        @param challenge The NSURLAuthenticationChallenge for which to cancel authentication
113        - (void)webView:(WebView *)sender resource:(id)identifier didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)dataSource;
114    */
115    HRESULT didCancelAuthenticationChallenge([in] IWebView* webView, [in] unsigned long identifier, [in] IWebURLAuthenticationChallenge* challenge, [in] IWebDataSource* dataSource);
116
117    /*!
118        @method webView:resource:didReceiveResponse:fromDataSource:
119        @abstract This message is sent after a response has been received for this load.
120        @param webView The WebView sending the message.
121        @param identifier An identifier that can be used to track the progress of a resource load across
122        multiple call backs.
123        @param response The response for the request.
124        @param dataSource The dataSource that initiated the load.
125        @discussion In some rare cases, multiple responses may be received for a single load.
126        This occurs with multipart/x-mixed-replace, or "server push". In this case, the client
127        should assume that each new response resets progress so far for the resource back to 0,
128        and should check the new response for the expected content length.
129        - (void)webView:(WebView *)sender resource:(id)identifier didReceiveResponse:(NSURLResponse *)response fromDataSource:(WebDataSource *)dataSource;
130    */
131    HRESULT didReceiveResponse([in] IWebView* webView, [in] unsigned long identifier, [in] IWebURLResponse* response, [in] IWebDataSource* dataSource);
132
133    /*!
134        @method webView:resource:didReceiveContentLength:fromDataSource:
135        @discussion Multiple of these messages may be sent as data arrives.
136        @param webView The WebView sending the message.
137        @param identifier An identifier that can be used to track the progress of a resource load across
138        multiple call backs.
139        @param length The amount of new data received.  This is not the total amount, just the new amount received.
140        @param dataSource The dataSource that initiated the load.
141        - (void)webView:(WebView *)sender resource:(id)identifier didReceiveContentLength:(WebNSInt)length fromDataSource:(WebDataSource *)dataSource;
142    */
143    HRESULT didReceiveContentLength([in] IWebView* webView, [in] unsigned long identifier, [in] UINT length, [in] IWebDataSource* dataSource);
144
145    /*!
146        @method webView:resource:didFinishLoadingFromDataSource:
147        @discussion This message is sent after a load has successfully completed.
148        @param webView The WebView sending the message.
149        @param identifier An identifier that can be used to track the progress of a resource load across
150        multiple call backs.
151        @param dataSource The dataSource that initiated the load.
152        - (void)webView:(WebView *)sender resource:(id)identifier didFinishLoadingFromDataSource:(WebDataSource *)dataSource;
153    */
154    HRESULT didFinishLoadingFromDataSource([in] IWebView* webView, [in] unsigned long identifier, [in] IWebDataSource* dataSource);
155
156    /*!
157        @method webView:resource:didFailLoadingWithError:fromDataSource:
158        @discussion This message is sent after a load has failed to load due to an error.
159        @param webView The WebView sending the message.
160        @param identifier An identifier that can be used to track the progress of a resource load across
161        multiple call backs.
162        @param error The error associated with this load.
163        @param dataSource The dataSource that initiated the load.
164        - (void)webView:(WebView *)sender resource:(id)identifier didFailLoadingWithError:(NSError *)error fromDataSource:(WebDataSource *)dataSource;
165    */
166    HRESULT didFailLoadingWithError([in] IWebView* webView, [in] unsigned long identifier, [in] IWebError* error, [in] IWebDataSource* dataSource);
167
168    /*!
169        @method webView:plugInFailedWithError:dataSource:
170        @discussion Called when a plug-in is not found, fails to load or is not available for some reason.
171        @param webView The WebView sending the message.
172        @param error The plug-in error. In the userInfo dictionary of the error, the object for the
173        NSErrorFailingURLKey key is a URL string of the SRC attribute, the object for the WebKitErrorPlugInNameKey
174        key is a string of the plug-in's name, the object for the WebKitErrorPlugInPageURLStringKey key is a URL string
175        of the PLUGINSPAGE attribute and the object for the WebKitErrorMIMETypeKey key is a string of the TYPE attribute.
176        Some, none or all of the mentioned attributes can be present in the userInfo. The error returns nil for userInfo
177        when none are present.
178        @param dataSource The dataSource that contains the plug-in.
179        - (void)webView:(WebView *)sender plugInFailedWithError:(NSError *)error dataSource:(WebDataSource *)dataSource;
180    */
181    HRESULT plugInFailedWithError([in] IWebView* webView, [in] IWebError* error, [in] IWebDataSource* dataSource);
182}
183