Reviewed by Maciej.
[WebKit-https.git] / WebKit / Loader / WebFrameLoader.h
1 /*
2  * Copyright (C) 2006 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
31 @class DOMElement;
32 @class WebArchive;
33 @class WebDataSource;
34 @class WebDocumentLoader;
35 @class WebFormState;
36 @class WebFrame;
37 @class WebFrameBridge;
38 @class WebLoader;
39 @class WebMainResourceLoader;
40 @class WebPolicyDecisionListener;
41 @class WebResource;
42 @protocol WebFrameLoaderClient;
43
44 typedef enum {
45     WebFrameStateProvisional,
46     
47     // This state indicates we are ready to commit to a page,
48     // which means the view will transition to use the new data source.
49     WebFrameStateCommittedPage,
50     
51     WebFrameStateComplete
52 } WebFrameState;
53
54 typedef enum {
55     WebPolicyUse,
56     WebPolicyDownload,
57     WebPolicyIgnore,
58 } WebPolicyAction;
59
60 typedef enum {
61     FrameLoadTypeStandard,
62     FrameLoadTypeBack,
63     FrameLoadTypeForward,
64     FrameLoadTypeIndexedBackForward, // a multi-item hop in the backforward list
65     FrameLoadTypeReload,
66     FrameLoadTypeReloadAllowingStaleData,
67     FrameLoadTypeSame,               // user loads same URL again (but not reload button)
68     FrameLoadTypeInternal,
69     FrameLoadTypeReplace
70 } FrameLoadType;
71
72 typedef enum {
73     NavigationTypeLinkClicked,
74     NavigationTypeFormSubmitted,
75     NavigationTypeBackForward,
76     NavigationTypeReload,
77     NavigationTypeFormResubmitted,
78     NavigationTypeOther
79 } NavigationType;
80
81 BOOL isBackForwardLoadType(FrameLoadType type);
82
83 @interface WebFrameLoader : NSObject {
84     WebMainResourceLoader *mainResourceLoader;
85     
86     NSMutableArray *subresourceLoaders;
87     NSMutableArray *plugInStreamLoaders;
88     
89     WebFrame <WebFrameLoaderClient> *client;
90     WebDocumentLoader *documentLoader;
91     WebDocumentLoader *provisionalDocumentLoader;
92     WebDocumentLoader *policyDocumentLoader;
93         
94     WebFrameState state;
95     
96     WebPolicyDecisionListener *listener;
97     
98     NSMutableDictionary *pendingArchivedResources;
99
100     FrameLoadType loadType;
101
102     // state we'll need to continue after waiting for the policy delegate's decision
103     NSURLRequest *policyRequest;
104     NSString *policyFrameName;
105     id policyTarget;
106     SEL policySelector;
107     WebFormState *policyFormState;
108     FrameLoadType policyLoadType;
109
110     BOOL delegateIsHandlingProvisionalLoadError;
111     BOOL delegateIsDecidingNavigationPolicy;
112     BOOL delegateIsHandlingUnimplementablePolicy;
113
114     BOOL firstLayoutDone;
115     BOOL quickRedirectComing;
116     BOOL sentRedirectNotification;
117     BOOL isStoppingLoad;    
118 }
119
120 - (id)initWithClient:(WebFrame <WebFrameLoaderClient> *)client;
121 - (void)addPlugInStreamLoader:(WebLoader *)loader;
122 - (void)removePlugInStreamLoader:(WebLoader *)loader;
123 - (void)setDefersCallbacks:(BOOL)defers;
124 - (void)stopLoadingPlugIns;
125 - (BOOL)isLoadingMainResource;
126 - (BOOL)isLoadingSubresources;
127 - (BOOL)isLoading;
128 - (void)stopLoadingSubresources;
129 - (void)addSubresourceLoader:(WebLoader *)loader;
130 - (void)removeSubresourceLoader:(WebLoader *)loader;
131 - (NSData *)mainResourceData;
132 - (void)releaseMainResourceLoader;
133 - (void)cancelMainResourceLoad;
134 - (BOOL)startLoadingMainResourceWithRequest:(NSMutableURLRequest *)request identifier:(id)identifier;
135 - (void)stopLoadingWithError:(NSError *)error;
136 - (void)clearProvisionalLoad;
137 - (void)stopLoading;
138 - (void)stopLoadingSubframes;
139 - (void)markLoadComplete;
140 - (void)commitProvisionalLoad;
141 - (void)startLoading;
142 - (void)startProvisionalLoad:(WebDataSource *)dataSource;
143 - (WebDataSource *)dataSource;
144 - (WebDataSource *)provisionalDataSource;
145 - (WebDataSource *)policyDataSource;
146 - (WebDataSource *)activeDataSource;
147 - (WebDocumentLoader *)activeDocumentLoader;
148 - (WebDocumentLoader *)documentLoader;
149 - (WebDocumentLoader *)provisionalDocumentLoader;
150 - (WebFrameState)state;
151 - (void)setupForReplace;
152 + (CFAbsoluteTime)timeOfLastCompletedLoad;
153 - (void)provisionalLoadStarted;
154 - (void)frameLoadCompleted;
155
156 - (BOOL)defersCallbacks;
157 - (void)defersCallbacksChanged;
158 - (id)_identifierForInitialRequest:(NSURLRequest *)clientRequest;
159 - (NSURLRequest *)_willSendRequest:(NSMutableURLRequest *)clientRequest forResource:(id)identifier redirectResponse:(NSURLResponse *)redirectResponse;
160 - (void)_didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)currentWebChallenge forResource:(id)identifier;
161 - (void)_didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)currentWebChallenge forResource:(id)identifier;
162 - (void)_didReceiveResponse:(NSURLResponse *)r forResource:(id)identifier;
163 - (void)_didReceiveData:(NSData *)data contentLength:(int)lengthReceived forResource:(id)identifier;
164 - (void)_didFinishLoadingForResource:(id)identifier;
165 - (void)_didFailLoadingWithError:(NSError *)error forResource:(id)identifier;
166 - (BOOL)_privateBrowsingEnabled;
167 - (void)_didFailLoadingWithError:(NSError *)error forResource:(id)identifier;
168 - (void)_finishedLoadingResource;
169 - (void)_receivedError:(NSError *)error;
170 - (NSURLRequest *)_originalRequest;
171 - (WebFrame *)webFrame;
172 - (void)_receivedMainResourceError:(NSError *)error complete:(BOOL)isComplete;
173 - (NSURLRequest *)initialRequest;
174 - (void)_receivedData:(NSData *)data;
175 - (void)_setRequest:(NSURLRequest *)request;
176 - (void)_downloadWithLoadingConnection:(NSURLConnection *)connection request:(NSURLRequest *)request response:(NSURLResponse *)r proxy:(id)proxy;
177 - (void)_handleFallbackContent;
178 - (BOOL)_isStopping;
179 - (void)_setupForReplaceByMIMEType:(NSString *)newMIMEType;
180 - (void)_setResponse:(NSURLResponse *)response;
181 - (void)_mainReceivedError:(NSError *)error complete:(BOOL)isComplete;
182 - (void)_finishedLoading;
183 - (NSURL *)_URL;
184
185 - (NSError *)cancelledErrorWithRequest:(NSURLRequest *)request;
186 - (NSError *)fileDoesNotExistErrorWithResponse:(NSURLResponse *)response;
187 - (BOOL)willUseArchiveForRequest:(NSURLRequest *)r originalURL:(NSURL *)originalURL loader:(WebLoader *)loader;
188 - (BOOL)archiveLoadPendingForLoader:(WebLoader *)loader;
189 - (void)deliverArchivedResourcesAfterDelay;
190 - (void)cancelPendingArchiveLoadForLoader:(WebLoader *)loader;
191 - (void)clearArchivedResources;
192 - (void)cannotShowMIMETypeForURL:(NSURL *)URL;
193 - (NSError *)interruptForPolicyChangeErrorWithRequest:(NSURLRequest *)request;
194 - (BOOL)isHostedByObjectElement;
195 - (BOOL)isLoadingMainFrame;
196 + (BOOL)_canShowMIMEType:(NSString *)MIMEType;
197 + (BOOL)_representationExistsForURLScheme:(NSString *)URLScheme;
198 + (NSString *)_generatedMIMETypeForURLScheme:(NSString *)URLScheme;
199 - (void)_notifyIconChanged:(NSURL *)iconURL;
200 - (void)_checkNavigationPolicyForRequest:(NSURLRequest *)newRequest andCall:(id)obj withSelector:(SEL)sel;
201 - (void)_checkContentPolicyForMIMEType:(NSString *)MIMEType andCall:(id)obj withSelector:(SEL)sel;
202 - (void)cancelContentPolicy;
203 - (void)_loadRequest:(NSURLRequest *)request archive:(WebArchive *)archive;
204 - (void)reload;
205 - (void)_reloadAllowingStaleDataWithOverrideEncoding:(NSString *)encoding;
206 - (void)_loadRequest:(NSURLRequest *)request triggeringAction:(NSDictionary *)action loadType:(FrameLoadType)loadType formState:(WebFormState *)formState;
207
208 - (void)didReceiveServerRedirectForProvisionalLoadForFrame;
209 - (WebFrameBridge *)bridge;
210 - (void)finishedLoadingDocument:(WebDocumentLoader *)loader;
211 - (void)committedLoadWithDocumentLoader:(WebDocumentLoader *)loader data:(NSData *)data;
212 - (BOOL)isReplacing;
213 - (void)setReplacing;
214 - (void)revertToProvisionalWithDocumentLoader:(WebDocumentLoader *)loader;
215 - (void)documentLoader:(WebDocumentLoader *)loader setMainDocumentError:(NSError *)error;
216 - (void)documentLoader:(WebDocumentLoader *)loader mainReceivedCompleteError:(NSError *)error;
217 - (void)finalSetupForReplaceWithDocumentLoader:(WebDocumentLoader *)loader;
218 - (void)prepareForLoadStart;
219 - (BOOL)subframeIsLoading;
220 - (void)willChangeTitleForDocument:(WebDocumentLoader *)loader;
221 - (void)didChangeTitleForDocument:(WebDocumentLoader *)loader;
222
223 - (FrameLoadType)loadType;
224 - (void)setLoadType:(FrameLoadType)type;
225
226 - (void)invalidatePendingPolicyDecisionCallingDefaultAction:(BOOL)call;
227 - (void)checkNewWindowPolicyForRequest:(NSURLRequest *)request action:(NSDictionary *)action frameName:(NSString *)frameName formState:(WebFormState *)formState andCall:(id)target withSelector:(SEL)selector;
228 - (void)checkNavigationPolicyForRequest:(NSURLRequest *)request dataSource:(WebDataSource *)dataSource formState:(WebFormState *)formState andCall:(id)target withSelector:(SEL)selector;
229 - (void)continueAfterWillSubmitForm:(WebPolicyAction)policy;
230 - (void)continueLoadRequestAfterNavigationPolicy:(NSURLRequest *)request formState:(WebFormState *)formState;
231 - (void)loadDataSource:(WebDataSource *)newDataSource withLoadType:(FrameLoadType)loadType formState:(WebFormState *)formState;
232 - (void)handleUnimplementablePolicyWithErrorCode:(int)code forURL:(NSURL *)URL;
233
234 - (void)didFirstLayout;
235 - (BOOL)firstLayoutDone;
236
237 - (void)clientRedirectCancelledOrFinished:(BOOL)cancelWithLoadInProgress;
238 - (void)clientRedirectedTo:(NSURL *)URL delay:(NSTimeInterval)seconds fireDate:(NSDate *)date lockHistory:(BOOL)lockHistory isJavaScriptFormAction:(BOOL)isJavaScriptFormAction;
239 - (void)loadURL:(NSURL *)URL referrer:(NSString *)referrer loadType:(FrameLoadType)loadType target:(NSString *)target triggeringEvent:(NSEvent *)event form:(DOMElement *)form formValues:(NSDictionary *)values;
240 - (void)commitProvisionalLoad:(NSDictionary *)pageCache;
241 - (BOOL)isQuickRedirectComing;
242 - (BOOL)shouldReloadForCurrent:(NSURL *)currentURL andDestination:(NSURL *)destinationURL;
243
244 - (void)transitionToCommitted:(NSDictionary *)pageCache;
245 - (void)checkLoadCompleteForThisFrame;
246 - (void)continueLoadRequestAfterNewWindowPolicy:(NSURLRequest *)request frameName:(NSString *)frameName formState:(WebFormState *)formState;
247 - (void)sendRemainingDelegateMessagesWithIdentifier:(id)identifier response:(NSURLResponse *)response length:(unsigned)length error:(NSError *)error;
248 - (NSURLRequest *)requestFromDelegateForRequest:(NSURLRequest *)request identifier:(id *)identifier error:(NSError **)error;
249 - (void)loadRequest:(NSURLRequest *)request inFrameNamed:(NSString *)frameName;
250 - (void)postWithURL:(NSURL *)URL referrer:(NSString *)referrer target:(NSString *)target data:(NSArray *)postData contentType:(NSString *)contentType triggeringEvent:(NSEvent *)event form:(DOMElement *)form formValues:(NSDictionary *)values;
251
252 - (void)checkLoadComplete;
253 - (void)detachFromParent;
254 - (void)safeLoadURL:(NSURL *)URL;
255 - (void)defersCallbacksChanged;
256 - (void)detachChildren;
257 - (void)addExtraFieldsToRequest:(NSMutableURLRequest *)request mainResource:(BOOL)mainResource alwaysFromRequest:(BOOL)alwaysFromRequest;
258 - (NSDictionary *)actionInformationForNavigationType:(NavigationType)navigationType event:(NSEvent *)event originalURL:(NSURL *)URL;
259 - (NSDictionary *)actionInformationForLoadType:(FrameLoadType)loadType isFormSubmission:(BOOL)isFormSubmission event:(NSEvent *)event originalURL:(NSURL *)URL;
260
261 @end