Reviewed by Maciej.
[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 "WebDocumentLoadState.h"
32 #import "WebFrameLoaderClient.h"
33 #import "WebFramePrivate.h"
34
35 @class WebArchive;
36 @class WebDataSource;
37 @class WebMainResourceLoader;
38 @class WebLoader;
39 @class WebResource;
40 @class WebFrame;
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 @interface WebFrameLoader : NSObject
60 {
61 @public
62     WebMainResourceLoader *mainResourceLoader;
63     
64     NSMutableArray *subresourceLoaders;
65     NSMutableArray *plugInStreamLoaders;
66     
67     WebFrame <WebFrameLoaderClient> *client;
68     WebDocumentLoadState *documentLoadState;
69     WebDocumentLoadState *provisionalDocumentLoadState;
70     WebDocumentLoadState *policyDocumentLoadState;
71         
72     WebFrameState state;
73     
74     WebPolicyDecisionListener *listener;
75     
76     NSMutableDictionary *pendingArchivedResources;
77
78     WebFrameLoadType loadType;
79
80     // state we'll need to continue after waiting for the policy delegate's decision
81     NSURLRequest *policyRequest;
82     NSString *policyFrameName;
83     id policyTarget;
84     SEL policySelector;
85     WebFormState *policyFormState;
86     WebFrameLoadType policyLoadType;
87
88     BOOL delegateIsHandlingProvisionalLoadError;
89     BOOL delegateIsDecidingNavigationPolicy;
90     BOOL delegateIsHandlingUnimplementablePolicy;
91
92     BOOL firstLayoutDone;
93 }
94
95 - (id)initWithClient:(WebFrame <WebFrameLoaderClient> *)wf;
96 - (void)addPlugInStreamLoader:(WebLoader *)loader;
97 - (void)removePlugInStreamLoader:(WebLoader *)loader;
98 - (void)setDefersCallbacks:(BOOL)defers;
99 - (void)stopLoadingPlugIns;
100 - (BOOL)isLoadingMainResource;
101 - (BOOL)isLoadingSubresources;
102 - (BOOL)isLoading;
103 - (void)stopLoadingSubresources;
104 - (void)addSubresourceLoader:(WebLoader *)loader;
105 - (void)removeSubresourceLoader:(WebLoader *)loader;
106 - (NSData *)mainResourceData;
107 - (void)releaseMainResourceLoader;
108 - (void)cancelMainResourceLoad;
109 - (BOOL)startLoadingMainResourceWithRequest:(NSMutableURLRequest *)request identifier:(id)identifier;
110 - (void)stopLoadingWithError:(NSError *)error;
111 - (void)clearProvisionalLoad;
112 - (void)stopLoading;
113 - (void)markLoadComplete;
114 - (void)commitProvisionalLoad;
115 - (void)startLoading;
116 - (void)startProvisionalLoad:(WebDataSource *)dataSource;
117 - (WebDataSource *)dataSource;
118 - (WebDataSource *)provisionalDataSource;
119 - (WebDataSource *)policyDataSource;
120 - (WebDataSource *)activeDataSource;
121 - (WebDocumentLoadState *)activeDocumentLoadState;
122 - (WebDocumentLoadState *)documentLoadState;
123 - (WebDocumentLoadState *)provisionalDocumentLoadState;
124 - (void)_setPolicyDocumentLoadState:(WebDocumentLoadState *)loadState;
125 - (WebFrameState)state;
126 - (void)clearDataSource;
127 - (void)setupForReplace;
128 + (CFAbsoluteTime)timeOfLastCompletedLoad;
129 - (void)provisionalLoadStarted;
130 - (void)frameLoadCompleted;
131
132 - (WebResource *)_archivedSubresourceForURL:(NSURL *)URL;
133 - (BOOL)defersCallbacks;
134 - (void)defersCallbacksChanged;
135 - (id)_identifierForInitialRequest:(NSURLRequest *)clientRequest;
136 - (NSURLRequest *)_willSendRequest:(NSMutableURLRequest *)clientRequest forResource:(id)identifier redirectResponse:(NSURLResponse *)redirectResponse;
137 - (void)_didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)currentWebChallenge forResource:(id)identifier;
138 - (void)_didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)currentWebChallenge forResource:(id)identifier;
139 - (void)_didReceiveResponse:(NSURLResponse *)r forResource:(id)identifier;
140 - (void)_didReceiveData:(NSData *)data contentLength:(int)lengthReceived forResource:(id)identifier;
141 - (void)_didFinishLoadingForResource:(id)identifier;
142 - (void)_didFailLoadingWithError:(NSError *)error forResource:(id)identifier;
143 - (BOOL)_privateBrowsingEnabled;
144 - (void)_didFailLoadingWithError:(NSError *)error forResource:(id)identifier;
145 - (void)_finishedLoadingResource;
146 - (void)_receivedError:(NSError *)error;
147 - (NSURLRequest *)_originalRequest;
148 - (WebFrame *)webFrame;
149 - (void)_receivedMainResourceError:(NSError *)error complete:(BOOL)isComplete;
150 - (NSURLRequest *)initialRequest;
151 - (void)_receivedData:(NSData *)data;
152 - (void)_setRequest:(NSURLRequest *)request;
153 - (void)_downloadWithLoadingConnection:(NSURLConnection *)connection request:(NSURLRequest *)request response:(NSURLResponse *)r proxy:(id)proxy;
154 - (void)_handleFallbackContent;
155 - (BOOL)_isStopping;
156 - (void)_setupForReplaceByMIMEType:(NSString *)newMIMEType;
157 - (void)_setResponse:(NSURLResponse *)response;
158 - (void)_mainReceivedError:(NSError *)error complete:(BOOL)isComplete;
159 - (void)_finishedLoading;
160 - (NSURL *)_URL;
161
162 - (NSError *)cancelledErrorWithRequest:(NSURLRequest *)request;
163 - (NSError *)fileDoesNotExistErrorWithResponse:(NSURLResponse *)response;
164 - (BOOL)willUseArchiveForRequest:(NSURLRequest *)r originalURL:(NSURL *)originalURL loader:(WebLoader *)loader;
165 - (BOOL)archiveLoadPendingForLoader:(WebLoader *)loader;
166 - (void)deliverArchivedResourcesAfterDelay;
167 - (void)cancelPendingArchiveLoadForLoader:(WebLoader *)loader;
168 - (void)clearArchivedResources;
169 - (void)_addExtraFieldsToRequest:(NSMutableURLRequest *)request mainResource:(BOOL)mainResource alwaysFromRequest:(BOOL)f;
170 - (void)cannotShowMIMETypeForURL:(NSURL *)URL;
171 - (NSError *)interruptForPolicyChangeErrorWithRequest:(NSURLRequest *)request;
172 - (BOOL)isHostedByObjectElement;
173 - (BOOL)isLoadingMainFrame;
174 + (BOOL)_canShowMIMEType:(NSString *)MIMEType;
175 + (BOOL)_representationExistsForURLScheme:(NSString *)URLScheme;
176 + (NSString *)_generatedMIMETypeForURLScheme:(NSString *)URLScheme;
177 - (void)_notifyIconChanged:(NSURL *)iconURL;
178 - (void)_checkNavigationPolicyForRequest:(NSURLRequest *)newRequest andCall:(id)obj withSelector:(SEL)sel;
179 - (void)_checkContentPolicyForMIMEType:(NSString *)MIMEType andCall:(id)obj withSelector:(SEL)sel;
180 - (void)cancelContentPolicy;
181 - (void)_loadRequest:(NSURLRequest *)request archive:(WebArchive *)archive;
182 - (void)reload;
183 - (void)_reloadAllowingStaleDataWithOverrideEncoding:(NSString *)encoding;
184 - (void)_loadRequest:(NSURLRequest *)request triggeringAction:(NSDictionary *)action loadType:(WebFrameLoadType)loadType formState:(WebFormState *)formState;
185
186 - (void)didReceiveServerRedirectForProvisionalLoadForFrame;
187 - (WebFrameBridge *)bridge;
188 - (void)finishedLoadingDocumentLoadState:(WebDocumentLoadState *)loadState;
189 - (void)commitProvisitionalLoad;
190 - (void)committedLoadWithDocumentLoadState:(WebDocumentLoadState *)loadState data:(NSData *)data;
191 - (BOOL)isReplacing;
192 - (void)setReplacing;
193 - (void)revertToProvisionalWithDocumentLoadState:(WebDocumentLoadState *)loadState;
194 - (void)documentLoadState:(WebDocumentLoadState *)loadState setMainDocumentError:(NSError *)error;
195 - (void)documentLoadState:(WebDocumentLoadState *)loadState mainReceivedCompleteError:(NSError *)error;
196 - (void)finalSetupForReplaceWithDocumentLoadState:(WebDocumentLoadState *)loadState;
197 - (void)prepareForLoadStart;
198 - (BOOL)subframeIsLoading;
199 - (void)willChangeTitleForDocumentLoadState:(WebDocumentLoadState *)loadState;
200 - (void)didChangeTitleForDocumentLoadState:(WebDocumentLoadState *)loadState;
201
202 - (WebFrameLoadType)loadType;
203 - (void)setLoadType:(WebFrameLoadType)type;
204 - (BOOL)delegateIsHandlingProvisionalLoadError;
205 - (void)setDelegateIsHandlingProvisionalLoadError:(BOOL)is;
206
207 - (void)invalidatePendingPolicyDecisionCallingDefaultAction:(BOOL)call;
208 - (void)checkNewWindowPolicyForRequest:(NSURLRequest *)request action:(NSDictionary *)action frameName:(NSString *)frameName formState:(WebFormState *)formState andCall:(id)target withSelector:(SEL)selector;
209 - (void)checkNavigationPolicyForRequest:(NSURLRequest *)request dataSource:(WebDataSource *)dataSource formState:(WebFormState *)formState andCall:(id)target withSelector:(SEL)selector;
210 - (void)continueAfterWillSubmitForm:(WebPolicyAction)policy;
211 - (void)continueLoadRequestAfterNavigationPolicy:(NSURLRequest *)request formState:(WebFormState *)formState;
212 - (void)loadDataSource:(WebDataSource *)newDataSource withLoadType:(WebFrameLoadType)loadType formState:(WebFormState *)formState;
213 - (void)handleUnimplementablePolicyWithErrorCode:(int)code forURL:(NSURL *)URL;
214
215 - (void)didFirstLayout;
216 - (BOOL)firstLayoutDone;
217
218 @end