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