Reviewed by Alice.
[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 WebFrameBridge;
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     WebMainResourceLoader *mainResourceLoader;
84     
85     NSMutableArray *subresourceLoaders;
86     NSMutableArray *plugInStreamLoaders;
87     
88     WebFrame <WebFrameLoaderClient> *client;
89     WebDocumentLoader *documentLoader;
90     WebDocumentLoader *provisionalDocumentLoader;
91     WebDocumentLoader *policyDocumentLoader;
92         
93     WebFrameState state;
94     
95     WebPolicyDecisionListener *listener;
96     
97     NSMutableDictionary *pendingArchivedResources;
98
99     FrameLoadType loadType;
100
101     // state we'll need to continue after waiting for the policy delegate's decision
102     NSURLRequest *policyRequest;
103     NSString *policyFrameName;
104     id policyTarget;
105     SEL policySelector;
106     WebFormState *policyFormState;
107     FrameLoadType policyLoadType;
108
109     BOOL delegateIsHandlingProvisionalLoadError;
110     BOOL delegateIsDecidingNavigationPolicy;
111     BOOL delegateIsHandlingUnimplementablePolicy;
112
113     BOOL firstLayoutDone;
114     BOOL quickRedirectComing;
115     BOOL sentRedirectNotification;
116     BOOL isStoppingLoad;    
117 }
118
119 - (id)initWithClient:(WebFrame <WebFrameLoaderClient> *)client;
120 - (void)addPlugInStreamLoader:(WebLoader *)loader;
121 - (void)removePlugInStreamLoader:(WebLoader *)loader;
122 - (void)setDefersCallbacks:(BOOL)defers;
123 - (void)stopLoadingPlugIns;
124 - (BOOL)isLoadingMainResource;
125 - (BOOL)isLoadingSubresources;
126 - (BOOL)isLoading;
127 - (void)stopLoadingSubresources;
128 - (void)addSubresourceLoader:(WebLoader *)loader;
129 - (void)removeSubresourceLoader:(WebLoader *)loader;
130 - (NSData *)mainResourceData;
131 - (void)releaseMainResourceLoader;
132 - (void)cancelMainResourceLoad;
133 - (BOOL)startLoadingMainResourceWithRequest:(NSMutableURLRequest *)request identifier:(id)identifier;
134 - (void)stopLoadingWithError:(NSError *)error;
135 - (void)clearProvisionalLoad;
136 - (void)stopLoading;
137 - (void)stopLoadingSubframes;
138 - (void)markLoadComplete;
139 - (void)commitProvisionalLoad;
140 - (void)startLoading;
141 - (void)startProvisionalLoad:(WebDocumentLoader *)loader;
142 - (WebDocumentLoader *)activeDocumentLoader;
143 - (WebDocumentLoader *)documentLoader;
144 - (WebDocumentLoader *)provisionalDocumentLoader;
145 - (WebFrameState)state;
146 - (void)setupForReplace;
147 + (CFAbsoluteTime)timeOfLastCompletedLoad;
148 - (void)provisionalLoadStarted;
149 - (void)frameLoadCompleted;
150
151 - (BOOL)defersCallbacks;
152 - (void)defersCallbacksChanged;
153 - (id)_identifierForInitialRequest:(NSURLRequest *)clientRequest;
154 - (NSURLRequest *)_willSendRequest:(NSMutableURLRequest *)clientRequest forResource:(id)identifier redirectResponse:(NSURLResponse *)redirectResponse;
155 - (void)_didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)currentWebChallenge forResource:(id)identifier;
156 - (void)_didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)currentWebChallenge forResource:(id)identifier;
157 - (void)_didReceiveResponse:(NSURLResponse *)r forResource:(id)identifier;
158 - (void)_didReceiveData:(NSData *)data contentLength:(int)lengthReceived forResource:(id)identifier;
159 - (void)_didFinishLoadingForResource:(id)identifier;
160 - (void)_didFailLoadingWithError:(NSError *)error forResource:(id)identifier;
161 - (BOOL)_privateBrowsingEnabled;
162 - (void)_didFailLoadingWithError:(NSError *)error forResource:(id)identifier;
163 - (void)_finishedLoadingResource;
164 - (void)_receivedError:(NSError *)error;
165 - (NSURLRequest *)_originalRequest;
166 - (WebFrame *)webFrame;
167 - (void)_receivedMainResourceError:(NSError *)error complete:(BOOL)isComplete;
168 - (NSURLRequest *)initialRequest;
169 - (void)_receivedData:(NSData *)data;
170 - (void)_setRequest:(NSURLRequest *)request;
171 - (void)_downloadWithLoadingConnection:(NSURLConnection *)connection request:(NSURLRequest *)request response:(NSURLResponse *)r proxy:(id)proxy;
172 - (void)_handleFallbackContent;
173 - (BOOL)_isStopping;
174 - (void)_setupForReplaceByMIMEType:(NSString *)newMIMEType;
175 - (void)_setResponse:(NSURLResponse *)response;
176 - (void)_mainReceivedError:(NSError *)error complete:(BOOL)isComplete;
177 - (void)_finishedLoading;
178 - (NSURL *)_URL;
179
180 - (NSError *)cancelledErrorWithRequest:(NSURLRequest *)request;
181 - (NSError *)fileDoesNotExistErrorWithResponse:(NSURLResponse *)response;
182 - (BOOL)willUseArchiveForRequest:(NSURLRequest *)r originalURL:(NSURL *)originalURL loader:(WebLoader *)loader;
183 - (BOOL)archiveLoadPendingForLoader:(WebLoader *)loader;
184 - (void)deliverArchivedResourcesAfterDelay;
185 - (void)cancelPendingArchiveLoadForLoader:(WebLoader *)loader;
186 - (void)clearArchivedResources;
187 - (void)cannotShowMIMETypeForURL:(NSURL *)URL;
188 - (NSError *)interruptForPolicyChangeErrorWithRequest:(NSURLRequest *)request;
189 - (BOOL)isHostedByObjectElement;
190 - (BOOL)isLoadingMainFrame;
191 + (BOOL)_canShowMIMEType:(NSString *)MIMEType;
192 + (BOOL)_representationExistsForURLScheme:(NSString *)URLScheme;
193 + (NSString *)_generatedMIMETypeForURLScheme:(NSString *)URLScheme;
194 - (void)_notifyIconChanged:(NSURL *)iconURL;
195 - (void)_checkNavigationPolicyForRequest:(NSURLRequest *)newRequest andCall:(id)obj withSelector:(SEL)sel;
196 - (void)_checkContentPolicyForMIMEType:(NSString *)MIMEType andCall:(id)obj withSelector:(SEL)sel;
197 - (void)cancelContentPolicy;
198 - (void)_loadRequest:(NSURLRequest *)request archive:(WebArchive *)archive;
199 - (void)reload;
200 - (void)_reloadAllowingStaleDataWithOverrideEncoding:(NSString *)encoding;
201 - (void)_loadRequest:(NSURLRequest *)request triggeringAction:(NSDictionary *)action loadType:(FrameLoadType)loadType formState:(WebFormState *)formState;
202
203 - (void)didReceiveServerRedirectForProvisionalLoadForFrame;
204 - (WebFrameBridge *)bridge;
205 - (void)finishedLoadingDocument:(WebDocumentLoader *)loader;
206 - (void)committedLoadWithDocumentLoader:(WebDocumentLoader *)loader data:(NSData *)data;
207 - (BOOL)isReplacing;
208 - (void)setReplacing;
209 - (void)revertToProvisionalWithDocumentLoader:(WebDocumentLoader *)loader;
210 - (void)documentLoader:(WebDocumentLoader *)loader setMainDocumentError:(NSError *)error;
211 - (void)documentLoader:(WebDocumentLoader *)loader mainReceivedCompleteError:(NSError *)error;
212 - (void)finalSetupForReplaceWithDocumentLoader:(WebDocumentLoader *)loader;
213 - (void)prepareForLoadStart;
214 - (BOOL)subframeIsLoading;
215 - (void)willChangeTitleForDocument:(WebDocumentLoader *)loader;
216 - (void)didChangeTitleForDocument:(WebDocumentLoader *)loader;
217
218 - (FrameLoadType)loadType;
219 - (void)setLoadType:(FrameLoadType)type;
220
221 - (void)invalidatePendingPolicyDecisionCallingDefaultAction:(BOOL)call;
222 - (void)checkNewWindowPolicyForRequest:(NSURLRequest *)request action:(NSDictionary *)action frameName:(NSString *)frameName formState:(WebFormState *)formState andCall:(id)target withSelector:(SEL)selector;
223 - (void)checkNavigationPolicyForRequest:(NSURLRequest *)request documentLoader:(WebDocumentLoader *)loader formState:(WebFormState *)formState andCall:(id)target withSelector:(SEL)selector;
224 - (void)continueAfterWillSubmitForm:(WebPolicyAction)policy;
225 - (void)continueLoadRequestAfterNavigationPolicy:(NSURLRequest *)request formState:(WebFormState *)formState;
226 - (void)loadDocumentLoader:(WebDocumentLoader *)loader withLoadType:(FrameLoadType)loadType formState:(WebFormState *)formState;
227 - (void)handleUnimplementablePolicyWithErrorCode:(int)code forURL:(NSURL *)URL;
228
229 - (void)didFirstLayout;
230 - (BOOL)firstLayoutDone;
231
232 - (void)clientRedirectCancelledOrFinished:(BOOL)cancelWithLoadInProgress;
233 - (void)clientRedirectedTo:(NSURL *)URL delay:(NSTimeInterval)seconds fireDate:(NSDate *)date lockHistory:(BOOL)lockHistory isJavaScriptFormAction:(BOOL)isJavaScriptFormAction;
234 - (void)loadURL:(NSURL *)URL referrer:(NSString *)referrer loadType:(FrameLoadType)loadType target:(NSString *)target triggeringEvent:(NSEvent *)event form:(DOMElement *)form formValues:(NSDictionary *)values;
235 - (void)commitProvisionalLoad:(NSDictionary *)pageCache;
236 - (BOOL)isQuickRedirectComing;
237 - (BOOL)shouldReloadForCurrent:(NSURL *)currentURL andDestination:(NSURL *)destinationURL;
238
239 - (void)transitionToCommitted:(NSDictionary *)pageCache;
240 - (void)checkLoadCompleteForThisFrame;
241 - (void)continueLoadRequestAfterNewWindowPolicy:(NSURLRequest *)request frameName:(NSString *)frameName formState:(WebFormState *)formState;
242 - (void)sendRemainingDelegateMessagesWithIdentifier:(id)identifier response:(NSURLResponse *)response length:(unsigned)length error:(NSError *)error;
243 - (NSURLRequest *)requestFromDelegateForRequest:(NSURLRequest *)request identifier:(id *)identifier error:(NSError **)error;
244 - (void)loadRequest:(NSURLRequest *)request inFrameNamed:(NSString *)frameName;
245 - (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;
246
247 - (void)checkLoadComplete;
248 - (void)detachFromParent;
249 - (void)safeLoadURL:(NSURL *)URL;
250 - (void)defersCallbacksChanged;
251 - (void)detachChildren;
252 - (void)addExtraFieldsToRequest:(NSMutableURLRequest *)request mainResource:(BOOL)mainResource alwaysFromRequest:(BOOL)alwaysFromRequest;
253 - (NSDictionary *)actionInformationForNavigationType:(NavigationType)navigationType event:(NSEvent *)event originalURL:(NSURL *)URL;
254 - (NSDictionary *)actionInformationForLoadType:(FrameLoadType)loadType isFormSubmission:(BOOL)isFormSubmission event:(NSEvent *)event originalURL:(NSURL *)URL;
255
256 @end