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>
31 @class WebFrameLoader;
33 @interface WebDocumentLoader : NSObject
36 WebFrameLoader *frameLoader;
38 NSData *mainResourceData;
40 // A reference to actual request used to create the data source.
41 // This should only be used by the resourceLoadDelegate's
42 // identifierForInitialRequest:fromDatasource: method. It is
43 // not guaranteed to remain unchanged, as requests are mutable.
44 NSURLRequest *originalRequest;
46 // A copy of the original request used to create the data source.
47 // We have to copy the request because requests are mutable.
48 NSURLRequest *originalRequestCopy;
50 // The 'working' request for this datasource. It may be mutated
51 // several times from the original request to include additional
52 // headers, cookie information, canonicalization and redirects.
53 NSMutableURLRequest *request;
55 NSURLResponse *response;
57 NSError *mainDocumentError;
59 // The time when the data source was told to start loading.
60 double loadingStartedTime;
66 BOOL primaryLoadComplete;
67 BOOL isClientRedirect;
72 NSString *overrideEncoding;
74 // The action that triggered loading of this data source -
75 // we keep this around for the benefit of the various policy
77 NSDictionary *triggeringAction;
79 // The last request that we checked click policy for - kept around
80 // so we can avoid asking again needlessly.
81 NSURLRequest *lastCheckedRequest;
83 // We retain all the received responses so we can play back the
84 // WebResourceLoadDelegate messages if the item is loaded from the
86 NSMutableArray *responses;
87 BOOL stopRecordingResponses;
90 - (id)initWithRequest:(NSURLRequest *)request;
91 - (void)setFrameLoader:(WebFrameLoader *)fl;
92 - (WebFrameLoader *)frameLoader;
93 - (void)setMainResourceData:(NSData *)data;
94 - (NSData *)mainResourceData;
95 - (NSURLRequest *)originalRequest;
96 - (NSURLRequest *)originalRequestCopy;
97 - (NSMutableURLRequest *)request;
98 - (void)setRequest:(NSURLRequest *)request;
99 - (NSMutableURLRequest *)actualRequest;
100 - (NSURLRequest *)initialRequest;
102 - (NSURL *)unreachableURL;
103 - (void)replaceRequestURLForAnchorScrollWithURL:(NSURL *)URL;
106 - (void)setupForReplace;
107 - (void)commitIfReady;
108 - (void)setCommitted:(BOOL)f;
111 - (void)setLoading:(BOOL)f;
112 - (void)updateLoading;
113 - (void)receivedData:(NSData *)data;
114 - (void)setupForReplaceByMIMEType:(NSString *)newMIMEType;
115 - (void)finishedLoading;
116 - (NSURLResponse *)response;
118 - (NSError *)mainDocumentError;
119 - (void)mainReceivedError:(NSError *)error complete:(BOOL)isComplete;
120 - (void)setResponse:(NSURLResponse *)resp;
121 - (void)detachFromFrameLoader;
122 - (void)prepareForLoadStart;
123 - (double)loadingStartedTime;
124 - (BOOL)isClientRedirect;
125 - (void)setIsClientRedirect:(BOOL)flag;
126 - (BOOL)isLoadingInAPISense;
127 - (void)setPrimaryLoadComplete:(BOOL)flag;
128 - (void)setTitle:(NSString *)title;
129 - (NSString *)overrideEncoding;
130 - (void)addResponse:(NSURLResponse *)r;
131 - (NSArray *)responses;
132 - (NSDictionary *)triggeringAction;
133 - (void)setTriggeringAction:(NSDictionary *)action;
134 - (void)setOverrideEncoding:(NSString *)overrideEncoding;
135 - (NSString *)overrideEncoding;
136 - (NSDictionary *)triggeringAction;
137 - (void)setTriggeringAction:(NSDictionary *)action;
138 - (void)setLastCheckedRequest:(NSURLRequest *)request;
139 - (NSURLRequest *)lastCheckedRequest;
140 - (void)stopRecordingResponses;
142 - (NSURL *)URLForHistory;