[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
cblu
cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:28:10 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit e3de9d409185f52e49a82108d3ca0bf693c5a201
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Mar 7 19:20:18 2003 +0000
WebKit:
Fixed: 3191052 - Predetermined downloads should not be started from the browser window
- Stripped the rest of WebKit of download related code.
Reviewed by trey.
* Downloads.subproj/WebDownload.h: Changed the download delegate method from download:didStartFromDataSource: download:didStartFromRequest:. Passing the data source wasn't that helpful. It was also quirky that the data source would sometimes be nil.
* Downloads.subproj/WebDownload.m:
(-[WebDownloadPrivate dealloc]): release directory path
(-[WebDownload _initWithLoadingResource:dataSource:]): call _loadStarted and _loadEnded
(-[WebDownload loadWithDelegate:]): call _loadStarted
(-[WebDownload _loadStarted]): set flag, retain self
(-[WebDownload _loadEnded]): set flag, release self
(-[WebDownload resource:willSendRequest:]): call _loadEnded if the returned request is nil
(-[WebDownload resourceDidFinishLoading:]): call _loadEnded
(-[WebDownload resource:didFailLoadingWithError:]): call _loadEnded
(-[WebDownload _createFileIfNecessary]): handle a predetermined download directory, not path
(-[WebDownload _cancelWithError:]): call _loadEnded
(-[WebDownload _setDirectoryPath:]): new private method
* Downloads.subproj/WebDownloadPrivate.h:
* WebView.subproj/WebControllerPrivate.m:
(-[WebController _mainReceivedError:fromDataSource:complete:]): don't call [dataSource isDownloading]
(-[WebController _downloadURL:toDirectory:]): create and start a self retained WebDownload
* WebView.subproj/WebDataSource.h:
* WebView.subproj/WebDataSource.m: removed download related methods
* WebView.subproj/WebDataSourcePrivate.h:
* WebView.subproj/WebDataSourcePrivate.m: removed download related methods
(-[WebDataSource _commitIfReady:]): don't call isDownloading
* WebView.subproj/WebFramePrivate.h:
* WebView.subproj/WebFramePrivate.m:
* WebView.subproj/WebMainResourceClient.m:
(-[WebMainResourceClient continueAfterContentPolicy:response:]): when handing off the load to the download, don't deal with the download path
(-[WebMainResourceClient resource:didReceiveResponse:]): no more predetermined downloads come through here
WebBrowser:
Fixed: 3142376 - would be better if queued downloads showed up in downloads window
- Handle WebKit started downloads that don't have associated data sources.
- Don't use removed WebKit download API's.
- Handle HTTP errors in responses instead of downloading html error files.
- Don't update progress bar using a timer so it doesn't jerk.
Reviewed by john.
* BrowserWebController.m:
(-[BrowserWebController contentPolicyForMIMEType:andRequest:inFrame:]): call downloadMayBeOpenedForRequest
(-[BrowserWebController stopLoading]): removed stopNonDownloadingDataSource, don't call it
* DownloadMonitor.h:
* DownloadMonitor.m:
(-[DownloadMonitor init]): create _openableDownloadRequests
(-[DownloadMonitor download:didStartFromRequest:]): fixed leak, create entry with request
(-[DownloadMonitor download:didReceiveResponse:]): handle HTTP errors
(-[DownloadMonitor downloadMayBeOpenedForRequest:]): renamed
* DownloadProgressEntry.h:
* DownloadProgressEntry.m:
(-[DownloadProgressEntry setBytesLoaded:]): call progress notification
(-[DownloadProgressEntry setBytesExpected:]): call progress notification
(-[DownloadProgressEntry bytesExpected]): overridden to avoid superclass quirks
* DownloadRow.m:
(-[DownloadRow initWithDownloadProgressEntry:]): observe DownloadEntryProgressDidChangeNotification
(-[DownloadRow _updateProgressAnimation]): handle changes in bytesExpected
(-[DownloadRow _startProgressAnimation]): call _updateProgressAnimation, have timer call _updateStatusField
(-[DownloadRow _updateStatusField]): handle no bytes received case
(-[DownloadRow entryStageDidChange]): tweak
(-[DownloadRow entryPathDidChange]): tweak
(-[DownloadRow entryProgressDidChange]): call _updateProgressAnimation
* English.lproj/Localizable.strings: updated
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3776 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 7b0fd8a..c0c132d 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,38 @@
+2003-03-07 Chris Blumenberg <cblu at apple.com>
+
+ Fixed: 3191052 - Predetermined downloads should not be started from the browser window
+ - Stripped the rest of WebKit of download related code.
+
+ Reviewed by trey.
+
+ * Downloads.subproj/WebDownload.h: Changed the download delegate method from download:didStartFromDataSource: download:didStartFromRequest:. Passing the data source wasn't that helpful. It was also quirky that the data source would sometimes be nil.
+ * Downloads.subproj/WebDownload.m:
+ (-[WebDownloadPrivate dealloc]): release directory path
+ (-[WebDownload _initWithLoadingResource:dataSource:]): call _loadStarted and _loadEnded
+ (-[WebDownload loadWithDelegate:]): call _loadStarted
+ (-[WebDownload _loadStarted]): set flag, retain self
+ (-[WebDownload _loadEnded]): set flag, release self
+ (-[WebDownload resource:willSendRequest:]): call _loadEnded if the returned request is nil
+ (-[WebDownload resourceDidFinishLoading:]): call _loadEnded
+ (-[WebDownload resource:didFailLoadingWithError:]): call _loadEnded
+ (-[WebDownload _createFileIfNecessary]): handle a predetermined download directory, not path
+ (-[WebDownload _cancelWithError:]): call _loadEnded
+ (-[WebDownload _setDirectoryPath:]): new private method
+ * Downloads.subproj/WebDownloadPrivate.h:
+ * WebView.subproj/WebControllerPrivate.m:
+ (-[WebController _mainReceivedError:fromDataSource:complete:]): don't call [dataSource isDownloading]
+ (-[WebController _downloadURL:toDirectory:]): create and start a self retained WebDownload
+ * WebView.subproj/WebDataSource.h:
+ * WebView.subproj/WebDataSource.m: removed download related methods
+ * WebView.subproj/WebDataSourcePrivate.h:
+ * WebView.subproj/WebDataSourcePrivate.m: removed download related methods
+ (-[WebDataSource _commitIfReady:]): don't call isDownloading
+ * WebView.subproj/WebFramePrivate.h:
+ * WebView.subproj/WebFramePrivate.m:
+ * WebView.subproj/WebMainResourceClient.m:
+ (-[WebMainResourceClient continueAfterContentPolicy:response:]): when handing off the load to the download, don't deal with the download path
+ (-[WebMainResourceClient resource:didReceiveResponse:]): no more predetermined downloads come through here
+
2003-03-06 Maciej Stachowiak <mjs at apple.com>
Reviewed by Trey.
diff --git a/WebKit/Downloads.subproj/WebDownload.h b/WebKit/Downloads.subproj/WebDownload.h
index a14544e..247215e 100644
--- a/WebKit/Downloads.subproj/WebDownload.h
+++ b/WebKit/Downloads.subproj/WebDownload.h
@@ -7,7 +7,6 @@
#import <Foundation/Foundation.h>
- at class WebDataSource;
@class WebDownload;
@class WebDownloadPrivate;
@class WebError;
@@ -42,13 +41,12 @@
@interface NSObject (WebDownloadDelegate)
/*!
- @method download:startedFromDataSource:
+ @method download:didStartFromRequest:
@abstract This method is called immediately after the download has started.
- @discussion A download is started from a data source if the WebPolicySave WebPolicyAction was chosen for a request.
@param download The download that just started downloading.
- @param response The data source that the download started from. Nil if the download was not started from a data source.
+ @param request The request that the download started from.
*/
-- (void)download:(WebDownload *)download didStartFromDataSource:(WebDataSource *)dataSource;
+- (void)download:(WebDownload *)download didStartFromRequest:(WebRequest *)request;
/*!
@method download:willSendRequest:
diff --git a/WebKit/Downloads.subproj/WebDownload.m b/WebKit/Downloads.subproj/WebDownload.m
index d8d081e..b005f4b 100644
--- a/WebKit/Downloads.subproj/WebDownload.m
+++ b/WebKit/Downloads.subproj/WebDownload.m
@@ -63,6 +63,7 @@ typedef struct WebFSRefParam
NSString *path;
NSString *tempPath;
+ NSString *directoryPath;
}
@end
@@ -73,6 +74,9 @@ static void CloseCompletionCallback(ParmBlkPtr paramBlock);
static void DeleteCompletionCallback(ParmBlkPtr paramBlock);
@interface WebDownload (ForwardDeclarations)
+#pragma mark LOADING
+- (void)_loadStarted;
+- (void)_loadEnded;
#pragma mark CREATING
- (NSString *)_pathWithUniqueFilenameForPath:(NSString *)path;
- (BOOL)_createFSRefForPath:(NSString *)path;
@@ -100,6 +104,7 @@ static void DeleteCompletionCallback(ParmBlkPtr paramBlock);
- (void)_cancelWithError:(WebError *)error;
- (void)_cancelWithErrorCode:(int)code;
#pragma mark MISC
+- (void)_setPath:(NSString *)path;
- (NSString *)_currentPath;
- (WebError *)_errorWithCode:(int)code;
- (SInt16)_dataForkReferenceNumber;
@@ -133,6 +138,7 @@ static void DeleteCompletionCallback(ParmBlkPtr paramBlock);
{
ASSERT(!resource);
ASSERT(!delegate);
+ ASSERT(!isLoading);
free(fileRefPtr);
@@ -143,6 +149,7 @@ static void DeleteCompletionCallback(ParmBlkPtr paramBlock);
[response release];
[path release];
[tempPath release];
+ [directoryPath release];
[super dealloc];
}
@@ -177,26 +184,29 @@ static void DeleteCompletionCallback(ParmBlkPtr paramBlock);
_private->request = [[dataSource request] retain];
_private->response = [[dataSource response] retain];
_private->delegate = [[dataSource _controller] downloadDelegate];
- _private->isLoading = YES;
+ [self _loadStarted];
// Replay the delegate methods that would be called in the standalone download case.
- if ([_private->delegate respondsToSelector:@selector(download:didStartFromDataSource:)]) {
- [_private->delegate download:self didStartFromDataSource:dataSource];
+ if ([_private->delegate respondsToSelector:@selector(download:didStartFromRequest:)]) {
+ [_private->delegate download:self didStartFromRequest:_private->request];
}
- // If the request is altered, cancel the previous resource and start a new one.
if ([_private->delegate respondsToSelector:@selector(download:willSendRequest:)]) {
WebRequest *request = [_private->delegate download:self willSendRequest:_private->request];
if (request != _private->request) {
+ // If the request is altered, cancel the resource and start a new one.
[self cancel];
if (request) {
_private->resource = [[WebResource alloc] initWithRequest:request];
+ ASSERT(_private->resource);
[_private->resource loadWithDelegate:(id <WebResourceDelegate>)self];
+ } else {
+ [self _loadEnded];
}
return self;
}
}
-
+
if ([_private->delegate respondsToSelector:@selector(download:didReceiveResponse:)]) {
[_private->delegate download:self didReceiveResponse:_private->response];
}
@@ -215,10 +225,11 @@ static void DeleteCompletionCallback(ParmBlkPtr paramBlock);
if (!_private->isLoading) {
_private->delegate = delegate;
[_private->resource loadWithDelegate:(id <WebResourceDelegate>)self];
- _private->isLoading = YES;
-
- if ([_private->delegate respondsToSelector:@selector(download:didStartFromDataSource:)]) {
- [_private->delegate download:self didStartFromDataSource:nil];
+
+ [self _loadStarted];
+
+ if ([_private->delegate respondsToSelector:@selector(download:didStartFromRequest:)]) {
+ [_private->delegate download:self didStartFromRequest:_private->request];
}
}
}
@@ -241,12 +252,27 @@ static void DeleteCompletionCallback(ParmBlkPtr paramBlock);
#pragma mark LOADING
-- (void)_loadFinished
+- (void)_loadStarted
+{
+ if (!_private->isLoading) {
+ _private->isLoading = YES;
+
+ // Retain self while loading so we aren't released during the load.
+ [self retain];
+ }
+}
+
+- (void)_loadEnded
{
- _private->isLoading = NO;
+ if (_private->isLoading) {
+ _private->isLoading = NO;
- [_private->resource release];
- _private->resource = nil;
+ [_private->resource release];
+ _private->resource = nil;
+
+ // Balance the retain from when the load started.
+ [self release];
+ }
}
-(WebRequest *)resource:(WebResource *)resource willSendRequest:(WebRequest *)theRequest
@@ -260,7 +286,7 @@ static void DeleteCompletionCallback(ParmBlkPtr paramBlock);
}
if (!request) {
- [self _loadFinished];
+ [self _loadEnded];
}
if (_private->request != request) {
@@ -295,7 +321,7 @@ static void DeleteCompletionCallback(ParmBlkPtr paramBlock);
-(void)resourceDidFinishLoading:(WebResource *)resource
{
- [self _loadFinished];
+ [self _loadEnded];
WebError *error = [self _decodeData:_private->bufferedData];
[_private->bufferedData release];
@@ -316,7 +342,7 @@ static void DeleteCompletionCallback(ParmBlkPtr paramBlock);
-(void)resource:(WebResource *)resource didFailLoadingWithError:(WebError *)error
{
- [self _loadFinished];
+ [self _loadEnded];
[self _cancelWithError:error];
}
@@ -390,13 +416,20 @@ static void DeleteCompletionCallback(ParmBlkPtr paramBlock);
[attributes setObject:[_private->response createdDate] forKey:NSFileModificationDate];
}
- // Check if the path is predetermined. If not, ask for one.
- if (!_private->path) {
- NSString *filename = [[lastDecoder filename] _web_filenameByFixingIllegalCharacters];
- if ([filename length] == 0) {
- filename = [_private->response suggestedFilenameForSaving];
- }
+ NSString *filename = [[lastDecoder filename] _web_filenameByFixingIllegalCharacters];
+ if ([filename length] == 0) {
+ filename = [_private->response suggestedFilenameForSaving];
+ }
+
+ ASSERT(!_private->path);
+ NSString *path = nil;
+
+ // Check if the directory is predetermined. If not, ask for a path.
+ if (_private->directoryPath) {
+ path = [_private->directoryPath stringByAppendingPathComponent:filename];
+ [self _setPath:path];
+ } else {
if ([_private->delegate respondsToSelector:@selector(download:decidePathWithListener:suggestedFilename:)]) {
[_private->delegate download:self
decidePathWithListener:(id <WebDownloadDecisionListener>)self
@@ -404,7 +437,6 @@ static void DeleteCompletionCallback(ParmBlkPtr paramBlock);
}
}
- NSString *path = nil;
if (_private->path) {
// Path was immeditately set.
path = _private->path;
@@ -742,7 +774,8 @@ static void DeleteCompletionCallback(ParmBlkPtr paramBlock);
- (void)_cancelWithError:(WebError *)error
{
[_private->resource cancel];
- [self _loadFinished];
+
+ [self _loadEnded];
if (error) {
if ([_private->delegate respondsToSelector:@selector(download:didFailDownloadingWithError:)]) {
@@ -806,6 +839,13 @@ static void DeleteCompletionCallback(ParmBlkPtr paramBlock);
}
}
+- (void)_setDirectoryPath:(NSString *)directoryPath
+{
+ NSString *copy = [directoryPath copy];
+ [_private->directoryPath release];
+ _private->directoryPath = copy;
+}
+
- (NSString *)_currentPath
{
return _private->path ? _private->path : _private->tempPath;
diff --git a/WebKit/Downloads.subproj/WebDownloadPrivate.h b/WebKit/Downloads.subproj/WebDownloadPrivate.h
index b385894..76481c5 100644
--- a/WebKit/Downloads.subproj/WebDownloadPrivate.h
+++ b/WebKit/Downloads.subproj/WebDownloadPrivate.h
@@ -12,5 +12,5 @@
@interface WebDownload (WebPrivate)
- _initWithLoadingResource:(WebResource *)resource dataSource:(WebDataSource *)dataSource;
-- (void)_setPath:(NSString *)path;
+- (void)_setDirectoryPath:(NSString *)directoryPath;
@end
diff --git a/WebKit/WebView.subproj/WebControllerPrivate.m b/WebKit/WebView.subproj/WebControllerPrivate.m
index dbb9aa2..2ebca6b 100644
--- a/WebKit/WebView.subproj/WebControllerPrivate.m
+++ b/WebKit/WebView.subproj/WebControllerPrivate.m
@@ -13,6 +13,7 @@
#import <WebKit/WebDefaultPolicyDelegate.h>
#import <WebKit/WebDefaultResourceLoadDelegate.h>
#import <WebKit/WebDefaultWindowOperationsDelegate.h>
+#import <WebKit/WebDownloadPrivate.h>
#import <WebKit/WebFormDelegatePrivate.h>
#import <WebKit/WebFramePrivate.h>
#import <WebKit/WebLocationChangeDelegate.h>
@@ -164,10 +165,9 @@
{
ASSERT(dataSource);
#ifndef NDEBUG
- if (![dataSource isDownloading])
- ASSERT([dataSource webFrame]);
-#endif
-
+ ASSERT([dataSource webFrame]);
+#endif
+
[dataSource _setMainDocumentError: error];
if (isComplete) {
@@ -233,12 +233,18 @@
- (void)_downloadURL:(NSURL *)URL toDirectory:(NSString *)directory
{
ASSERT(URL);
-
- WebRequest *request = [[WebRequest alloc] initWithURL:URL];
- WebFrame *webFrame = [self mainFrame];
- [webFrame _downloadRequest:request toDirectory:directory];
+ WebRequest *request = [[WebRequest alloc] initWithURL:URL];
+ WebDownload *download = [[WebDownload alloc] initWithRequest:request];
[request release];
+
+ if (directory != nil && [directory isAbsolutePath]) {
+ [download _setDirectoryPath:directory];
+ }
+
+ // The download retains itself in loadWithDelegate.
+ [download loadWithDelegate:_private->downloadDelegate];
+ [download release];
}
- (BOOL)defersCallbacks
diff --git a/WebKit/WebView.subproj/WebDataSource.h b/WebKit/WebView.subproj/WebDataSource.h
index 68d967c..767dd10 100644
--- a/WebKit/WebView.subproj/WebDataSource.h
+++ b/WebKit/WebView.subproj/WebDataSource.h
@@ -109,19 +109,6 @@
- (WebError *)mainDocumentError;
/*!
- @method isDownloading
- @result Description forthcoming.
-*/
-- (BOOL)isDownloading;
-
-/*!
- @method downloadPath
- @result Description forthcoming.
-*/
-- (NSString *)downloadPath;
-
-
-/*!
@method registerRepresentationClass:forMIMEType:
@discussion A class that implements WebDocumentRepresentation may be registered
with this method.
diff --git a/WebKit/WebView.subproj/WebDataSource.m b/WebKit/WebView.subproj/WebDataSource.m
index bf78202..a5d9a2b 100644
--- a/WebKit/WebView.subproj/WebDataSource.m
+++ b/WebKit/WebView.subproj/WebDataSource.m
@@ -143,14 +143,4 @@
[[self _repTypes] setObject:repClass forKey:MIMEType];
}
-- (BOOL)isDownloading
-{
- return _private->isDownloading;
-}
-
-- (NSString *)downloadPath
-{
- return [[_private->downloadPath retain] autorelease];
-}
-
@end
diff --git a/WebKit/WebView.subproj/WebDataSourcePrivate.h b/WebKit/WebView.subproj/WebDataSourcePrivate.h
index 55f01e8..b5e9f85 100644
--- a/WebKit/WebView.subproj/WebDataSourcePrivate.h
+++ b/WebKit/WebView.subproj/WebDataSourcePrivate.h
@@ -166,10 +166,6 @@
- (void)_setTriggeringAction:(NSDictionary *)action;
- (WebRequest *)_lastCheckedRequest;
- (void)_setLastCheckedRequest:(WebRequest *)request;
-- (void)_setIsDownloading:(BOOL)isDownloading;
-- (void)_setDownloadPath:(NSString *)downloadPath;
-- (void)_setDownloadDirectory:(NSString *)downloadDirectory;
-- (NSString *)_downloadDirectory;
- (void)_setJustOpenedForTargetedLink:(BOOL)justOpened;
- (BOOL)_justOpenedForTargetedLink;
- (void)_setStoredInPageCache:(BOOL)f;
diff --git a/WebKit/WebView.subproj/WebDataSourcePrivate.m b/WebKit/WebView.subproj/WebDataSourcePrivate.m
index 71c9e94..f2b89e3 100644
--- a/WebKit/WebView.subproj/WebDataSourcePrivate.m
+++ b/WebKit/WebView.subproj/WebDataSourcePrivate.m
@@ -477,7 +477,7 @@
- (void)_commitIfReady: (NSDictionary *)pageCache
{
- if (_private->loadingFromPageCache || (![self isDownloading] && _private->gotFirstByte && !_private->committed)) {
+ if (_private->loadingFromPageCache || (_private->gotFirstByte && !_private->committed)) {
WebFrame *frame = [self webFrame];
WebFrameLoadType loadType = [frame _loadType];
bool reload = loadType == WebFrameLoadTypeReload
@@ -672,45 +672,6 @@
[oldRequest release];
}
-- (void)_setIsDownloading:(BOOL)isDownloading
-{
- _private->isDownloading = isDownloading;
-}
-
-- (void)_setDownloadPath:(NSString *)downloadPath
-{
- if (_private->downloadPath == downloadPath) {
- return;
- }
- [_private->downloadPath release];
- _private->downloadPath = [downloadPath copy];
-
- // Have either a download path or directory, not both at once.
- [_private->downloadDirectory release];
- _private->downloadDirectory = nil;
-}
-
-- (void)_setDownloadDirectory:(NSString *)downloadDirectory
-{
- ASSERT(_private->downloadPath == nil);
-
- if (_private->downloadDirectory == downloadDirectory) {
- return;
- }
- [_private->downloadDirectory release];
- _private->downloadDirectory = [downloadDirectory copy];
-}
-
-- (NSString *)_downloadDirectory
-{
- if (_private->downloadPath) {
- ASSERT(_private->downloadDirectory == nil);
- return [_private->downloadPath stringByDeletingLastPathComponent];
- }
-
- return _private->downloadDirectory;
-}
-
- (void)_setJustOpenedForTargetedLink:(BOOL)justOpened
{
_private->justOpenedForTargetedLink = justOpened;
diff --git a/WebKit/WebView.subproj/WebFramePrivate.h b/WebKit/WebView.subproj/WebFramePrivate.h
index 4f3c746..8d9ac12 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.h
+++ b/WebKit/WebView.subproj/WebFramePrivate.h
@@ -152,8 +152,6 @@ typedef enum {
- (void)_loadDataSource:(WebDataSource *)dataSource withLoadType:(WebFrameLoadType)type formState:(WebFormState *)formState;
-- (void)_downloadRequest:(WebRequest *)request toDirectory:(NSString *)directory;
-
- (void)_setJustOpenedForTargetedLink:(BOOL)justOpened;
- (void)_setProvisionalDataSource: (WebDataSource *)d;
diff --git a/WebKit/WebView.subproj/WebFramePrivate.m b/WebKit/WebView.subproj/WebFramePrivate.m
index 7c296d1..535fb0c 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.m
+++ b/WebKit/WebView.subproj/WebFramePrivate.m
@@ -1768,8 +1768,7 @@ static CFAbsoluteTime _timeOfLastCompletedLoad;
// to KDE parser requiring a KHTMLView. Once we settle on a final
// KDE drop we should fix this dependency.
- // This is commented out because for the download reload feature, we need to be able to start a load without a WebView involved.
- //ASSERT([self webView] != nil);
+ ASSERT([self webView] != nil);
[self stopLoading];
@@ -1789,20 +1788,6 @@ static CFAbsoluteTime _timeOfLastCompletedLoad;
[self _checkNavigationPolicyForRequest:[newDataSource request] dataSource:newDataSource formState:formState andCall:self withSelector:@selector(_continueLoadRequestAfterNavigationPolicy:formState:)];
}
-- (void)_downloadRequest:(WebRequest *)request toDirectory:(NSString *)directory
-{
- WebDataSource *dataSource = [[WebDataSource alloc] initWithRequest:request];
- [dataSource _setIsDownloading:YES];
-
- if (directory != nil && [directory isAbsolutePath]) {
- [dataSource _setDownloadDirectory:directory];
- }
-
- [self _loadDataSource:dataSource withLoadType:WebFrameLoadTypeStandard formState:nil];
-
- [dataSource release];
-}
-
- (void)_setJustOpenedForTargetedLink:(BOOL)justOpened
{
_private->justOpenedForTargetedLink = justOpened;
diff --git a/WebKit/WebView.subproj/WebMainResourceClient.m b/WebKit/WebView.subproj/WebMainResourceClient.m
index e8513c1..c29e4ad 100644
--- a/WebKit/WebView.subproj/WebMainResourceClient.m
+++ b/WebKit/WebView.subproj/WebMainResourceClient.m
@@ -170,20 +170,13 @@
break;
case WebPolicySave:
- ASSERT([self downloadDelegate]);
-
+ {
WebDownload *download = [[WebDownload alloc] _initWithLoadingResource:resource dataSource:dataSource];
- NSString *directory = [dataSource _downloadDirectory];
- if (directory != nil && [directory isAbsolutePath]) {
- // FIXME: Predetermined downloads should not be using this code path (3191052).
- NSString *path = [directory stringByAppendingPathComponent:[r suggestedFilenameForSaving]];
- [download _setPath:path];
- }
-
[proxy setDelegate:(id <WebResourceDelegate>)download];
[download release];
[self interruptForPolicyChangeAndKeepLoading:YES];
+ }
break;
case WebPolicyIgnore:
@@ -224,20 +217,15 @@
{
ASSERT(![h defersCallbacks]);
ASSERT(![self defersCallbacks]);
- ASSERT([dataSource isDownloading] || ![[dataSource _controller] defersCallbacks]);
+ ASSERT(![[dataSource _controller] defersCallbacks]);
[dataSource _setResponse:r];
LOG(Loading, "main content type: %@", [r contentType]);
[[dataSource _controller] setDefersCallbacks:YES];
- // FIXME: Predetermined downloads should not be using this code path (3191052).
// Figure out the content policy.
- if (![dataSource isDownloading]) {
- [self checkContentPolicyForResponse:r andCallSelector:@selector(continueAfterContentPolicy:response:)];
- } else {
- [self continueAfterContentPolicy:WebPolicySave response:r];
- }
+ [self checkContentPolicyForResponse:r andCallSelector:@selector(continueAfterContentPolicy:response:)];
_contentLength = [r contentLength];
}
diff --git a/WebKit/WebView.subproj/WebMainResourceLoader.m b/WebKit/WebView.subproj/WebMainResourceLoader.m
index e8513c1..c29e4ad 100644
--- a/WebKit/WebView.subproj/WebMainResourceLoader.m
+++ b/WebKit/WebView.subproj/WebMainResourceLoader.m
@@ -170,20 +170,13 @@
break;
case WebPolicySave:
- ASSERT([self downloadDelegate]);
-
+ {
WebDownload *download = [[WebDownload alloc] _initWithLoadingResource:resource dataSource:dataSource];
- NSString *directory = [dataSource _downloadDirectory];
- if (directory != nil && [directory isAbsolutePath]) {
- // FIXME: Predetermined downloads should not be using this code path (3191052).
- NSString *path = [directory stringByAppendingPathComponent:[r suggestedFilenameForSaving]];
- [download _setPath:path];
- }
-
[proxy setDelegate:(id <WebResourceDelegate>)download];
[download release];
[self interruptForPolicyChangeAndKeepLoading:YES];
+ }
break;
case WebPolicyIgnore:
@@ -224,20 +217,15 @@
{
ASSERT(![h defersCallbacks]);
ASSERT(![self defersCallbacks]);
- ASSERT([dataSource isDownloading] || ![[dataSource _controller] defersCallbacks]);
+ ASSERT(![[dataSource _controller] defersCallbacks]);
[dataSource _setResponse:r];
LOG(Loading, "main content type: %@", [r contentType]);
[[dataSource _controller] setDefersCallbacks:YES];
- // FIXME: Predetermined downloads should not be using this code path (3191052).
// Figure out the content policy.
- if (![dataSource isDownloading]) {
- [self checkContentPolicyForResponse:r andCallSelector:@selector(continueAfterContentPolicy:response:)];
- } else {
- [self continueAfterContentPolicy:WebPolicySave response:r];
- }
+ [self checkContentPolicyForResponse:r andCallSelector:@selector(continueAfterContentPolicy:response:)];
_contentLength = [r contentLength];
}
diff --git a/WebKit/WebView.subproj/WebViewPrivate.m b/WebKit/WebView.subproj/WebViewPrivate.m
index dbb9aa2..2ebca6b 100644
--- a/WebKit/WebView.subproj/WebViewPrivate.m
+++ b/WebKit/WebView.subproj/WebViewPrivate.m
@@ -13,6 +13,7 @@
#import <WebKit/WebDefaultPolicyDelegate.h>
#import <WebKit/WebDefaultResourceLoadDelegate.h>
#import <WebKit/WebDefaultWindowOperationsDelegate.h>
+#import <WebKit/WebDownloadPrivate.h>
#import <WebKit/WebFormDelegatePrivate.h>
#import <WebKit/WebFramePrivate.h>
#import <WebKit/WebLocationChangeDelegate.h>
@@ -164,10 +165,9 @@
{
ASSERT(dataSource);
#ifndef NDEBUG
- if (![dataSource isDownloading])
- ASSERT([dataSource webFrame]);
-#endif
-
+ ASSERT([dataSource webFrame]);
+#endif
+
[dataSource _setMainDocumentError: error];
if (isComplete) {
@@ -233,12 +233,18 @@
- (void)_downloadURL:(NSURL *)URL toDirectory:(NSString *)directory
{
ASSERT(URL);
-
- WebRequest *request = [[WebRequest alloc] initWithURL:URL];
- WebFrame *webFrame = [self mainFrame];
- [webFrame _downloadRequest:request toDirectory:directory];
+ WebRequest *request = [[WebRequest alloc] initWithURL:URL];
+ WebDownload *download = [[WebDownload alloc] initWithRequest:request];
[request release];
+
+ if (directory != nil && [directory isAbsolutePath]) {
+ [download _setDirectoryPath:directory];
+ }
+
+ // The download retains itself in loadWithDelegate.
+ [download loadWithDelegate:_private->downloadDelegate];
+ [download release];
}
- (BOOL)defersCallbacks
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list