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