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