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