webengine/osswebengine/WebKit/win/Interfaces/IWebPolicyDelegate.idl
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2  * Copyright (C) 2006, 2007 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 cpp_quote("/*")
       
    27 cpp_quote(" * Copyright (C) 2006, 2007 Apple Inc.  All rights reserved.")
       
    28 cpp_quote(" *")
       
    29 cpp_quote(" * Redistribution and use in source and binary forms, with or without")
       
    30 cpp_quote(" * modification, are permitted provided that the following conditions")
       
    31 cpp_quote(" * are met:")
       
    32 cpp_quote(" * 1. Redistributions of source code must retain the above copyright")
       
    33 cpp_quote(" *    notice, this list of conditions and the following disclaimer.")
       
    34 cpp_quote(" * 2. Redistributions in binary form must reproduce the above copyright")
       
    35 cpp_quote(" *    notice, this list of conditions and the following disclaimer in the")
       
    36 cpp_quote(" *    documentation and/or other materials provided with the distribution.")
       
    37 cpp_quote(" *")
       
    38 cpp_quote(" * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY")
       
    39 cpp_quote(" * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE")
       
    40 cpp_quote(" * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR")
       
    41 cpp_quote(" * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR")
       
    42 cpp_quote(" * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,")
       
    43 cpp_quote(" * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,")
       
    44 cpp_quote(" * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR")
       
    45 cpp_quote(" * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY")
       
    46 cpp_quote(" * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT")
       
    47 cpp_quote(" * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE")
       
    48 cpp_quote(" * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ")
       
    49 cpp_quote(" */")
       
    50 
       
    51 import "oaidl.idl";
       
    52 import "ocidl.idl";
       
    53 import "IWebView.idl";
       
    54 import "IWebURLRequest.idl";
       
    55 
       
    56 interface IWebError;
       
    57 interface IWebURLResponse;
       
    58 interface IWebURLRequest;
       
    59 interface IWebView;
       
    60 interface IWebFrame;
       
    61 interface IWebPolicyPrivate;
       
    62 
       
    63 /*!
       
    64     @enum WebNavigationType
       
    65     @abstract The type of action that triggered a possible navigation.
       
    66     @constant WebNavigationTypeLinkClicked A link with an href was clicked.
       
    67     @constant WebNavigationTypeFormSubmitted A form was submitted.
       
    68     @constant WebNavigationTypeBackForward The user chose back or forward.
       
    69     @constant WebNavigationTypeReload The User hit the reload button.
       
    70     @constant WebNavigationTypeFormResubmitted A form was resubmitted (by virtue of doing back, forward or reload).
       
    71     @constant WebNavigationTypeOther Navigation is taking place for some other reason.
       
    72 */
       
    73 
       
    74 typedef enum WebNavigationType {
       
    75     WebNavigationTypeLinkClicked,
       
    76     WebNavigationTypeFormSubmitted,
       
    77     WebNavigationTypeBackForward,
       
    78     WebNavigationTypeReload,
       
    79     WebNavigationTypeFormResubmitted,
       
    80     WebNavigationTypeOther
       
    81 } WebNavigationType;
       
    82 
       
    83 cpp_quote("#define WebActionNavigationTypeKey TEXT(\"WebActionNavigationTypeKey\")")
       
    84 cpp_quote("#define WebActionElementKey TEXT(\"WebActionElementKey\")")
       
    85 cpp_quote("#define WebActionButtonKey TEXT(\"WebActionButtonKey\")")
       
    86 cpp_quote("#define WebActionModifierFlagsKey TEXT(\"WebActionModifierFlagsKey\")")
       
    87 cpp_quote("#define WebActionOriginalURLKey TEXT(\"WebActionOriginalURLKey\")")
       
    88 
       
    89 /*
       
    90 extern NSString *WebActionNavigationTypeKey; // NSNumber (WebNavigationType)
       
    91 extern NSString *WebActionElementKey; // NSDictionary of element info
       
    92 extern NSString *WebActionButtonKey;  // NSEventType
       
    93 extern NSString *WebActionModifierFlagsKey; // NSNumber (unsigned)
       
    94 extern NSString *WebActionOriginalURLKey; // NSURL
       
    95 */
       
    96 
       
    97 /*!
       
    98     @protocol WebPolicyDecisionListener
       
    99     @discussion This protocol is used to call back with the results of a
       
   100     policy decision. This provides the ability to make these decisions
       
   101     asyncrhonously, which means the decision can be made by prompting
       
   102     with a sheet, for example.
       
   103     @protocol WebPolicyDecisionListener <NSObject>
       
   104 */
       
   105 [
       
   106     object,
       
   107     oleautomation,
       
   108     uuid(DFCDE523-FD96-4f95-958B-151540FE122A),
       
   109     pointer_default(unique)
       
   110 ]
       
   111 interface IWebPolicyDecisionListener : IUnknown
       
   112 {
       
   113     /*!
       
   114         @method use
       
   115         @abstract Use the resource
       
   116         @discussion If there remain more policy decisions to be made, then
       
   117         the next policy delegate method gets to decide. This will be
       
   118         either the next navigation policy delegate if there is a redirect,
       
   119         or the content policy delegate. If there are no more policy
       
   120         decisions to be made, the resource will be displayed inline if
       
   121         possible. If there is no view available to display the resource
       
   122         inline, then unableToImplementPolicyWithError:frame: will be
       
   123         called with an appropriate error. 
       
   124 
       
   125         <p>If a new window is going to be created for this navigation as a
       
   126         result of frame targetting, then it will be created once you call
       
   127         this method.
       
   128         - (void)use;
       
   129     */
       
   130     HRESULT use();
       
   131 
       
   132     /*!
       
   133         @method download
       
   134         @abstract Download the resource instead of displaying it.
       
   135         @discussion This method is more than just a convenience because it
       
   136         allows an in-progress navigation to be converted to a download
       
   137         based on content type, without having to stop and restart the
       
   138         load.
       
   139         - (void)download;
       
   140     */
       
   141     HRESULT download();
       
   142 
       
   143     /*!
       
   144         @method ignore
       
   145         @abstract Do nothing (but the client may choose to handle the request itself)
       
   146         @discussion A policy of ignore prevents WebKit from doing anything
       
   147         further with the load, however, the client is still free to handle
       
   148         the request in some other way, such as opening a new window,
       
   149         opening a new window behind the current one, opening the URL in an
       
   150         external app, revealing the location in Finder if a file URL, etc.
       
   151         - (void)ignore;
       
   152     */
       
   153     HRESULT ignore();
       
   154 }
       
   155 
       
   156 /*!
       
   157     @category WebPolicyDelegate
       
   158     @discussion While loading a URL, WebKit asks the WebPolicyDelegate for
       
   159     policies that determine the action of what to do with the URL or the data that
       
   160     the URL represents. Typically, the policy handler methods are called in this order:
       
   161 
       
   162     decidePolicyForNewWindowAction:request:newFrameName:decisionListener: (at most once)<BR>
       
   163     decidePolicyForNavigationAction:request:frame:decisionListener: (zero or more times)<BR>
       
   164     decidePolicyForMIMEType:request:frame: (zero or more times)<BR>
       
   165 
       
   166     New window policy is always checked. Navigation policy is checked
       
   167     for the initial load and every redirect unless blocked by an
       
   168     earlier policy. Content policy is checked once the content type is
       
   169     known, unless an earlier policy prevented it.
       
   170 
       
   171     In rare cases, content policy might be checked more than
       
   172     once. This occurs when loading a "multipart/x-mixed-replace"
       
   173     document, also known as "server push". In this case, multiple
       
   174     documents come in one navigation, with each replacing the last. In
       
   175     this case, conent policy will be checked for each one.
       
   176     @interface NSObject (WebPolicyDelegate)
       
   177 */
       
   178 [
       
   179     object,
       
   180     oleautomation,
       
   181     uuid(9B0BAE6C-A496-4000-9E22-2E89F0747401),
       
   182     pointer_default(unique)
       
   183 ]
       
   184 interface IWebPolicyDelegate : IUnknown
       
   185 {
       
   186     /*!
       
   187        @method webView:decidePolicyForNavigationAction:request:frame:decisionListener:
       
   188        @abstract This method is called to decide what to do with a proposed navigation.
       
   189        @param actionInformation Dictionary that describes the action that triggered this navigation.
       
   190        @param request The request for the proposed navigation
       
   191        @param frame The WebFrame in which the navigation is happening
       
   192        @param listener The object to call when the decision is made
       
   193        @discussion This method will be called before loading starts, and
       
   194        on every redirect.
       
   195         - (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation
       
   196                                                                    request:(NSURLRequest *)request
       
   197                                                                      frame:(WebFrame *)frame
       
   198                                                           decisionListener:(id<WebPolicyDecisionListener>)listener;
       
   199     */
       
   200     HRESULT decidePolicyForNavigationAction([in] IWebView* webView, [in] IPropertyBag* actionInformation, [in] IWebURLRequest* request, [in] IWebFrame* frame, [in] IWebPolicyDecisionListener* listener);
       
   201 
       
   202     /*!
       
   203         @method webView:decidePolicyForNewWindowAction:request:newFrameName:decisionListener:
       
   204         @discussion This method is called to decide what to do with an targetted nagivation that would open a new window.
       
   205         @param actionInformation Dictionary that describes the action that triggered this navigation.
       
   206         @param request The request for the proposed navigation
       
   207         @param frame The frame in which the navigation is taking place
       
   208         @param listener The object to call when the decision is made
       
   209         @discussion This method is provided so that modified clicks on a targetted link which
       
   210         opens a new frame can prevent the new window from being opened if they decide to
       
   211         do something else, like download or present the new frame in a specialized way. 
       
   212 
       
   213         <p>If this method picks a policy of Use, the new window will be
       
   214         opened, and decidePolicyForNavigationAction:request:frame:decisionListner:
       
   215         will be called with a WebNavigationType of WebNavigationTypeOther
       
   216         in its action. This is to avoid possible confusion about the modifiers.
       
   217         - (void)webView:(WebView *)webView decidePolicyForNewWindowAction:(NSDictionary *)actionInformation
       
   218                                                                   request:(NSURLRequest *)request
       
   219                                                              newFrameName:(NSString *)frameName
       
   220                                                          decisionListener:(id<WebPolicyDecisionListener>)listener;
       
   221     */
       
   222     HRESULT decidePolicyForNewWindowAction([in] IWebView* webView, [in] IPropertyBag* actionInformation, [in] IWebURLRequest* request, [in] BSTR frameName, [in] IWebPolicyDecisionListener* listener);
       
   223 
       
   224     /*!
       
   225         @method webView:decidePolicyForMIMEType:request:frame:
       
   226         @discussion Returns the policy for content which has been partially loaded.
       
   227         Sent after webView:didStartProvisionalLoadForFrame: is sent on the WebFrameLoadDelegate.
       
   228         @param type MIME type for the resource.
       
   229         @param request A NSURLRequest for the partially loaded content.
       
   230         @param frame The frame which is loading the URL.
       
   231         @param listener The object to call when the decision is made
       
   232         - (void)webView:(WebView *)webView decidePolicyForMIMEType:(NSString *)type
       
   233                                                            request:(NSURLRequest *)request
       
   234                                                              frame:(WebFrame *)frame
       
   235                                                   decisionListener:(id<IWebPolicyDecisionListener>)listener;
       
   236     */
       
   237     HRESULT decidePolicyForMIMEType([in] IWebView* webView, [in] BSTR type, [in] IWebURLRequest* request, [in] IWebFrame* frame, [in] IWebPolicyDecisionListener* listener);
       
   238 
       
   239     /*!
       
   240         @method webView:unableToImplementPolicy:error:forURL:inFrame:
       
   241         @discussion Called when a WebPolicy could not be implemented. It is up to the client to display appropriate feedback.
       
   242         @param policy The policy that could not be implemented.
       
   243         @param error The error that caused the policy to not be implemented.
       
   244         @param URL The URL of the resource for which a particular action was requested but failed.
       
   245         @param frame The frame in which the policy could not be implemented.
       
   246         - (void)webView:(WebView *)webView unableToImplementPolicyWithError:(NSError *)error frame:(WebFrame *)frame;
       
   247     */
       
   248     HRESULT unableToImplementPolicyWithError([in] IWebView* webView, [in] IWebError* error, [in] IWebFrame* frame);
       
   249 }