2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
29 #import <Cocoa/Cocoa.h>
32 @class WebDocumentLoader;
35 @class WebFrameBridge;
37 @class WebMainResourceLoader;
38 @protocol WebFrameLoaderClient;
41 @class WebPolicyDecisionListener;
44 WebFrameStateProvisional,
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,
60 FrameLoadTypeStandard,
63 FrameLoadTypeIndexedBackForward, // a multi-item hop in the backforward list
65 FrameLoadTypeReloadAllowingStaleData,
66 FrameLoadTypeSame, // user loads same URL again (but not reload button)
67 FrameLoadTypeInternal,
72 NavigationTypeLinkClicked,
73 NavigationTypeFormSubmitted,
74 NavigationTypeBackForward,
76 NavigationTypeFormResubmitted,
80 BOOL isBackForwardLoadType(FrameLoadType type);
82 @interface WebFrameLoader : NSObject {
83 WebMainResourceLoader *mainResourceLoader;
85 NSMutableArray *subresourceLoaders;
86 NSMutableArray *plugInStreamLoaders;
88 WebFrame <WebFrameLoaderClient> *client;
89 WebDocumentLoader *documentLoader;
90 WebDocumentLoader *provisionalDocumentLoader;
91 WebDocumentLoader *policyDocumentLoader;
95 WebPolicyDecisionListener *listener;
97 NSMutableDictionary *pendingArchivedResources;
99 FrameLoadType loadType;
101 // state we'll need to continue after waiting for the policy delegate's decision
102 NSURLRequest *policyRequest;
103 NSString *policyFrameName;
106 WebFormState *policyFormState;
107 FrameLoadType policyLoadType;
109 BOOL delegateIsHandlingProvisionalLoadError;
110 BOOL delegateIsDecidingNavigationPolicy;
111 BOOL delegateIsHandlingUnimplementablePolicy;
113 BOOL firstLayoutDone;
114 BOOL quickRedirectComing;
115 BOOL sentRedirectNotification;
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;
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;
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;
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;
174 - (void)_setupForReplaceByMIMEType:(NSString *)newMIMEType;
175 - (void)_setResponse:(NSURLResponse *)response;
176 - (void)_mainReceivedError:(NSError *)error complete:(BOOL)isComplete;
177 - (void)_finishedLoading;
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;
200 - (void)_reloadAllowingStaleDataWithOverrideEncoding:(NSString *)encoding;
201 - (void)_loadRequest:(NSURLRequest *)request triggeringAction:(NSDictionary *)action loadType:(FrameLoadType)loadType formState:(WebFormState *)formState;
203 - (void)didReceiveServerRedirectForProvisionalLoadForFrame;
204 - (WebFrameBridge *)bridge;
205 - (void)finishedLoadingDocument:(WebDocumentLoader *)loader;
206 - (void)committedLoadWithDocumentLoader:(WebDocumentLoader *)loader data:(NSData *)data;
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;
218 - (FrameLoadType)loadType;
219 - (void)setLoadType:(FrameLoadType)type;
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;
229 - (void)didFirstLayout;
230 - (BOOL)firstLayoutDone;
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;
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;
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;