IWebPolicyDelegate.idl 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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. #ifndef DO_NO_IMPORTS
  26. import "oaidl.idl";
  27. import "ocidl.idl";
  28. import "IWebView.idl";
  29. import "IWebURLRequest.idl";
  30. #endif
  31. interface IWebError;
  32. interface IWebURLResponse;
  33. interface IWebURLRequest;
  34. interface IWebView;
  35. interface IWebFrame;
  36. interface IWebPolicyPrivate;
  37. /*!
  38. @enum WebNavigationType
  39. @abstract The type of action that triggered a possible navigation.
  40. @constant WebNavigationTypeLinkClicked A link with an href was clicked.
  41. @constant WebNavigationTypeFormSubmitted A form was submitted.
  42. @constant WebNavigationTypeBackForward The user chose back or forward.
  43. @constant WebNavigationTypeReload The User hit the reload button.
  44. @constant WebNavigationTypeFormResubmitted A form was resubmitted (by virtue of doing back, forward or reload).
  45. @constant WebNavigationTypeOther Navigation is taking place for some other reason.
  46. */
  47. typedef enum WebNavigationType {
  48. WebNavigationTypeLinkClicked,
  49. WebNavigationTypeFormSubmitted,
  50. WebNavigationTypeBackForward,
  51. WebNavigationTypeReload,
  52. WebNavigationTypeFormResubmitted,
  53. WebNavigationTypeOther
  54. } WebNavigationType;
  55. cpp_quote("#define WebActionButtonKey TEXT(\"WebActionButtonKey\")")
  56. cpp_quote("#define WebActionElementKey TEXT(\"WebActionElementKey\")")
  57. cpp_quote("#define WebActionFormKey TEXT(\"WebActionFormKey\")")
  58. cpp_quote("#define WebActionModifierFlagsKey TEXT(\"WebActionModifierFlagsKey\")")
  59. cpp_quote("#define WebActionNavigationTypeKey TEXT(\"WebActionNavigationTypeKey\")")
  60. cpp_quote("#define WebActionOriginalURLKey TEXT(\"WebActionOriginalURLKey\")")
  61. /*!
  62. @protocol WebPolicyDecisionListener
  63. @discussion This protocol is used to call back with the results of a
  64. policy decision. This provides the ability to make these decisions
  65. asyncrhonously, which means the decision can be made by prompting
  66. with a sheet, for example.
  67. @protocol WebPolicyDecisionListener <NSObject>
  68. */
  69. [
  70. object,
  71. oleautomation,
  72. uuid(DFCDE523-FD96-4f95-958B-151540FE122A),
  73. pointer_default(unique)
  74. ]
  75. interface IWebPolicyDecisionListener : IUnknown
  76. {
  77. /*!
  78. @method use
  79. @abstract Use the resource
  80. @discussion If there remain more policy decisions to be made, then
  81. the next policy delegate method gets to decide. This will be
  82. either the next navigation policy delegate if there is a redirect,
  83. or the content policy delegate. If there are no more policy
  84. decisions to be made, the resource will be displayed inline if
  85. possible. If there is no view available to display the resource
  86. inline, then unableToImplementPolicyWithError:frame: will be
  87. called with an appropriate error.
  88. <p>If a new window is going to be created for this navigation as a
  89. result of frame targetting, then it will be created once you call
  90. this method.
  91. - (void)use;
  92. */
  93. HRESULT use();
  94. /*!
  95. @method download
  96. @abstract Download the resource instead of displaying it.
  97. @discussion This method is more than just a convenience because it
  98. allows an in-progress navigation to be converted to a download
  99. based on content type, without having to stop and restart the
  100. load.
  101. - (void)download;
  102. */
  103. HRESULT download();
  104. /*!
  105. @method ignore
  106. @abstract Do nothing (but the client may choose to handle the request itself)
  107. @discussion A policy of ignore prevents WebKit from doing anything
  108. further with the load, however, the client is still free to handle
  109. the request in some other way, such as opening a new window,
  110. opening a new window behind the current one, opening the URL in an
  111. external app, revealing the location in Finder if a file URL, etc.
  112. - (void)ignore;
  113. */
  114. HRESULT ignore();
  115. }
  116. /*!
  117. @category WebPolicyDelegate
  118. @discussion While loading a URL, WebKit asks the WebPolicyDelegate for
  119. policies that determine the action of what to do with the URL or the data that
  120. the URL represents. Typically, the policy handler methods are called in this order:
  121. decidePolicyForNewWindowAction:request:newFrameName:decisionListener: (at most once)<BR>
  122. decidePolicyForNavigationAction:request:frame:decisionListener: (zero or more times)<BR>
  123. decidePolicyForMIMEType:request:frame: (zero or more times)<BR>
  124. New window policy is always checked. Navigation policy is checked
  125. for the initial load and every redirect unless blocked by an
  126. earlier policy. Content policy is checked once the content type is
  127. known, unless an earlier policy prevented it.
  128. In rare cases, content policy might be checked more than
  129. once. This occurs when loading a "multipart/x-mixed-replace"
  130. document, also known as "server push". In this case, multiple
  131. documents come in one navigation, with each replacing the last. In
  132. this case, conent policy will be checked for each one.
  133. @interface NSObject (WebPolicyDelegate)
  134. */
  135. [
  136. object,
  137. oleautomation,
  138. uuid(9B0BAE6C-A496-4000-9E22-2E89F0747401),
  139. pointer_default(unique)
  140. ]
  141. interface IWebPolicyDelegate : IUnknown
  142. {
  143. /*!
  144. @method webView:decidePolicyForNavigationAction:request:frame:decisionListener:
  145. @abstract This method is called to decide what to do with a proposed navigation.
  146. @param actionInformation Dictionary that describes the action that triggered this navigation.
  147. @param request The request for the proposed navigation
  148. @param frame The WebFrame in which the navigation is happening
  149. @param listener The object to call when the decision is made
  150. @discussion This method will be called before loading starts, and
  151. on every redirect.
  152. - (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation
  153. request:(NSURLRequest *)request
  154. frame:(WebFrame *)frame
  155. decisionListener:(id<WebPolicyDecisionListener>)listener;
  156. */
  157. HRESULT decidePolicyForNavigationAction([in] IWebView* webView, [in] IPropertyBag* actionInformation, [in] IWebURLRequest* request, [in] IWebFrame* frame, [in] IWebPolicyDecisionListener* listener);
  158. /*!
  159. @method webView:decidePolicyForNewWindowAction:request:newFrameName:decisionListener:
  160. @discussion This method is called to decide what to do with an targetted nagivation that would open a new window.
  161. @param actionInformation Dictionary that describes the action that triggered this navigation.
  162. @param request The request for the proposed navigation
  163. @param frame The frame in which the navigation is taking place
  164. @param listener The object to call when the decision is made
  165. @discussion This method is provided so that modified clicks on a targetted link which
  166. opens a new frame can prevent the new window from being opened if they decide to
  167. do something else, like download or present the new frame in a specialized way.
  168. <p>If this method picks a policy of Use, the new window will be
  169. opened, and decidePolicyForNavigationAction:request:frame:decisionListner:
  170. will be called with a WebNavigationType of WebNavigationTypeOther
  171. in its action. This is to avoid possible confusion about the modifiers.
  172. - (void)webView:(WebView *)webView decidePolicyForNewWindowAction:(NSDictionary *)actionInformation
  173. request:(NSURLRequest *)request
  174. newFrameName:(NSString *)frameName
  175. decisionListener:(id<WebPolicyDecisionListener>)listener;
  176. */
  177. HRESULT decidePolicyForNewWindowAction([in] IWebView* webView, [in] IPropertyBag* actionInformation, [in] IWebURLRequest* request, [in] BSTR frameName, [in] IWebPolicyDecisionListener* listener);
  178. /*!
  179. @method webView:decidePolicyForMIMEType:request:frame:
  180. @discussion Returns the policy for content which has been partially loaded.
  181. Sent after webView:didStartProvisionalLoadForFrame: is sent on the WebFrameLoadDelegate.
  182. @param type MIME type for the resource.
  183. @param request A NSURLRequest for the partially loaded content.
  184. @param frame The frame which is loading the URL.
  185. @param listener The object to call when the decision is made
  186. - (void)webView:(WebView *)webView decidePolicyForMIMEType:(NSString *)type
  187. request:(NSURLRequest *)request
  188. frame:(WebFrame *)frame
  189. decisionListener:(id<IWebPolicyDecisionListener>)listener;
  190. */
  191. HRESULT decidePolicyForMIMEType([in] IWebView* webView, [in] BSTR type, [in] IWebURLRequest* request, [in] IWebFrame* frame, [in] IWebPolicyDecisionListener* listener);
  192. /*!
  193. @method webView:unableToImplementPolicy:error:forURL:inFrame:
  194. @discussion Called when a WebPolicy could not be implemented. It is up to the client to display appropriate feedback.
  195. @param policy The policy that could not be implemented.
  196. @param error The error that caused the policy to not be implemented.
  197. @param URL The URL of the resource for which a particular action was requested but failed.
  198. @param frame The frame in which the policy could not be implemented.
  199. - (void)webView:(WebView *)webView unableToImplementPolicyWithError:(NSError *)error frame:(WebFrame *)frame;
  200. */
  201. HRESULT unableToImplementPolicyWithError([in] IWebView* webView, [in] IWebError* error, [in] IWebFrame* frame);
  202. }