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 #import <Cocoa/Cocoa.h> 30 #import <JavaScriptCore/WebKitAvailability.h> 31 32 @class NSError; 33 @class WebFrame; 34 @class WebScriptObject; 35 @class WebView; 36 37 /*! 38 @category WebFrameLoadDelegate 39 @discussion A WebView's WebFrameLoadDelegate tracks the loading progress of its frames. 40 When a data source of a frame starts to load, the data source is considered "provisional". 41 Once at least one byte is received, the data source is considered "committed". This is done 42 so the contents of the frame will not be lost if the new data source fails to successfully load. 43 */ 44 @interface NSObject (WebFrameLoadDelegate) 45 46 /*! 47 @method webView:didStartProvisionalLoadForFrame: 48 @abstract Notifies the delegate that the provisional load of a frame has started 49 @param webView The WebView sending the message 50 @param frame The frame for which the provisional load has started 51 @discussion This method is called after the provisional data source of a frame 52 has started to load. 53 */ 54 - (void)webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame; 55 56 /*! 57 @method webView:didReceiveServerRedirectForProvisionalLoadForFrame: 58 @abstract Notifies the delegate that a server redirect occurred during the provisional load 59 @param webView The WebView sending the message 60 @param frame The frame for which the redirect occurred 61 */ 62 - (void)webView:(WebView *)sender didReceiveServerRedirectForProvisionalLoadForFrame:(WebFrame *)frame; 63 64 /*! 65 @method webView:didFailProvisionalLoadWithError:forFrame: 66 @abstract Notifies the delegate that the provisional load has failed 67 @param webView The WebView sending the message 68 @param error The error that occurred 69 @param frame The frame for which the error occurred 70 @discussion This method is called after the provisional data source has failed to load. 71 The frame will continue to display the contents of the committed data source if there is one. 72 */ 73 - (void)webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame; 74 75 /*! 76 @method webView:didCommitLoadForFrame: 77 @abstract Notifies the delegate that the load has changed from provisional to committed 78 @param webView The WebView sending the message 79 @param frame The frame for which the load has committed 80 @discussion This method is called after the provisional data source has become the 81 committed data source. 82 83 In some cases, a single load may be committed more than once. This happens 84 in the case of multipart/x-mixed-replace, also known as "server push". In this case, 85 a single location change leads to multiple documents that are loaded in sequence. When 86 this happens, a new commit will be sent for each document. 87 */ 88 - (void)webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)frame; 89 90 /*! 91 @method webView:didReceiveTitle:forFrame: 92 @abstract Notifies the delegate that the page title for a frame has been received 93 @param webView The WebView sending the message 94 @param title The new page title 95 @param frame The frame for which the title has been received 96 @discussion The title may update during loading; clients should be prepared for this. 97 */ 98 - (void)webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame; 99 100 /*! 101 @method webView:didReceiveIcon:forFrame: 102 @abstract Notifies the delegate that a page icon image for a frame has been received 103 @param webView The WebView sending the message 104 @param image The icon image. Also known as a "favicon". 105 @param frame The frame for which a page icon has been received 106 */ 107 - (void)webView:(WebView *)sender didReceiveIcon:(NSImage *)image forFrame:(WebFrame *)frame; 108 109 /*! 110 @method webView:didFinishLoadForFrame: 111 @abstract Notifies the delegate that the committed load of a frame has completed 112 @param webView The WebView sending the message 113 @param frame The frame that finished loading 114 @discussion This method is called after the committed data source of a frame has successfully loaded 115 and will only be called when all subresources such as images and stylesheets are done loading. 116 Plug-In content and JavaScript-requested loads may occur after this method is called. 117 */ 118 - (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame; 119 120 /*! 121 @method webView:didFailLoadWithError:forFrame: 122 @abstract Notifies the delegate that the committed load of a frame has failed 123 @param webView The WebView sending the message 124 @param error The error that occurred 125 @param frame The frame that failed to load 126 @discussion This method is called after a data source has committed but failed to completely load. 127 */ 128 - (void)webView:(WebView *)sender didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame; 129 130 /*! 131 @method webView:didChangeLocationWithinPageForFrame: 132 @abstract Notifies the delegate that the scroll position in a frame has changed 133 @param webView The WebView sending the message 134 @param frame The frame that scrolled 135 @discussion This method is called when anchors within a page have been clicked. 136 */ 137 - (void)webView:(WebView *)sender didChangeLocationWithinPageForFrame:(WebFrame *)frame; 138 139 /*! 140 @method webView:willPerformClientRedirectToURL:delay:fireDate:forFrame: 141 @abstract Notifies the delegate that a frame will perform a client-side redirect 142 @param webView The WebView sending the message 143 @param URL The URL to be redirected to 144 @param seconds Seconds in which the redirect will happen 145 @param date The fire date 146 @param frame The frame on which the redirect will occur 147 @discussion This method can be used to continue progress feedback while a client-side 148 redirect is pending. 149 */ 150 - (void)webView:(WebView *)sender willPerformClientRedirectToURL:(NSURL *)URL delay:(NSTimeInterval)seconds fireDate:(NSDate *)date forFrame:(WebFrame *)frame; 151 152 /*! 153 @method webView:didCancelClientRedirectForFrame: 154 @abstract Notifies the delegate that a pending client-side redirect has been cancelled 155 @param webView The WebView sending the message 156 @param frame The frame for which the pending redirect was cancelled 157 @discussion A client-side redirect can be cancelled if a frame changes location before the timeout. 158 */ 159 - (void)webView:(WebView *)sender didCancelClientRedirectForFrame:(WebFrame *)frame; 160 161 /*! 162 @method webView:willCloseFrame: 163 @abstract Notifies the delegate that a frame will be closed 164 @param webView The WebView sending the message 165 @param frame The frame that will be closed 166 @discussion This method is called right before WebKit is done with the frame 167 and the objects that it contains. 168 */ 169 - (void)webView:(WebView *)sender willCloseFrame:(WebFrame *)frame; 170 171 /*! 172 @method webView:didClearWindowObject:forFrame: 173 @abstract Notifies the delegate that the JavaScript window object in a frame has 174 been cleared in preparation for a new load. This is the preferred place to set custom 175 properties on the window object using the WebScriptObject and JavaScriptCore APIs. 176 @param webView The webView sending the message. 177 @param windowObject The WebScriptObject representing the frame's JavaScript window object. 178 @param frame The WebFrame to which windowObject belongs. 179 @discussion If a delegate implements both webView:didClearWindowObject:forFrame: 180 and webView:windowScriptObjectAvailable:, only webView:didClearWindowObject:forFrame: 181 will be invoked. This enables a delegate to implement both methods for backwards 182 compatibility with older versions of WebKit. 183 */ 184 - (void)webView:(WebView *)webView didClearWindowObject:(WebScriptObject *)windowObject forFrame:(WebFrame *)frame; 185 186 /*! 187 @method webView:windowScriptObjectAvailable: 188 @abstract Notifies the delegate that the scripting object for a page is available. This is called 189 before the page is loaded. It may be useful to allow delegates to bind native objects to the window. 190 @param webView The webView sending the message. 191 @param windowScriptObject The WebScriptObject for the window in the scripting environment. 192 @discussion This method is deprecated. Consider using webView:didClearWindowObject:forFrame: 193 instead. 194 */ 195 - (void)webView:(WebView *)webView windowScriptObjectAvailable:(WebScriptObject *)windowScriptObject WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0); 196 197 @end 198