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