Reviewed by Darin.
[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 @interface WebFrameLoader : NSObject
74 {
75 @public
76     WebMainResourceLoader *mainResourceLoader;
77     
78     NSMutableArray *subresourceLoaders;
79     NSMutableArray *plugInStreamLoaders;
80     
81     WebFrame <WebFrameLoaderClient> *client;
82     WebDocumentLoader *documentLoader;
83     WebDocumentLoader *provisionalDocumentLoader;
84     WebDocumentLoader *policyDocumentLoader;
85         
86     WebFrameState state;
87     
88     WebPolicyDecisionListener *listener;
89     
90     NSMutableDictionary *pendingArchivedResources;
91
92     FrameLoadType loadType;
93
94     // state we'll need to continue after waiting for the policy delegate's decision
95     NSURLRequest *policyRequest;
96     NSString *policyFrameName;
97     id policyTarget;
98     SEL policySelector;
99     WebFormState *policyFormState;
100     FrameLoadType policyLoadType;
101
102     BOOL delegateIsHandlingProvisionalLoadError;
103     BOOL delegateIsDecidingNavigationPolicy;
104     BOOL delegateIsHandlingUnimplementablePolicy;
105
106     BOOL firstLayoutDone;
107     BOOL quickRedirectComing;
108     BOOL sentRedirectNotification;
109     BOOL isStoppingLoad;    
110 }
111
112 - (id)initWithClient:(WebFrame <WebFrameLoaderClient> *)wf;
113 - (void)addPlugInStreamLoader:(WebLoader *)loader;
114 - (void)removePlugInStreamLoader:(WebLoader *)loader;
115 - (void)setDefersCallbacks:(BOOL)defers;
116 - (void)stopLoadingPlugIns;
117 - (BOOL)isLoadingMainResource;
118 - (BOOL)isLoadingSubresources;
119 - (BOOL)isLoading;
120 - (void)stopLoadingSubresources;
121 - (void)addSubresourceLoader:(WebLoader *)loader;
122 - (void)removeSubresourceLoader:(WebLoader *)loader;
123 - (NSData *)mainResourceData;
124 - (void)releaseMainResourceLoader;
125 - (void)cancelMainResourceLoad;
126 - (BOOL)startLoadingMainResourceWithRequest:(NSMutableURLRequest *)request identifier:(id)identifier;
127 - (void)stopLoadingWithError:(NSError *)error;
128 - (void)clearProvisionalLoad;
129 - (void)stopLoading;
130 - (void)stopLoadingSubframes;
131 - (void)markLoadComplete;
132 - (void)commitProvisionalLoad;
133 - (void)startLoading;
134 - (void)startProvisionalLoad:(WebDataSource *)dataSource;
135 - (WebDataSource *)dataSource;
136 - (WebDataSource *)provisionalDataSource;
137 - (WebDataSource *)policyDataSource;
138 - (WebDataSource *)activeDataSource;
139 - (WebDocumentLoader *)activeDocumentLoader;
140 - (WebDocumentLoader *)documentLoader;
141 - (WebDocumentLoader *)provisionalDocumentLoader;
142 - (WebFrameState)state;
143 - (void)clearDataSource;
144 - (void)setupForReplace;
145 + (CFAbsoluteTime)timeOfLastCompletedLoad;
146 - (void)provisionalLoadStarted;
147 - (void)frameLoadCompleted;
148
149 - (WebResource *)_archivedSubresourceForURL:(NSURL *)URL;
150 - (BOOL)defersCallbacks;
151 - (void)defersCallbacksChanged;
152 - (id)_identifierForInitialRequest:(NSURLRequest *)clientRequest;
153 - (NSURLRequest *)_willSendRequest:(NSMutableURLRequest *)clientRequest forResource:(id)identifier redirectResponse:(NSURLResponse *)redirectResponse;
154 - (void)_didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)currentWebChallenge forResource:(id)identifier;
155 - (void)_didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)currentWebChallenge forResource:(id)identifier;
156 - (void)_didReceiveResponse:(NSURLResponse *)r forResource:(id)identifier;
157 - (void)_didReceiveData:(NSData *)data contentLength:(int)lengthReceived forResource:(id)identifier;
158 - (void)_didFinishLoadingForResource:(id)identifier;
159 - (void)_didFailLoadingWithError:(NSError *)error forResource:(id)identifier;
160 - (BOOL)_privateBrowsingEnabled;
161 - (void)_didFailLoadingWithError:(NSError *)error forResource:(id)identifier;
162 - (void)_finishedLoadingResource;
163 - (void)_receivedError:(NSError *)error;
164 - (NSURLRequest *)_originalRequest;
165 - (WebFrame *)webFrame;
166 - (void)_receivedMainResourceError:(NSError *)error complete:(BOOL)isComplete;
167 - (NSURLRequest *)initialRequest;
168 - (void)_receivedData:(NSData *)data;
169 - (void)_setRequest:(NSURLRequest *)request;
170 - (void)_downloadWithLoadingConnection:(NSURLConnection *)connection request:(NSURLRequest *)request response:(NSURLResponse *)r proxy:(id)proxy;
171 - (void)_handleFallbackContent;
172 - (BOOL)_isStopping;
173 - (void)_setupForReplaceByMIMEType:(NSString *)newMIMEType;
174 - (void)_setResponse:(NSURLResponse *)response;
175 - (void)_mainReceivedError:(NSError *)error complete:(BOOL)isComplete;
176 - (void)_finishedLoading;
177 - (NSURL *)_URL;
178
179 - (NSError *)cancelledErrorWithRequest:(NSURLRequest *)request;
180 - (NSError *)fileDoesNotExistErrorWithResponse:(NSURLResponse *)response;
181 - (BOOL)willUseArchiveForRequest:(NSURLRequest *)r originalURL:(NSURL *)originalURL loader:(WebLoader *)loader;
182 - (BOOL)archiveLoadPendingForLoader:(WebLoader *)loader;
183 - (void)deliverArchivedResourcesAfterDelay;
184 - (void)cancelPendingArchiveLoadForLoader:(WebLoader *)loader;
185 - (void)clearArchivedResources;
186 - (void)_addExtraFieldsToRequest:(NSMutableURLRequest *)request mainResource:(BOOL)mainResource alwaysFromRequest:(BOOL)f;
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 - (BOOL)delegateIsHandlingProvisionalLoadError;
221 - (void)setDelegateIsHandlingProvisionalLoadError:(BOOL)is;
222
223 - (void)invalidatePendingPolicyDecisionCallingDefaultAction:(BOOL)call;
224 - (void)checkNewWindowPolicyForRequest:(NSURLRequest *)request action:(NSDictionary *)action frameName:(NSString *)frameName formState:(WebFormState *)formState andCall:(id)target withSelector:(SEL)selector;
225 - (void)checkNavigationPolicyForRequest:(NSURLRequest *)request dataSource:(WebDataSource *)dataSource formState:(WebFormState *)formState andCall:(id)target withSelector:(SEL)selector;
226 - (void)continueAfterWillSubmitForm:(WebPolicyAction)policy;
227 - (void)continueLoadRequestAfterNavigationPolicy:(NSURLRequest *)request formState:(WebFormState *)formState;
228 - (void)loadDataSource:(WebDataSource *)newDataSource withLoadType:(FrameLoadType)loadType formState:(WebFormState *)formState;
229 - (void)handleUnimplementablePolicyWithErrorCode:(int)code forURL:(NSURL *)URL;
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 @end