[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

rjw rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 06:53:31 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit dc2735d8604dd89c52f983da45a5630108c64b4f
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Oct 24 05:16:33 2002 +0000

            Cleaned up months of accumulated cruft.
            Added base class to the three WebResourceHandleDelegate implementors.
            Removed superfluous handle references to controller callbacks.
            More can still be done.
            All in the name of fixing 3076050.
    
            * Misc.subproj/WebKitErrors.h:
            * Plugins.subproj/WebBaseNetscapePluginStream.m:
            (-[WebBaseNetscapePluginStream setResponse:]):
            * Plugins.subproj/WebNetscapePluginRepresentation.m:
            (-[WebNetscapePluginRepresentation receivedData:withDataSource:]):
            (-[WebNetscapePluginRepresentation receivedError:withDataSource:]):
            (-[WebNetscapePluginRepresentation finishedLoadingWithDataSource:]):
            * Plugins.subproj/WebNetscapePluginStream.h:
            * Plugins.subproj/WebNetscapePluginStream.m:
            (-[WebNetscapePluginStream initWithRequest:pluginPointer:notifyData:]):
            (-[WebNetscapePluginStream dealloc]):
            (-[WebNetscapePluginStream start]):
            (-[WebNetscapePluginStream stop]):
            (-[WebNetscapePluginStream handle:willSendRequest:]):
            (-[WebNetscapePluginStream handle:didReceiveResponse:]):
            (-[WebNetscapePluginStream handle:didReceiveData:]):
            (-[WebNetscapePluginStream handleDidFinishLoading:]):
            (-[WebNetscapePluginStream handle:didFailLoadingWithError:]):
            * WebCoreSupport.subproj/WebBridge.m:
            (-[WebBridge reportBadURL:]):
            * WebCoreSupport.subproj/WebSubresourceClient.h:
            * WebCoreSupport.subproj/WebSubresourceClient.m:
            (-[WebSubresourceClient initWithLoader:dataSource:]):
            (-[WebSubresourceClient dealloc]):
            (+[WebSubresourceClient startLoadingResource:withURL:referrer:forDataSource:]):
            (-[WebSubresourceClient receivedError:]):
            (-[WebSubresourceClient handle:willSendRequest:]):
            (-[WebSubresourceClient handle:didReceiveResponse:]):
            (-[WebSubresourceClient handle:didReceiveData:]):
            (-[WebSubresourceClient handleDidFinishLoading:]):
            (-[WebSubresourceClient handle:didFailLoadingWithError:]):
            (-[WebSubresourceClient cancel]):
            * WebView.subproj/WebBaseResourceHandleDelegate.h:
            * WebView.subproj/WebBaseResourceHandleDelegate.m:
            (-[WebBaseResourceHandleDelegate init]):
            (-[WebBaseResourceHandleDelegate _releaseResources]):
            (-[WebBaseResourceHandleDelegate dealloc]):
            (-[WebBaseResourceHandleDelegate setDataSource:]):
            (-[WebBaseResourceHandleDelegate dataSource]):
            (-[WebBaseResourceHandleDelegate resourceLoadDelegate]):
            (-[WebBaseResourceHandleDelegate downloadDelegate]):
            (-[WebBaseResourceHandleDelegate setIsDownload:]):
            (-[WebBaseResourceHandleDelegate isDownload]):
            (-[WebBaseResourceHandleDelegate handle:willSendRequest:]):
            (-[WebBaseResourceHandleDelegate handle:didReceiveResponse:]):
            (-[WebBaseResourceHandleDelegate handle:didReceiveData:]):
            (-[WebBaseResourceHandleDelegate handleDidFinishLoading:]):
            (-[WebBaseResourceHandleDelegate handle:didFailLoadingWithError:]):
            (-[WebBaseResourceHandleDelegate cancel]):
            (-[WebBaseResourceHandleDelegate handle]):
            * WebView.subproj/WebControllerPrivate.h:
            * WebView.subproj/WebControllerPrivate.m:
            (-[WebController _mainReceivedBytesSoFar:fromDataSource:complete:]):
            (-[WebController _receivedError:fromDataSource:]):
            (-[WebController _mainReceivedError:fromDataSource:]):
            * WebView.subproj/WebDataSource.h:
            * WebView.subproj/WebDataSource.m:
            * WebView.subproj/WebDataSourcePrivate.h:
            * WebView.subproj/WebDataSourcePrivate.m:
            (-[WebDataSourcePrivate dealloc]):
            (-[WebDataSource _startLoading]):
            (-[WebDataSource _stopLoading]):
            (-[WebDataSource _clearErrors]):
            * WebView.subproj/WebFramePrivate.m:
            (-[WebFrame _isLoadComplete]):
            * WebView.subproj/WebMainResourceClient.h:
            * WebView.subproj/WebMainResourceClient.m:
            (-[WebMainResourceClient initWithDataSource:]):
            (-[WebMainResourceClient dealloc]):
            (-[WebMainResourceClient receivedError:]):
            (-[WebMainResourceClient cancel]):
            (-[WebMainResourceClient handle:willSendRequest:]):
            (-[WebMainResourceClient _notifyDelegatesOfInterruptionByPolicyChange]):
            (-[WebMainResourceClient handle:didReceiveResponse:]):
            (-[WebMainResourceClient handle:didReceiveData:]):
            (-[WebMainResourceClient handleDidFinishLoading:]):
            (-[WebMainResourceClient handle:didFailLoadingWithError:]):
            * WebView.subproj/WebResourceLoadDelegate.h:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2443 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index e375d59..55d9052 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,90 @@
+2002-10-23  Richard Williamson  <rjw at apple.com>
+
+        Cleaned up months of accumulated cruft.
+        Added base class to the three WebResourceHandleDelegate implementors.
+        Removed superfluous handle references to controller callbacks.
+        More can still be done.
+        All in the name of fixing 3076050.
+        
+        * Misc.subproj/WebKitErrors.h:
+        * Plugins.subproj/WebBaseNetscapePluginStream.m:
+        (-[WebBaseNetscapePluginStream setResponse:]):
+        * Plugins.subproj/WebNetscapePluginRepresentation.m:
+        (-[WebNetscapePluginRepresentation receivedData:withDataSource:]):
+        (-[WebNetscapePluginRepresentation receivedError:withDataSource:]):
+        (-[WebNetscapePluginRepresentation finishedLoadingWithDataSource:]):
+        * Plugins.subproj/WebNetscapePluginStream.h:
+        * Plugins.subproj/WebNetscapePluginStream.m:
+        (-[WebNetscapePluginStream initWithRequest:pluginPointer:notifyData:]):
+        (-[WebNetscapePluginStream dealloc]):
+        (-[WebNetscapePluginStream start]):
+        (-[WebNetscapePluginStream stop]):
+        (-[WebNetscapePluginStream handle:willSendRequest:]):
+        (-[WebNetscapePluginStream handle:didReceiveResponse:]):
+        (-[WebNetscapePluginStream handle:didReceiveData:]):
+        (-[WebNetscapePluginStream handleDidFinishLoading:]):
+        (-[WebNetscapePluginStream handle:didFailLoadingWithError:]):
+        * WebCoreSupport.subproj/WebBridge.m:
+        (-[WebBridge reportBadURL:]):
+        * WebCoreSupport.subproj/WebSubresourceClient.h:
+        * WebCoreSupport.subproj/WebSubresourceClient.m:
+        (-[WebSubresourceClient initWithLoader:dataSource:]):
+        (-[WebSubresourceClient dealloc]):
+        (+[WebSubresourceClient startLoadingResource:withURL:referrer:forDataSource:]):
+        (-[WebSubresourceClient receivedError:]):
+        (-[WebSubresourceClient handle:willSendRequest:]):
+        (-[WebSubresourceClient handle:didReceiveResponse:]):
+        (-[WebSubresourceClient handle:didReceiveData:]):
+        (-[WebSubresourceClient handleDidFinishLoading:]):
+        (-[WebSubresourceClient handle:didFailLoadingWithError:]):
+        (-[WebSubresourceClient cancel]):
+        * WebView.subproj/WebBaseResourceHandleDelegate.h:
+        * WebView.subproj/WebBaseResourceHandleDelegate.m:
+        (-[WebBaseResourceHandleDelegate init]):
+        (-[WebBaseResourceHandleDelegate _releaseResources]):
+        (-[WebBaseResourceHandleDelegate dealloc]):
+        (-[WebBaseResourceHandleDelegate setDataSource:]):
+        (-[WebBaseResourceHandleDelegate dataSource]):
+        (-[WebBaseResourceHandleDelegate resourceLoadDelegate]):
+        (-[WebBaseResourceHandleDelegate downloadDelegate]):
+        (-[WebBaseResourceHandleDelegate setIsDownload:]):
+        (-[WebBaseResourceHandleDelegate isDownload]):
+        (-[WebBaseResourceHandleDelegate handle:willSendRequest:]):
+        (-[WebBaseResourceHandleDelegate handle:didReceiveResponse:]):
+        (-[WebBaseResourceHandleDelegate handle:didReceiveData:]):
+        (-[WebBaseResourceHandleDelegate handleDidFinishLoading:]):
+        (-[WebBaseResourceHandleDelegate handle:didFailLoadingWithError:]):
+        (-[WebBaseResourceHandleDelegate cancel]):
+        (-[WebBaseResourceHandleDelegate handle]):
+        * WebView.subproj/WebControllerPrivate.h:
+        * WebView.subproj/WebControllerPrivate.m:
+        (-[WebController _mainReceivedBytesSoFar:fromDataSource:complete:]):
+        (-[WebController _receivedError:fromDataSource:]):
+        (-[WebController _mainReceivedError:fromDataSource:]):
+        * WebView.subproj/WebDataSource.h:
+        * WebView.subproj/WebDataSource.m:
+        * WebView.subproj/WebDataSourcePrivate.h:
+        * WebView.subproj/WebDataSourcePrivate.m:
+        (-[WebDataSourcePrivate dealloc]):
+        (-[WebDataSource _startLoading]):
+        (-[WebDataSource _stopLoading]):
+        (-[WebDataSource _clearErrors]):
+        * WebView.subproj/WebFramePrivate.m:
+        (-[WebFrame _isLoadComplete]):
+        * WebView.subproj/WebMainResourceClient.h:
+        * WebView.subproj/WebMainResourceClient.m:
+        (-[WebMainResourceClient initWithDataSource:]):
+        (-[WebMainResourceClient dealloc]):
+        (-[WebMainResourceClient receivedError:]):
+        (-[WebMainResourceClient cancel]):
+        (-[WebMainResourceClient handle:willSendRequest:]):
+        (-[WebMainResourceClient _notifyDelegatesOfInterruptionByPolicyChange]):
+        (-[WebMainResourceClient handle:didReceiveResponse:]):
+        (-[WebMainResourceClient handle:didReceiveData:]):
+        (-[WebMainResourceClient handleDidFinishLoading:]):
+        (-[WebMainResourceClient handle:didFailLoadingWithError:]):
+        * WebView.subproj/WebResourceLoadDelegate.h:
+
 2002-10-23  Chris Blumenberg  <cblu at apple.com>
 
 	Support for new plug-in API. This is about as much as I can do without the new java plug-in and java root.
diff --git a/WebKit/ChangeLog-2002-12-03 b/WebKit/ChangeLog-2002-12-03
index e375d59..55d9052 100644
--- a/WebKit/ChangeLog-2002-12-03
+++ b/WebKit/ChangeLog-2002-12-03
@@ -1,3 +1,90 @@
+2002-10-23  Richard Williamson  <rjw at apple.com>
+
+        Cleaned up months of accumulated cruft.
+        Added base class to the three WebResourceHandleDelegate implementors.
+        Removed superfluous handle references to controller callbacks.
+        More can still be done.
+        All in the name of fixing 3076050.
+        
+        * Misc.subproj/WebKitErrors.h:
+        * Plugins.subproj/WebBaseNetscapePluginStream.m:
+        (-[WebBaseNetscapePluginStream setResponse:]):
+        * Plugins.subproj/WebNetscapePluginRepresentation.m:
+        (-[WebNetscapePluginRepresentation receivedData:withDataSource:]):
+        (-[WebNetscapePluginRepresentation receivedError:withDataSource:]):
+        (-[WebNetscapePluginRepresentation finishedLoadingWithDataSource:]):
+        * Plugins.subproj/WebNetscapePluginStream.h:
+        * Plugins.subproj/WebNetscapePluginStream.m:
+        (-[WebNetscapePluginStream initWithRequest:pluginPointer:notifyData:]):
+        (-[WebNetscapePluginStream dealloc]):
+        (-[WebNetscapePluginStream start]):
+        (-[WebNetscapePluginStream stop]):
+        (-[WebNetscapePluginStream handle:willSendRequest:]):
+        (-[WebNetscapePluginStream handle:didReceiveResponse:]):
+        (-[WebNetscapePluginStream handle:didReceiveData:]):
+        (-[WebNetscapePluginStream handleDidFinishLoading:]):
+        (-[WebNetscapePluginStream handle:didFailLoadingWithError:]):
+        * WebCoreSupport.subproj/WebBridge.m:
+        (-[WebBridge reportBadURL:]):
+        * WebCoreSupport.subproj/WebSubresourceClient.h:
+        * WebCoreSupport.subproj/WebSubresourceClient.m:
+        (-[WebSubresourceClient initWithLoader:dataSource:]):
+        (-[WebSubresourceClient dealloc]):
+        (+[WebSubresourceClient startLoadingResource:withURL:referrer:forDataSource:]):
+        (-[WebSubresourceClient receivedError:]):
+        (-[WebSubresourceClient handle:willSendRequest:]):
+        (-[WebSubresourceClient handle:didReceiveResponse:]):
+        (-[WebSubresourceClient handle:didReceiveData:]):
+        (-[WebSubresourceClient handleDidFinishLoading:]):
+        (-[WebSubresourceClient handle:didFailLoadingWithError:]):
+        (-[WebSubresourceClient cancel]):
+        * WebView.subproj/WebBaseResourceHandleDelegate.h:
+        * WebView.subproj/WebBaseResourceHandleDelegate.m:
+        (-[WebBaseResourceHandleDelegate init]):
+        (-[WebBaseResourceHandleDelegate _releaseResources]):
+        (-[WebBaseResourceHandleDelegate dealloc]):
+        (-[WebBaseResourceHandleDelegate setDataSource:]):
+        (-[WebBaseResourceHandleDelegate dataSource]):
+        (-[WebBaseResourceHandleDelegate resourceLoadDelegate]):
+        (-[WebBaseResourceHandleDelegate downloadDelegate]):
+        (-[WebBaseResourceHandleDelegate setIsDownload:]):
+        (-[WebBaseResourceHandleDelegate isDownload]):
+        (-[WebBaseResourceHandleDelegate handle:willSendRequest:]):
+        (-[WebBaseResourceHandleDelegate handle:didReceiveResponse:]):
+        (-[WebBaseResourceHandleDelegate handle:didReceiveData:]):
+        (-[WebBaseResourceHandleDelegate handleDidFinishLoading:]):
+        (-[WebBaseResourceHandleDelegate handle:didFailLoadingWithError:]):
+        (-[WebBaseResourceHandleDelegate cancel]):
+        (-[WebBaseResourceHandleDelegate handle]):
+        * WebView.subproj/WebControllerPrivate.h:
+        * WebView.subproj/WebControllerPrivate.m:
+        (-[WebController _mainReceivedBytesSoFar:fromDataSource:complete:]):
+        (-[WebController _receivedError:fromDataSource:]):
+        (-[WebController _mainReceivedError:fromDataSource:]):
+        * WebView.subproj/WebDataSource.h:
+        * WebView.subproj/WebDataSource.m:
+        * WebView.subproj/WebDataSourcePrivate.h:
+        * WebView.subproj/WebDataSourcePrivate.m:
+        (-[WebDataSourcePrivate dealloc]):
+        (-[WebDataSource _startLoading]):
+        (-[WebDataSource _stopLoading]):
+        (-[WebDataSource _clearErrors]):
+        * WebView.subproj/WebFramePrivate.m:
+        (-[WebFrame _isLoadComplete]):
+        * WebView.subproj/WebMainResourceClient.h:
+        * WebView.subproj/WebMainResourceClient.m:
+        (-[WebMainResourceClient initWithDataSource:]):
+        (-[WebMainResourceClient dealloc]):
+        (-[WebMainResourceClient receivedError:]):
+        (-[WebMainResourceClient cancel]):
+        (-[WebMainResourceClient handle:willSendRequest:]):
+        (-[WebMainResourceClient _notifyDelegatesOfInterruptionByPolicyChange]):
+        (-[WebMainResourceClient handle:didReceiveResponse:]):
+        (-[WebMainResourceClient handle:didReceiveData:]):
+        (-[WebMainResourceClient handleDidFinishLoading:]):
+        (-[WebMainResourceClient handle:didFailLoadingWithError:]):
+        * WebView.subproj/WebResourceLoadDelegate.h:
+
 2002-10-23  Chris Blumenberg  <cblu at apple.com>
 
 	Support for new plug-in API. This is about as much as I can do without the new java plug-in and java root.
diff --git a/WebKit/Misc.subproj/WebKitErrors.h b/WebKit/Misc.subproj/WebKitErrors.h
index 7cd014f..44e0878 100644
--- a/WebKit/Misc.subproj/WebKitErrors.h
+++ b/WebKit/Misc.subproj/WebKitErrors.h
@@ -39,5 +39,6 @@ enum {
     WebErrorCannotShowMIMEType = 10009,
     WebErrorCannotShowURL = 10010,
     WebErrorCannotNotFindApplicationForURL = 10011,
-    WebErrorLocationChangeInterruptedByPolicyChange = 10012
+    WebErrorLocationChangeInterruptedByPolicyChange = 10012,
+    WebErrorResourceLoadInterruptedByPolicyChange = 10013
 };
diff --git a/WebKit/Plugins.subproj/WebBaseNetscapePluginStream.m b/WebKit/Plugins.subproj/WebBaseNetscapePluginStream.m
index bb1df17..c46b379 100644
--- a/WebKit/Plugins.subproj/WebBaseNetscapePluginStream.m
+++ b/WebKit/Plugins.subproj/WebBaseNetscapePluginStream.m
@@ -42,10 +42,10 @@
     NPP_URLNotify = 	[plugin NPP_URLNotify];
 }
 
-- (void)setResponse:(WebResourceResponse *)response
+- (void)setResponse:(WebResourceResponse *)r
 {
     [URL release];
-    URL = [[response URL] retain];
+    URL = [[r URL] retain];
     
     NSString *URLString = [URL absoluteString];
     char *cURL = (char *)malloc([URLString cStringLength]+1);
@@ -54,7 +54,7 @@
     uint32 lastModified = 0;
 
     if ([response isKindOfClass:[WebHTTPResourceResponse class]]) {
-        NSNumber *timeInterval = [[(WebHTTPResourceResponse *)response headers] objectForKey:@"Last-Modified"];
+        NSNumber *timeInterval = [[(WebHTTPResourceResponse *)r headers] objectForKey:@"Last-Modified"];
         if(timeInterval) {
             NSTimeInterval lastModifiedInterval;
             lastModifiedInterval = [[NSDate dateWithTimeIntervalSinceReferenceDate:[timeInterval doubleValue]] timeIntervalSince1970];
@@ -66,14 +66,14 @@
 
     stream.ndata = self;
     stream.URL = cURL;
-    stream.end = [response contentLength];
+    stream.end = [r contentLength];
     stream.lastmodified = lastModified;
     stream.notifyData = notifyData;
 
     // FIXME: Need a way to check if stream is seekable
 
     NPError npErr;
-    npErr = NPP_NewStream(instance, (char *)[[response contentType] cString], &stream, NO, &transferMode);
+    npErr = NPP_NewStream(instance, (char *)[[r contentType] cString], &stream, NO, &transferMode);
     LOG(Plugins, "NPP_NewStream: %d %@", npErr, URL);
 
     if (npErr != NPERR_NO_ERROR) {
diff --git a/WebKit/Plugins.subproj/WebNetscapePluginRepresentation.m b/WebKit/Plugins.subproj/WebNetscapePluginRepresentation.m
index 9957c78..939bf03 100644
--- a/WebKit/Plugins.subproj/WebNetscapePluginRepresentation.m
+++ b/WebKit/Plugins.subproj/WebNetscapePluginRepresentation.m
@@ -17,16 +17,16 @@
 {
 }
 
-- (void)receivedData:(NSData *)data withDataSource:(WebDataSource *)dataSource
+- (void)receivedData:(NSData *)data withDataSource:(WebDataSource *)ds
 {
     if(!instance){
-        [self setPluginPointer:[(WebNetscapePluginDocumentView *)[[[dataSource webFrame] webView] documentView] pluginPointer]];
-        [self setResponse:[dataSource response]];
+        [self setPluginPointer:[(WebNetscapePluginDocumentView *)[[[ds webFrame] webView] documentView] pluginPointer]];
+        [self setResponse:[ds response]];
     }
     [self receivedData:data];
 }
 
-- (void)receivedError:(WebError *)error withDataSource:(WebDataSource *)dataSource
+- (void)receivedError:(WebError *)error withDataSource:(WebDataSource *)ds
 {
     if([error errorCode] == WebErrorCodeCancelled){
         [self receivedError:NPRES_USER_BREAK];
@@ -35,9 +35,9 @@
     }
 }
 
-- (void)finishedLoadingWithDataSource:(WebDataSource *)dataSource
+- (void)finishedLoadingWithDataSource:(WebDataSource *)ds
 {
-    [self finishedLoadingWithData:[dataSource data]];
+    [self finishedLoadingWithData:[ds data]];
 }
 
 @end
diff --git a/WebKit/Plugins.subproj/WebNetscapePluginStream.h b/WebKit/Plugins.subproj/WebNetscapePluginStream.h
index c8acd67..1a2b9b2 100644
--- a/WebKit/Plugins.subproj/WebNetscapePluginStream.h
+++ b/WebKit/Plugins.subproj/WebNetscapePluginStream.h
@@ -16,13 +16,7 @@
 @interface WebNetscapePluginStream : WebBaseNetscapePluginStream 
 {
     WebNetscapePluginEmbeddedView *view;
-    
-    WebResourceRequest *request;
-    WebResourceHandle *resource;
-    
     NSMutableData *resourceData;
-
-    NSURL *currentURL;
 }
 
 - initWithRequest:(WebResourceRequest *)theRequest
diff --git a/WebKit/Plugins.subproj/WebNetscapePluginStream.m b/WebKit/Plugins.subproj/WebNetscapePluginStream.m
index e213c82..86dc3e8 100644
--- a/WebKit/Plugins.subproj/WebNetscapePluginStream.m
+++ b/WebKit/Plugins.subproj/WebNetscapePluginStream.m
@@ -12,12 +12,6 @@
 
 @implementation WebNetscapePluginStream
 
-- (void)setCurrentURL:(NSURL *)theCurrentURL
-{
-    [currentURL release];
-    currentURL = [theCurrentURL retain];
-}
-
 - initWithRequest:(WebResourceRequest *)theRequest
     pluginPointer:(NPP)thePluginPointer
        notifyData:(void *)theNotifyData
@@ -30,12 +24,12 @@
 
     request = [theRequest retain];
 
-    [self setCurrentURL:[theRequest URL]];
-    
     [self setPluginPointer:thePluginPointer];
 
     view = [(WebNetscapePluginEmbeddedView *)instance->ndata retain];
 
+    [self setDataSource: [view dataSource]];
+
     notifyData = theNotifyData;
     resourceData = [[NSMutableData alloc] init];
 
@@ -45,16 +39,13 @@
 - (void)dealloc
 {
     [resourceData release];
-    [request release];
-    [currentURL release];
     [super dealloc];
 }
 
 - (void)start
 {
-    resource = [[WebResourceHandle alloc] initWithRequest:request];
-    [resource loadWithDelegate:self];
-    [[view controller] _didStartLoading:currentURL];
+    handle = [[WebResourceHandle alloc] initWithRequest:request];
+    [handle loadWithDelegate:self];
 }
 
 - (void)stop
@@ -62,76 +53,60 @@
     [view release];
     view = nil;
     
-    if (!resource) {
+    if (!handle) {
         return;
     }
 
     // Stopped while loading.
-
-    [resource cancel];
+    [handle cancel];
 
     WebController *controller = [view controller];
 
     WebError *cancelError = [[WebError alloc] initWithErrorCode:WebErrorCodeCancelled
                                                        inDomain:WebErrorDomainWebFoundation
                                                      failingURL:nil];
-    [controller _receivedError:cancelError
-             forResourceHandle:resource
-                fromDataSource:[view dataSource]];
+    [controller _receivedError:cancelError fromDataSource:[view dataSource]];
 
     [cancelError release];
 
-    [resource release];
-    resource = nil;
+    [handle release];
+    handle = nil;
 
     if(URL){
         // Send error only if the response has been set (the URL is set with the response).
         [self receivedError:NPRES_USER_BREAK];
     }
-
-    [controller _didStopLoading:currentURL];
 }
 
-- (void)loadEnded
+- (WebResourceRequest *)handle:(WebResourceHandle *)h willSendRequest:(WebResourceRequest *)theRequest
 {
-    [resource release];
-    resource = nil;
-
-    [self stop];
+    return [super handle: h willSendRequest: theRequest];
 }
 
-- (WebResourceRequest *)handle:(WebResourceHandle *)handle willSendRequest:(WebResourceRequest *)theRequest
+- (void)handle:(WebResourceHandle *)h didReceiveResponse:(WebResourceResponse *)theResponse
 {
-    WebController *webController = [view controller];
-
-    [webController _didStopLoading:currentURL];
-
-    [self setCurrentURL:[theRequest URL]];
-
-    [webController _didStartLoading:currentURL];
+    ASSERT(handle == h);
     
-    return theRequest;
-}
-
-- (void)handle:(WebResourceHandle *)handle didReceiveResponse:(WebResourceResponse *)theResponse
-{
     [self setResponse:theResponse];
+    [super handle: h didReceiveResponse: theResponse];    
 }
 
-- (void)handle:(WebResourceHandle *)handle didReceiveData:(NSData *)data
+- (void)handle:(WebResourceHandle *)h didReceiveData:(NSData *)data
 {
-    ASSERT(resource == handle);
+    ASSERT(handle == h);
 
     if(transferMode == NP_ASFILE || transferMode == NP_ASFILEONLY) {
         [resourceData appendData:data];
     }
     
     [self receivedData:data];
+
+    [super handle: handle didReceiveData: data];
 }
 
-- (void)handleDidFinishLoading:(WebResourceHandle *)handle
+- (void)handleDidFinishLoading:(WebResourceHandle *)h
 {
-    ASSERT(resource == handle);
+    ASSERT(handle == h);
 
     WebController *controller = [view controller];
 
@@ -139,25 +114,26 @@
 
     [self finishedLoadingWithData:resourceData];
 
-    [controller _didStopLoading:currentURL];
-
-    [self loadEnded];
+    [view release];
+    view = nil;
+    
+    [super handleDidFinishLoading: h];
 }
 
-- (void)handle:(WebResourceHandle *)handle didFailLoadingWithError:(WebError *)result
+- (void)handle:(WebResourceHandle *)h didFailLoadingWithError:(WebError *)result
 {
-    ASSERT(resource == handle);
+    ASSERT(handle == h);
 
     WebController *controller = [view controller];
 
-    [controller _receivedError: result forResourceHandle: handle
-                fromDataSource: [view dataSource]];
+    [controller _receivedError: result fromDataSource: [view dataSource]];
 
     [self receivedError:NPRES_NETWORK_ERR];
 
-    [controller _didStopLoading:currentURL];
-
-    [self loadEnded];
+    [view release];
+    view = nil;
+    
+    [super handle: h didFailLoadingWithError: result];
 }
 
 @end
diff --git a/WebKit/WebCoreSupport.subproj/WebBridge.m b/WebKit/WebCoreSupport.subproj/WebBridge.m
index 33e0d03..31d840b 100644
--- a/WebKit/WebCoreSupport.subproj/WebBridge.m
+++ b/WebKit/WebCoreSupport.subproj/WebBridge.m
@@ -351,7 +351,6 @@
                                                         inDomain:WebErrorDomainWebFoundation
                                                         failingURL:badURL];
     [[frame controller] _receivedError:badURLError
-                        forResourceHandle:nil
                         fromDataSource:[self dataSource]];
     [badURLError release];
 }
diff --git a/WebKit/WebCoreSupport.subproj/WebSubresourceClient.h b/WebKit/WebCoreSupport.subproj/WebSubresourceClient.h
index 09ff7be..e8f2248 100644
--- a/WebKit/WebCoreSupport.subproj/WebSubresourceClient.h
+++ b/WebKit/WebCoreSupport.subproj/WebSubresourceClient.h
@@ -15,21 +15,9 @@
 @interface WebSubresourceClient : WebBaseResourceHandleDelegate <WebCoreResourceHandle>
 {
     id <WebCoreResourceLoader> loader;
-    WebDataSource *dataSource;
-    NSURL *currentURL;
-    WebResourceHandle *handle;
-
-    // Both of these delegates are retained by the client.
-    id <WebResourceLoadDelegate> resourceProgressDelegate;
-    WebResourceRequest *request;
-    WebResourceResponse *response;
-    
-    id identifier;
 }
 
 + (WebSubresourceClient *)startLoadingResource:(id <WebCoreResourceLoader>)rLoader
     withURL:(NSURL *)URL referrer:(NSString *)referrer forDataSource:(WebDataSource *)source;
 
-- (WebResourceHandle *)handle;
-
 @end
diff --git a/WebKit/WebCoreSupport.subproj/WebSubresourceClient.m b/WebKit/WebCoreSupport.subproj/WebSubresourceClient.m
index 13cc9be..fb10096 100644
--- a/WebKit/WebCoreSupport.subproj/WebSubresourceClient.m
+++ b/WebKit/WebCoreSupport.subproj/WebSubresourceClient.m
@@ -28,9 +28,8 @@
     [super init];
     
     loader = [l retain];
-    dataSource = [s retain];
 
-    resourceProgressDelegate = [[[dataSource controller] resourceLoadDelegate] retain];
+    [self setDataSource: s];
     
     return self;
 }
@@ -40,31 +39,10 @@
     ASSERT(currentURL == nil);
     
     [loader release];
-    [dataSource release];
-    [handle release];
-    [request release];
-    [response release];
-    [resourceProgressDelegate release];
     
     [super dealloc];
 }
 
-- (void)didStartLoadingWithURL:(NSURL *)URL
-{
-    ASSERT(currentURL == nil);
-    currentURL = [URL retain];
-    [[dataSource controller] _didStartLoading:currentURL];
-}
-
-- (void)didStopLoading
-{
-    ASSERT(currentURL != nil);
-    [[dataSource controller] _didStopLoading:currentURL];
-    [currentURL release];
-    currentURL = nil;
-}
-
-
 + (WebSubresourceClient *)startLoadingResource:(id <WebCoreResourceLoader>)rLoader
     withURL:(NSURL *)URL referrer:(NSString *)referrer forDataSource:(WebDataSource *)source
 {
@@ -83,16 +61,13 @@
         WebError *badURLError = [[WebError alloc] initWithErrorCode:WebErrorCodeBadURLError
                                                            inDomain:WebErrorDomainWebFoundation
                                                          failingURL:[URL absoluteString]];
-        [[source controller] _receivedError:badURLError forResourceHandle:nil
-            fromDataSource:source];
+        [[source controller] _receivedError:badURLError fromDataSource:source];
         [badURLError release];
         return nil;
     }
     
     WebResourceHandle *h = [[WebResourceHandle alloc] initWithRequest:newRequest];
-    client->handle = h;
     [source _addSubresourceClient:client];
-    [client didStartLoadingWithURL:[newRequest URL]];
     [h loadWithDelegate:client];
     [newRequest release];
         
@@ -101,14 +76,11 @@
 
 - (void)receivedError:(WebError *)error
 {
-    [[dataSource controller] _receivedError:error forResourceHandle:handle
-        fromDataSource:dataSource];
+    [[dataSource controller] _receivedError:error fromDataSource:dataSource];
 }
 
 -(WebResourceRequest *)handle:(WebResourceHandle *)h willSendRequest:(WebResourceRequest *)newRequest
 {
-    ASSERT(handle == h);
-
     // FIXME: We do want to tell the client about redirects for subresources.
     // But the current API doesn't give any way to tell redirects on
     // the main page from redirects on subresources.
@@ -117,34 +89,7 @@
     // properly on redirect when we have the new redirect
     // request-adjusting API
 
-    WebController *controller = [dataSource controller];
-    NSURL *URL = [request URL];
-
-    [newRequest setUserAgent:[controller userAgentForURL:URL]];
-
-    // Not the first send, so reload.
-    if (request) {
-        [self didStopLoading];
-        [self didStartLoadingWithURL:URL];
-    }
-
-    // Let the resourceProgressDelegate get a crack at modifying the request.
-    if (resourceProgressDelegate){
-        if (identifier == nil){
-            // The identifier is released after the last callback, rather than in dealloc
-            // to avoid potential cycles.
-            identifier = [[resourceProgressDelegate identifierForInitialRequest: newRequest fromDataSource: dataSource] retain];
-        }
-        newRequest = [resourceProgressDelegate resource: identifier willSendRequest: newRequest fromDataSource: dataSource];
-    }
-        
-    ASSERT (newRequest != nil); 
-
-    [newRequest retain];
-    [request release];
-    request = newRequest;
-
-    return newRequest;
+    return [super handle: h willSendRequest: newRequest];
 }
 
 -(void)handle:(WebResourceHandle *)h didReceiveResponse:(WebResourceResponse *)r
@@ -152,22 +97,18 @@
     ASSERT(handle == h);
     ASSERT(r);
 
-    [r retain];
-    [response release];
-    response = r;
-    [resourceProgressDelegate resource:identifier didReceiveResponse:r fromDataSource: dataSource];
-
     [loader receivedResponse:r];
+
+    [super handle: handle didReceiveResponse: r];
 }
 
 - (void)handle:(WebResourceHandle *)h didReceiveData:(NSData *)data
 {
     ASSERT(handle == h);
 
-    [resourceProgressDelegate resource: identifier didReceiveContentLength: [data length] 
-        fromDataSource: dataSource];
-
     [loader addData:data];
+
+    [super handle: handle didReceiveData: data];
 }
 
 - (void)handleDidFinishLoading:(WebResourceHandle *)h
@@ -186,19 +127,11 @@
         [self receivedError:nonTerminalError];
     }
     
-    [resourceProgressDelegate resource:identifier didFinishLoadingFromDataSource:dataSource];
-
     [[dataSource controller] _finsishedLoadingResourceFromDataSource:dataSource];
     
-    [self didStopLoading];
-
-    [handle release];
-    handle = nil;
-    
-    [identifier release];
-    identifier = nil;
-    
     [self release];
+    
+    [super handleDidFinishLoading: h];
 }
 
 - (void)handle:(WebResourceHandle *)h didFailLoadingWithError:(WebError *)error
@@ -211,19 +144,11 @@
     [loader cancel];
     
     [dataSource _removeSubresourceClient:self];
-
-    [resourceProgressDelegate resource: identifier didFailLoadingWithError: error fromDataSource: dataSource];
     
     [self receivedError:error];
 
-    [self didStopLoading];
+    [super handle: handle didFailLoadingWithError: error];
 
-    [handle release];
-    handle = nil;
-
-    [identifier release];
-    identifier = nil;
-        
     [self release];
 }
 
@@ -231,9 +156,7 @@
 {
     // Calling _removeSubresourceClient will likely result in a call to release, so we must retain.
     [self retain];
-    
-    [handle cancel];
-    
+        
     [loader cancel];
     
     [dataSource _removeSubresourceClient:self];
@@ -242,18 +165,10 @@
         inDomain:WebErrorDomainWebFoundation failingURL:[[request URL] absoluteString]];
     [self receivedError:error];
     [error release];
-
-    [self didStopLoading];
-
-    [handle release];
-    handle = nil;
     
-    [self release];
-}
+    [super cancel];
 
-- (WebResourceHandle *)handle
-{
-    return handle;
+    [self release];
 }
 
 @end
diff --git a/WebKit/WebCoreSupport.subproj/WebSubresourceLoader.h b/WebKit/WebCoreSupport.subproj/WebSubresourceLoader.h
index 09ff7be..e8f2248 100644
--- a/WebKit/WebCoreSupport.subproj/WebSubresourceLoader.h
+++ b/WebKit/WebCoreSupport.subproj/WebSubresourceLoader.h
@@ -15,21 +15,9 @@
 @interface WebSubresourceClient : WebBaseResourceHandleDelegate <WebCoreResourceHandle>
 {
     id <WebCoreResourceLoader> loader;
-    WebDataSource *dataSource;
-    NSURL *currentURL;
-    WebResourceHandle *handle;
-
-    // Both of these delegates are retained by the client.
-    id <WebResourceLoadDelegate> resourceProgressDelegate;
-    WebResourceRequest *request;
-    WebResourceResponse *response;
-    
-    id identifier;
 }
 
 + (WebSubresourceClient *)startLoadingResource:(id <WebCoreResourceLoader>)rLoader
     withURL:(NSURL *)URL referrer:(NSString *)referrer forDataSource:(WebDataSource *)source;
 
-- (WebResourceHandle *)handle;
-
 @end
diff --git a/WebKit/WebCoreSupport.subproj/WebSubresourceLoader.m b/WebKit/WebCoreSupport.subproj/WebSubresourceLoader.m
index 13cc9be..fb10096 100644
--- a/WebKit/WebCoreSupport.subproj/WebSubresourceLoader.m
+++ b/WebKit/WebCoreSupport.subproj/WebSubresourceLoader.m
@@ -28,9 +28,8 @@
     [super init];
     
     loader = [l retain];
-    dataSource = [s retain];
 
-    resourceProgressDelegate = [[[dataSource controller] resourceLoadDelegate] retain];
+    [self setDataSource: s];
     
     return self;
 }
@@ -40,31 +39,10 @@
     ASSERT(currentURL == nil);
     
     [loader release];
-    [dataSource release];
-    [handle release];
-    [request release];
-    [response release];
-    [resourceProgressDelegate release];
     
     [super dealloc];
 }
 
-- (void)didStartLoadingWithURL:(NSURL *)URL
-{
-    ASSERT(currentURL == nil);
-    currentURL = [URL retain];
-    [[dataSource controller] _didStartLoading:currentURL];
-}
-
-- (void)didStopLoading
-{
-    ASSERT(currentURL != nil);
-    [[dataSource controller] _didStopLoading:currentURL];
-    [currentURL release];
-    currentURL = nil;
-}
-
-
 + (WebSubresourceClient *)startLoadingResource:(id <WebCoreResourceLoader>)rLoader
     withURL:(NSURL *)URL referrer:(NSString *)referrer forDataSource:(WebDataSource *)source
 {
@@ -83,16 +61,13 @@
         WebError *badURLError = [[WebError alloc] initWithErrorCode:WebErrorCodeBadURLError
                                                            inDomain:WebErrorDomainWebFoundation
                                                          failingURL:[URL absoluteString]];
-        [[source controller] _receivedError:badURLError forResourceHandle:nil
-            fromDataSource:source];
+        [[source controller] _receivedError:badURLError fromDataSource:source];
         [badURLError release];
         return nil;
     }
     
     WebResourceHandle *h = [[WebResourceHandle alloc] initWithRequest:newRequest];
-    client->handle = h;
     [source _addSubresourceClient:client];
-    [client didStartLoadingWithURL:[newRequest URL]];
     [h loadWithDelegate:client];
     [newRequest release];
         
@@ -101,14 +76,11 @@
 
 - (void)receivedError:(WebError *)error
 {
-    [[dataSource controller] _receivedError:error forResourceHandle:handle
-        fromDataSource:dataSource];
+    [[dataSource controller] _receivedError:error fromDataSource:dataSource];
 }
 
 -(WebResourceRequest *)handle:(WebResourceHandle *)h willSendRequest:(WebResourceRequest *)newRequest
 {
-    ASSERT(handle == h);
-
     // FIXME: We do want to tell the client about redirects for subresources.
     // But the current API doesn't give any way to tell redirects on
     // the main page from redirects on subresources.
@@ -117,34 +89,7 @@
     // properly on redirect when we have the new redirect
     // request-adjusting API
 
-    WebController *controller = [dataSource controller];
-    NSURL *URL = [request URL];
-
-    [newRequest setUserAgent:[controller userAgentForURL:URL]];
-
-    // Not the first send, so reload.
-    if (request) {
-        [self didStopLoading];
-        [self didStartLoadingWithURL:URL];
-    }
-
-    // Let the resourceProgressDelegate get a crack at modifying the request.
-    if (resourceProgressDelegate){
-        if (identifier == nil){
-            // The identifier is released after the last callback, rather than in dealloc
-            // to avoid potential cycles.
-            identifier = [[resourceProgressDelegate identifierForInitialRequest: newRequest fromDataSource: dataSource] retain];
-        }
-        newRequest = [resourceProgressDelegate resource: identifier willSendRequest: newRequest fromDataSource: dataSource];
-    }
-        
-    ASSERT (newRequest != nil); 
-
-    [newRequest retain];
-    [request release];
-    request = newRequest;
-
-    return newRequest;
+    return [super handle: h willSendRequest: newRequest];
 }
 
 -(void)handle:(WebResourceHandle *)h didReceiveResponse:(WebResourceResponse *)r
@@ -152,22 +97,18 @@
     ASSERT(handle == h);
     ASSERT(r);
 
-    [r retain];
-    [response release];
-    response = r;
-    [resourceProgressDelegate resource:identifier didReceiveResponse:r fromDataSource: dataSource];
-
     [loader receivedResponse:r];
+
+    [super handle: handle didReceiveResponse: r];
 }
 
 - (void)handle:(WebResourceHandle *)h didReceiveData:(NSData *)data
 {
     ASSERT(handle == h);
 
-    [resourceProgressDelegate resource: identifier didReceiveContentLength: [data length] 
-        fromDataSource: dataSource];
-
     [loader addData:data];
+
+    [super handle: handle didReceiveData: data];
 }
 
 - (void)handleDidFinishLoading:(WebResourceHandle *)h
@@ -186,19 +127,11 @@
         [self receivedError:nonTerminalError];
     }
     
-    [resourceProgressDelegate resource:identifier didFinishLoadingFromDataSource:dataSource];
-
     [[dataSource controller] _finsishedLoadingResourceFromDataSource:dataSource];
     
-    [self didStopLoading];
-
-    [handle release];
-    handle = nil;
-    
-    [identifier release];
-    identifier = nil;
-    
     [self release];
+    
+    [super handleDidFinishLoading: h];
 }
 
 - (void)handle:(WebResourceHandle *)h didFailLoadingWithError:(WebError *)error
@@ -211,19 +144,11 @@
     [loader cancel];
     
     [dataSource _removeSubresourceClient:self];
-
-    [resourceProgressDelegate resource: identifier didFailLoadingWithError: error fromDataSource: dataSource];
     
     [self receivedError:error];
 
-    [self didStopLoading];
+    [super handle: handle didFailLoadingWithError: error];
 
-    [handle release];
-    handle = nil;
-
-    [identifier release];
-    identifier = nil;
-        
     [self release];
 }
 
@@ -231,9 +156,7 @@
 {
     // Calling _removeSubresourceClient will likely result in a call to release, so we must retain.
     [self retain];
-    
-    [handle cancel];
-    
+        
     [loader cancel];
     
     [dataSource _removeSubresourceClient:self];
@@ -242,18 +165,10 @@
         inDomain:WebErrorDomainWebFoundation failingURL:[[request URL] absoluteString]];
     [self receivedError:error];
     [error release];
-
-    [self didStopLoading];
-
-    [handle release];
-    handle = nil;
     
-    [self release];
-}
+    [super cancel];
 
-- (WebResourceHandle *)handle
-{
-    return handle;
+    [self release];
 }
 
 @end
diff --git a/WebKit/WebView.subproj/WebBaseResourceHandleDelegate.h b/WebKit/WebView.subproj/WebBaseResourceHandleDelegate.h
index c009ca2..0e856eb 100644
--- a/WebKit/WebView.subproj/WebBaseResourceHandleDelegate.h
+++ b/WebKit/WebView.subproj/WebBaseResourceHandleDelegate.h
@@ -5,11 +5,35 @@
 
 #import <Foundation/Foundation.h>
 
+ at class WebDataSource;
+ at class WebResourceHandle;
+ at class WebResourceRequest;
+ at class WebResourceResponse;
+
 @protocol WebResourceHandleDelegate;
+ at protocol WebResourceLoadDelegate;
 
 @interface WebBaseResourceHandleDelegate : NSObject <WebResourceHandleDelegate>
 {
-
+    WebResourceHandle *handle;
+    WebDataSource *dataSource;
+    WebResourceRequest *request;
+    WebResourceResponse *response;
+    id identifier;
+    id <WebResourceLoadDelegate>resourceLoadDelegate;
+    id <WebResourceLoadDelegate>downloadDelegate;
+    NSURL *currentURL;
+    BOOL isDownload;
+    BOOL reachedTerminalState;
 }
 
+- (WebResourceHandle *)handle;
+
+- (void)setDataSource: (WebDataSource *)d;
+- (WebDataSource *)dataSource;
+- (id <WebResourceLoadDelegate>)resourceLoadDelegate;
+- (id <WebResourceLoadDelegate>)downloadDelegate;
+- (void)setIsDownload: (BOOL)f;
+- (void)cancel;
+
 @end
diff --git a/WebKit/WebView.subproj/WebBaseResourceHandleDelegate.m b/WebKit/WebView.subproj/WebBaseResourceHandleDelegate.m
index 449ca02..eba1578 100644
--- a/WebKit/WebView.subproj/WebBaseResourceHandleDelegate.m
+++ b/WebKit/WebView.subproj/WebBaseResourceHandleDelegate.m
@@ -3,9 +3,214 @@
     Copyright (c) 2002, Apple Computer, Inc. All rights reserved.
 */
 
-#import "WebBaseResourceHandleDelegate.h"
+#import <WebFoundation/WebAssertions.h>
+#import <WebFoundation/WebError.h>
+#import <WebFoundation/WebHTTPResourceRequest.h>
+#import <WebFoundation/WebResourceHandle.h>
+#import <WebFoundation/WebResourceRequest.h>
+#import <WebFoundation/WebResourceResponse.h>
+
+#import <WebKit/WebBaseResourceHandleDelegate.h>
+#import <WebKit/WebController.h>
+#import <WebKit/WebDataSource.h>
+#import <WebKit/WebResourceLoadDelegate.h>
+#import <WebKit/WebStandardPanelsPrivate.h>
 
 
 @implementation WebBaseResourceHandleDelegate
 
+- init
+{
+    self = [super init];
+    
+    [self setIsDownload: NO];
+    
+    return self;
+}
+
+- (void)_releaseResources
+{
+    [identifier release];
+    identifier = nil;
+
+    [handle release];
+    handle = nil;
+
+    [dataSource release];
+    dataSource = nil;
+    
+    [resourceLoadDelegate release];
+    resourceLoadDelegate = nil;
+
+    [downloadDelegate release];
+    downloadDelegate = nil;
+    
+    reachedTerminalState = YES;
+}
+
+- (void)dealloc
+{
+    [self _releaseResources];
+    [request release];
+    [response release];
+    [currentURL release];
+}
+
+- (void)setDataSource: (WebDataSource *)d
+{
+    if (d != dataSource){
+        [dataSource release];
+        dataSource = [d retain];
+    }
+    
+    if (resourceLoadDelegate != [[dataSource controller] resourceLoadDelegate]){
+        [resourceLoadDelegate release];
+        resourceLoadDelegate = [[[dataSource controller] resourceLoadDelegate] retain];
+    }
+
+    if (downloadDelegate != [[dataSource controller] downloadDelegate]){
+        [downloadDelegate release];
+        downloadDelegate = [[[dataSource controller] downloadDelegate] retain];
+    }    
+}
+
+- (WebDataSource *)dataSource
+{
+    return dataSource;
+}
+
+- (id <WebResourceLoadDelegate>)resourceLoadDelegate
+{
+    return resourceLoadDelegate;
+}
+
+- (id <WebResourceLoadDelegate>)downloadDelegate
+{
+    return downloadDelegate;
+}
+
+- (void)setIsDownload: (BOOL)f
+{
+    isDownload = f;
+}
+
+- (BOOL)isDownload
+{
+    return isDownload;
+}
+
+-(WebResourceRequest *)handle:(WebResourceHandle *)h willSendRequest:(WebResourceRequest *)newRequest
+{
+    ASSERT (!reachedTerminalState);
+
+    if (!handle){
+        // Retained so we can cancel if necessary.  Released when we
+        // reach a terminal state.
+        handle = [h retain];
+    }
+        
+    [newRequest setUserAgent:[[dataSource controller] userAgentForURL:[newRequest URL]]];
+
+    [newRequest retain];
+    [request release];
+    request = newRequest;
+
+    if (identifier == nil){
+        // The identifier is released after the last callback, rather than in dealloc
+        // to avoid potential cycles.
+        identifier = [[resourceLoadDelegate identifierForInitialRequest: newRequest fromDataSource: dataSource] retain];
+    }
+
+    if (resourceLoadDelegate)
+        newRequest = [resourceLoadDelegate resource: identifier willSendRequest: newRequest fromDataSource: dataSource];
+
+    [[WebStandardPanels sharedStandardPanels] _didStopLoadingURL:currentURL inController: [dataSource controller]];
+    
+    if ([newRequest URL] != currentURL){
+        [currentURL release];
+        currentURL = [[newRequest URL] retain];
+    }
+    
+    [[WebStandardPanels sharedStandardPanels] _didStartLoadingURL:currentURL inController:[dataSource controller]];
+
+    return newRequest;
+}
+
+-(void)handle:(WebResourceHandle *)h didReceiveResponse:(WebResourceResponse *)r
+{
+    ASSERT (handle == h);
+    ASSERT (!reachedTerminalState);
+
+    [r retain];
+    [response release];
+    response = r;
+
+    if (isDownload)
+        [downloadDelegate resource:identifier didReceiveResponse:r fromDataSource: dataSource];
+    else
+        [resourceLoadDelegate resource:identifier didReceiveResponse:r fromDataSource: dataSource];
+}
+
+- (void)handle:(WebResourceHandle *)h didReceiveData:(NSData *)data
+{
+    ASSERT (handle == h);
+    ASSERT (!reachedTerminalState);
+
+    if ([self isDownload])
+        [downloadDelegate resource: identifier didReceiveContentLength: [data length] fromDataSource: dataSource];
+    else
+        [resourceLoadDelegate resource: identifier didReceiveContentLength: [data length] fromDataSource: dataSource];
+}
+
+- (void)handleDidFinishLoading:(WebResourceHandle *)h
+{
+    ASSERT (handle == h);
+    ASSERT (!reachedTerminalState);
+
+    if ([self isDownload])
+        [downloadDelegate resource:identifier didFinishLoadingFromDataSource:dataSource];
+    else
+        [resourceLoadDelegate resource:identifier didFinishLoadingFromDataSource:dataSource];
+
+    [[WebStandardPanels sharedStandardPanels] _didStopLoadingURL:currentURL inController:[dataSource controller]];
+
+    [self _releaseResources];
+}
+
+- (void)handle:(WebResourceHandle *)h didFailLoadingWithError:(WebError *)result
+{
+    ASSERT (handle == h);
+    ASSERT (!reachedTerminalState);
+    
+    if ([self isDownload])
+        [downloadDelegate resource: identifier didFailLoadingWithError: result fromDataSource: dataSource];
+    else
+        [resourceLoadDelegate resource: identifier didFailLoadingWithError: result fromDataSource: dataSource];
+
+    [[WebStandardPanels sharedStandardPanels] _didStopLoadingURL:currentURL inController:[dataSource controller]];
+
+    [self _releaseResources];
+}
+
+- (void)cancel
+{
+    ASSERT (!reachedTerminalState);
+
+    [handle cancel];
+    
+    [[WebStandardPanels sharedStandardPanels] _didStopLoadingURL:currentURL inController:[dataSource controller]];
+
+    WebError *error = [[WebError alloc] initWithErrorCode:WebErrorCodeCancelled 
+        inDomain:WebErrorDomainWebFoundation failingURL:[[request URL] absoluteString]];
+    if (![self isDownload])
+        [resourceLoadDelegate resource: identifier didFailLoadingWithError: error fromDataSource: dataSource];
+
+    [self _releaseResources];
+}
+
+- (WebResourceHandle *)handle
+{
+    return handle;
+}
+
 @end
diff --git a/WebKit/WebView.subproj/WebControllerPrivate.h b/WebKit/WebView.subproj/WebControllerPrivate.h
index 99f7214..b832078 100644
--- a/WebKit/WebView.subproj/WebControllerPrivate.h
+++ b/WebKit/WebView.subproj/WebControllerPrivate.h
@@ -45,11 +45,9 @@
 
 - (id <WebContextMenuDelegate>)_defaultContextMenuDelegate;
 - (void)_finsishedLoadingResourceFromDataSource:(WebDataSource *)dataSource;
-- (void)_receivedError:(WebError *)error forResourceHandle:(WebResourceHandle *)resourceHandle fromDataSource:(WebDataSource *)dataSource;
-- (void)_mainReceivedProgressForResourceHandle:(WebResourceHandle *)resourceHandle bytesSoFar:(unsigned)bytesSoFar fromDataSource:(WebDataSource *)dataSource complete:(BOOL)isComplete;
-- (void)_mainReceivedError:(WebError *)error forResourceHandle:(WebResourceHandle *)resourceHandle fromDataSource:(WebDataSource *)dataSource;
-- (void)_didStartLoading:(NSURL *)URL;
-- (void)_didStopLoading:(NSURL *)URL;
+- (void)_receivedError:(WebError *)error fromDataSource:(WebDataSource *)dataSource;
+- (void)_mainReceivedBytesSoFar:(unsigned)bytesSoFar fromDataSource:(WebDataSource *)dataSource complete:(BOOL)isComplete;
+- (void)_mainReceivedError:(WebError *)error fromDataSource:(WebDataSource *)dataSource;
 + (NSString *)_MIMETypeForFile:(NSString *)path;
 - (void)_downloadURL:(NSURL *)URL withContentPolicy:(WebContentPolicy *)contentPolicy;
 
diff --git a/WebKit/WebView.subproj/WebControllerPrivate.m b/WebKit/WebView.subproj/WebControllerPrivate.m
index e12acc4..d03fd7e 100644
--- a/WebKit/WebView.subproj/WebControllerPrivate.m
+++ b/WebKit/WebView.subproj/WebControllerPrivate.m
@@ -115,7 +115,7 @@
     }
 }
 
-- (void)_mainReceivedProgressForResourceHandle: (WebResourceHandle *)resourceHandle bytesSoFar: (unsigned)bytesSoFar fromDataSource: (WebDataSource *)dataSource complete: (BOOL)isComplete
+- (void)_mainReceivedBytesSoFar: (unsigned)bytesSoFar fromDataSource: (WebDataSource *)dataSource complete: (BOOL)isComplete
 {
     WebFrame *frame = [dataSource webFrame];
     
@@ -125,7 +125,7 @@
     if (frame == nil)
         return;
         
-    // This resouce has completed, so check if the load is complete for all frames.
+    // This resource has completed, so check if the load is complete for all frames.
     if (isComplete){
         // If the load is complete, mark the primary load as done.  The primary load is the load
         // of the main document.  Other resources may still be arriving.
@@ -143,24 +143,15 @@
 }
 
 
-
-- (void)_receivedError: (WebError *)error forResourceHandle: (WebResourceHandle *)resourceHandle fromDataSource: (WebDataSource *)dataSource
+- (void)_receivedError: (WebError *)error fromDataSource: (WebDataSource *)dataSource
 {
     WebFrame *frame = [dataSource webFrame];
 
-    NSString *resourceIdentifier = [[[resourceHandle _request] URL] absoluteString];
-    if (resourceIdentifier == nil) {
-        resourceIdentifier = [error failingURL];
-    }
-    if (resourceIdentifier) {
-        [dataSource _addError:error forResource:resourceIdentifier];
-    }
-    
     [frame _checkLoadComplete];
 }
 
 
-- (void)_mainReceivedError: (WebError *)error forResourceHandle: (WebResourceHandle *)resourceHandle fromDataSource: (WebDataSource *)dataSource
+- (void)_mainReceivedError: (WebError *)error fromDataSource: (WebDataSource *)dataSource
 {
     WebFrame *frame = [dataSource webFrame];
     
@@ -170,16 +161,6 @@
     [frame _checkLoadComplete];
 }
 
-- (void)_didStartLoading: (NSURL *)URL
-{
-    [[WebStandardPanels sharedStandardPanels] _didStartLoadingURL:URL inController:self];
-}
-
-- (void)_didStopLoading: (NSURL *)URL
-{
-    [[WebStandardPanels sharedStandardPanels] _didStopLoadingURL:URL inController:self];
-}
-
 + (NSString *)_MIMETypeForFile: (NSString *)path
 {
     NSString *result;
diff --git a/WebKit/WebView.subproj/WebDataSource.h b/WebKit/WebView.subproj/WebDataSource.h
index 87fdc49..2ce2450 100644
--- a/WebKit/WebView.subproj/WebDataSource.h
+++ b/WebKit/WebView.subproj/WebDataSource.h
@@ -153,12 +153,6 @@
 - (NSString *)fileType;
 
 /*!
-    @method errors
-    @result Returns a dictionary of WebErrors from all the resources loaded for this page.
-*/
-- (NSDictionary *)errors;
-
-/*!
     @method mainDocumentError
     @result Returns a WebError associated with the load of the main document, or nil if no error occurred.
 */
diff --git a/WebKit/WebView.subproj/WebDataSource.m b/WebKit/WebView.subproj/WebDataSource.m
index c2a3be3..4308ca8 100644
--- a/WebKit/WebView.subproj/WebDataSource.m
+++ b/WebKit/WebView.subproj/WebDataSource.m
@@ -190,11 +190,6 @@
     return [[WebFileTypeMappings sharedMappings] preferredExtensionForMIMEType:[[self response] contentType]];
 }
 
-- (NSDictionary *)errors
-{
-    return _private->errors;
-}
-
 - (WebError *)mainDocumentError
 {
     return _private->mainDocumentError;
diff --git a/WebKit/WebView.subproj/WebDataSourcePrivate.h b/WebKit/WebView.subproj/WebDataSourcePrivate.h
index 3721470..e303e42 100644
--- a/WebKit/WebView.subproj/WebDataSourcePrivate.h
+++ b/WebKit/WebView.subproj/WebDataSourcePrivate.h
@@ -94,7 +94,6 @@
 - (void)_layoutChildren;
 - (void)_clearErrors;
 - (void)_setMainDocumentError:(WebError *)error;
-- (void)_addError:(WebError *)error forResource:(NSString *)resourceDescription;
 + (NSMutableDictionary *)_repTypes;
 + (BOOL)_canShowMIMEType:(NSString *)MIMEType;
 - (void)_loadIcon;
diff --git a/WebKit/WebView.subproj/WebDataSourcePrivate.m b/WebKit/WebView.subproj/WebDataSourcePrivate.m
index 9c779ab..e408e56 100644
--- a/WebKit/WebView.subproj/WebDataSourcePrivate.m
+++ b/WebKit/WebView.subproj/WebDataSourcePrivate.m
@@ -54,7 +54,6 @@
     [subresourceClients release];
     [pageTitle release];
     [response release];
-    [errors release];
     [mainDocumentError release];
     [contentPolicy release];
     [iconLoader setDelegate:nil];
@@ -166,10 +165,6 @@
         _private->mainHandle = [[WebResourceHandle alloc] initWithRequest:_private->request];
         [_private->mainHandle loadWithDelegate:_private->mainClient];
     }
-    
-    if (_private->mainHandle) {
-        [_private->mainClient didStartLoadingWithURL:[_private->request URL]];
-    }
 }
 
 - (void)_addSubresourceClient:(WebSubresourceClient *)client
@@ -203,8 +198,7 @@
 
     _private->stopping = YES;
     
-    [_private->mainHandle cancel];
-    [_private->mainClient didCancelWithHandle:_private->mainHandle];
+    [_private->mainClient cancel];
     
     NSArray *clients = [_private->subresourceClients copy];
     [clients makeObjectsPerformSelector:@selector(cancel)];
@@ -320,22 +314,11 @@
 
 - (void)_clearErrors
 {
-    [_private->errors release];
-    _private->errors = nil;
     [_private->mainDocumentError release];
     _private->mainDocumentError = nil;
 }
 
 
-- (void)_addError: (WebError *)error forResource: (NSString *)resourceDescription
-{
-    if (_private->errors == 0)
-        _private->errors = [[NSMutableDictionary alloc] init];
-        
-    [_private->errors setObject: error forKey: resourceDescription];
-}
-
-
 - (void)_layoutChildren
 {
     NSArray *subFrames = [[self webFrame] children];
diff --git a/WebKit/WebView.subproj/WebFramePrivate.m b/WebKit/WebView.subproj/WebFramePrivate.m
index 78e3d1b..6a89011 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.m
+++ b/WebKit/WebView.subproj/WebFramePrivate.m
@@ -428,9 +428,9 @@ static const char * const stateNames[] = {
             LOG(Loading, "%s:  checking complete in WebFrameStateProvisional", [[self name] cString]);
             // If we've received any errors we may be stuck in the provisional state and actually
             // complete.
-            if ([[pd errors] count] != 0 || [pd mainDocumentError]) {
+            if ([pd mainDocumentError]) {
                 // Check all children first.
-                LOG(Loading, "%s:  checking complete, current state WebFrameStateProvisional, %d errors", [[self name] cString], [[pd errors] count]);
+                LOG(Loading, "%s:  checking complete, current state WebFrameStateProvisional", [[self name] cString]);
                 if (![pd isLoading]) {
                     LOG(Loading, "%s:  checking complete in WebFrameStateProvisional, load done", [[self name] cString]);
 
diff --git a/WebKit/WebView.subproj/WebLoader.h b/WebKit/WebView.subproj/WebLoader.h
index c009ca2..0e856eb 100644
--- a/WebKit/WebView.subproj/WebLoader.h
+++ b/WebKit/WebView.subproj/WebLoader.h
@@ -5,11 +5,35 @@
 
 #import <Foundation/Foundation.h>
 
+ at class WebDataSource;
+ at class WebResourceHandle;
+ at class WebResourceRequest;
+ at class WebResourceResponse;
+
 @protocol WebResourceHandleDelegate;
+ at protocol WebResourceLoadDelegate;
 
 @interface WebBaseResourceHandleDelegate : NSObject <WebResourceHandleDelegate>
 {
-
+    WebResourceHandle *handle;
+    WebDataSource *dataSource;
+    WebResourceRequest *request;
+    WebResourceResponse *response;
+    id identifier;
+    id <WebResourceLoadDelegate>resourceLoadDelegate;
+    id <WebResourceLoadDelegate>downloadDelegate;
+    NSURL *currentURL;
+    BOOL isDownload;
+    BOOL reachedTerminalState;
 }
 
+- (WebResourceHandle *)handle;
+
+- (void)setDataSource: (WebDataSource *)d;
+- (WebDataSource *)dataSource;
+- (id <WebResourceLoadDelegate>)resourceLoadDelegate;
+- (id <WebResourceLoadDelegate>)downloadDelegate;
+- (void)setIsDownload: (BOOL)f;
+- (void)cancel;
+
 @end
diff --git a/WebKit/WebView.subproj/WebLoader.m b/WebKit/WebView.subproj/WebLoader.m
index 449ca02..eba1578 100644
--- a/WebKit/WebView.subproj/WebLoader.m
+++ b/WebKit/WebView.subproj/WebLoader.m
@@ -3,9 +3,214 @@
     Copyright (c) 2002, Apple Computer, Inc. All rights reserved.
 */
 
-#import "WebBaseResourceHandleDelegate.h"
+#import <WebFoundation/WebAssertions.h>
+#import <WebFoundation/WebError.h>
+#import <WebFoundation/WebHTTPResourceRequest.h>
+#import <WebFoundation/WebResourceHandle.h>
+#import <WebFoundation/WebResourceRequest.h>
+#import <WebFoundation/WebResourceResponse.h>
+
+#import <WebKit/WebBaseResourceHandleDelegate.h>
+#import <WebKit/WebController.h>
+#import <WebKit/WebDataSource.h>
+#import <WebKit/WebResourceLoadDelegate.h>
+#import <WebKit/WebStandardPanelsPrivate.h>
 
 
 @implementation WebBaseResourceHandleDelegate
 
+- init
+{
+    self = [super init];
+    
+    [self setIsDownload: NO];
+    
+    return self;
+}
+
+- (void)_releaseResources
+{
+    [identifier release];
+    identifier = nil;
+
+    [handle release];
+    handle = nil;
+
+    [dataSource release];
+    dataSource = nil;
+    
+    [resourceLoadDelegate release];
+    resourceLoadDelegate = nil;
+
+    [downloadDelegate release];
+    downloadDelegate = nil;
+    
+    reachedTerminalState = YES;
+}
+
+- (void)dealloc
+{
+    [self _releaseResources];
+    [request release];
+    [response release];
+    [currentURL release];
+}
+
+- (void)setDataSource: (WebDataSource *)d
+{
+    if (d != dataSource){
+        [dataSource release];
+        dataSource = [d retain];
+    }
+    
+    if (resourceLoadDelegate != [[dataSource controller] resourceLoadDelegate]){
+        [resourceLoadDelegate release];
+        resourceLoadDelegate = [[[dataSource controller] resourceLoadDelegate] retain];
+    }
+
+    if (downloadDelegate != [[dataSource controller] downloadDelegate]){
+        [downloadDelegate release];
+        downloadDelegate = [[[dataSource controller] downloadDelegate] retain];
+    }    
+}
+
+- (WebDataSource *)dataSource
+{
+    return dataSource;
+}
+
+- (id <WebResourceLoadDelegate>)resourceLoadDelegate
+{
+    return resourceLoadDelegate;
+}
+
+- (id <WebResourceLoadDelegate>)downloadDelegate
+{
+    return downloadDelegate;
+}
+
+- (void)setIsDownload: (BOOL)f
+{
+    isDownload = f;
+}
+
+- (BOOL)isDownload
+{
+    return isDownload;
+}
+
+-(WebResourceRequest *)handle:(WebResourceHandle *)h willSendRequest:(WebResourceRequest *)newRequest
+{
+    ASSERT (!reachedTerminalState);
+
+    if (!handle){
+        // Retained so we can cancel if necessary.  Released when we
+        // reach a terminal state.
+        handle = [h retain];
+    }
+        
+    [newRequest setUserAgent:[[dataSource controller] userAgentForURL:[newRequest URL]]];
+
+    [newRequest retain];
+    [request release];
+    request = newRequest;
+
+    if (identifier == nil){
+        // The identifier is released after the last callback, rather than in dealloc
+        // to avoid potential cycles.
+        identifier = [[resourceLoadDelegate identifierForInitialRequest: newRequest fromDataSource: dataSource] retain];
+    }
+
+    if (resourceLoadDelegate)
+        newRequest = [resourceLoadDelegate resource: identifier willSendRequest: newRequest fromDataSource: dataSource];
+
+    [[WebStandardPanels sharedStandardPanels] _didStopLoadingURL:currentURL inController: [dataSource controller]];
+    
+    if ([newRequest URL] != currentURL){
+        [currentURL release];
+        currentURL = [[newRequest URL] retain];
+    }
+    
+    [[WebStandardPanels sharedStandardPanels] _didStartLoadingURL:currentURL inController:[dataSource controller]];
+
+    return newRequest;
+}
+
+-(void)handle:(WebResourceHandle *)h didReceiveResponse:(WebResourceResponse *)r
+{
+    ASSERT (handle == h);
+    ASSERT (!reachedTerminalState);
+
+    [r retain];
+    [response release];
+    response = r;
+
+    if (isDownload)
+        [downloadDelegate resource:identifier didReceiveResponse:r fromDataSource: dataSource];
+    else
+        [resourceLoadDelegate resource:identifier didReceiveResponse:r fromDataSource: dataSource];
+}
+
+- (void)handle:(WebResourceHandle *)h didReceiveData:(NSData *)data
+{
+    ASSERT (handle == h);
+    ASSERT (!reachedTerminalState);
+
+    if ([self isDownload])
+        [downloadDelegate resource: identifier didReceiveContentLength: [data length] fromDataSource: dataSource];
+    else
+        [resourceLoadDelegate resource: identifier didReceiveContentLength: [data length] fromDataSource: dataSource];
+}
+
+- (void)handleDidFinishLoading:(WebResourceHandle *)h
+{
+    ASSERT (handle == h);
+    ASSERT (!reachedTerminalState);
+
+    if ([self isDownload])
+        [downloadDelegate resource:identifier didFinishLoadingFromDataSource:dataSource];
+    else
+        [resourceLoadDelegate resource:identifier didFinishLoadingFromDataSource:dataSource];
+
+    [[WebStandardPanels sharedStandardPanels] _didStopLoadingURL:currentURL inController:[dataSource controller]];
+
+    [self _releaseResources];
+}
+
+- (void)handle:(WebResourceHandle *)h didFailLoadingWithError:(WebError *)result
+{
+    ASSERT (handle == h);
+    ASSERT (!reachedTerminalState);
+    
+    if ([self isDownload])
+        [downloadDelegate resource: identifier didFailLoadingWithError: result fromDataSource: dataSource];
+    else
+        [resourceLoadDelegate resource: identifier didFailLoadingWithError: result fromDataSource: dataSource];
+
+    [[WebStandardPanels sharedStandardPanels] _didStopLoadingURL:currentURL inController:[dataSource controller]];
+
+    [self _releaseResources];
+}
+
+- (void)cancel
+{
+    ASSERT (!reachedTerminalState);
+
+    [handle cancel];
+    
+    [[WebStandardPanels sharedStandardPanels] _didStopLoadingURL:currentURL inController:[dataSource controller]];
+
+    WebError *error = [[WebError alloc] initWithErrorCode:WebErrorCodeCancelled 
+        inDomain:WebErrorDomainWebFoundation failingURL:[[request URL] absoluteString]];
+    if (![self isDownload])
+        [resourceLoadDelegate resource: identifier didFailLoadingWithError: error fromDataSource: dataSource];
+
+    [self _releaseResources];
+}
+
+- (WebResourceHandle *)handle
+{
+    return handle;
+}
+
 @end
diff --git a/WebKit/WebView.subproj/WebMainResourceClient.h b/WebKit/WebView.subproj/WebMainResourceClient.h
index 39c1f7c..4354b4a 100644
--- a/WebKit/WebView.subproj/WebMainResourceClient.h
+++ b/WebKit/WebView.subproj/WebMainResourceClient.h
@@ -22,27 +22,13 @@
 
 @interface WebMainResourceClient : WebBaseResourceHandleDelegate
 {
-    NSURL *currentURL;
-    WebDataSource *dataSource;
     WebDownloadHandler *downloadHandler;
-    
-    // Both of these delegates are retained by the client.
-    id <WebResourceLoadDelegate> downloadProgressDelegate;
-    id <WebResourceLoadDelegate> resourceProgressDelegate;
-
     WebContentAction policyAction;
     NSMutableData *resourceData;
-    WebResourceRequest *request;
-    WebResourceResponse *response;
-    
-    id identifier;
 }
 
 - initWithDataSource:(WebDataSource *)dataSource;
 - (WebDownloadHandler *)downloadHandler;
 - (NSData *)resourceData;
 
-- (void)didStartLoadingWithURL:(NSURL *)URL;
-- (void)didCancelWithHandle:(WebResourceHandle *)handle;
-
 @end
diff --git a/WebKit/WebView.subproj/WebMainResourceClient.m b/WebKit/WebView.subproj/WebMainResourceClient.m
index 409e101..13f6043 100644
--- a/WebKit/WebView.subproj/WebMainResourceClient.m
+++ b/WebKit/WebView.subproj/WebMainResourceClient.m
@@ -10,13 +10,14 @@
 #import <WebKit/WebDataSourcePrivate.h>
 #import <WebKit/WebDocument.h>
 #import <WebKit/WebDownloadHandler.h>
-#import <WebKit/WebKitErrors.h>
 #import <WebKit/WebFrame.h>
 #import <WebKit/WebFramePrivate.h>
+#import <WebKit/WebKitErrors.h>
 #import <WebKit/WebKitLogging.h>
 #import <WebKit/WebLocationChangeDelegate.h>
 #import <WebKit/WebMainResourceClient.h>
 #import <WebKit/WebResourceLoadDelegate.h>
+#import <WebKit/WebStandardPanelsPrivate.h>
 #import <WebKit/WebView.h>
 
 #import <WebFoundation/WebError.h>
@@ -37,44 +38,18 @@
     self = [super init];
     
     if (self) {
-        dataSource = [ds retain];
         resourceData = [[NSMutableData alloc] init];
-        
-        // set the user agent for the request
-        // consult the data source's controller
-        WebController *controller = [dataSource controller];
-        resourceProgressDelegate = [[controller resourceLoadDelegate] retain];
+        [self setDataSource: ds];
     }
 
     return self;
 }
 
-- (void)didStartLoadingWithURL:(NSURL *)URL
-{
-    ASSERT(currentURL == nil);
-    currentURL = [URL retain];
-    [[dataSource controller] _didStartLoading:currentURL];
-}
-
-- (void)didStopLoading
-{
-    ASSERT(currentURL != nil);
-    [[dataSource controller] _didStopLoading:currentURL];
-    [currentURL release];
-    currentURL = nil;
-}
-
 - (void)dealloc
 {
-    ASSERT(currentURL == nil);
     ASSERT(downloadHandler == nil);
     
-    [downloadProgressDelegate release];
-    [resourceProgressDelegate release];
     [resourceData release];
-    [dataSource release];
-    [response release];
-    [request release];
     
     [super dealloc];
 }
@@ -89,19 +64,16 @@
     return downloadHandler;
 }
 
-- (void)receivedError:(WebError *)error forHandle:(WebResourceHandle *)handle
+- (void)receivedError:(WebError *)error
 {    
     WebContentAction contentAction = [[dataSource contentPolicy] policyAction];
 
-    if (contentAction == WebContentPolicySaveAndOpenExternally || contentAction == WebContentPolicySave) {
-        [downloadProgressDelegate resource: identifier didFailLoadingWithError:error fromDataSource:dataSource];
-    } else {
-        [[dataSource controller] _mainReceivedError:error forResourceHandle:handle 
-            fromDataSource:dataSource];
+    if (contentAction != WebContentPolicySaveAndOpenExternally && contentAction != WebContentPolicySave) {
+        [[dataSource controller] _mainReceivedError:error fromDataSource:dataSource];
     }
 }
 
-- (void)didCancelWithHandle:(WebResourceHandle *)handle
+- (void)cancel
 {
     if (currentURL == nil) {
         return;
@@ -116,7 +88,7 @@
     WebError *error = [[WebError alloc] initWithErrorCode:WebErrorCodeCancelled
                                                  inDomain:WebErrorDomainWebFoundation
                                                failingURL:[[[dataSource request] URL] absoluteString]];
-    [self receivedError:error forHandle:handle];
+    [self receivedError:error];
     [error release];
 
     if (downloadHandler) {
@@ -124,81 +96,17 @@
         [downloadHandler release];
         downloadHandler = nil;
     }
-    
-    [self didStopLoading];
-    
-    [self release];
-}
-
-- (void)handleDidFinishLoading:(WebResourceHandle *)handle
-{
-    LOG(Loading, "URL = %@", currentURL);
-    
-    // Calling receivedError will likely result in a call to release, so we must retain.
-    [self retain];
-
-    WebContentAction contentAction = [[dataSource contentPolicy] policyAction];
-    
-    // Don't retain data for downloaded files
-    if (contentAction != WebContentPolicySave && contentAction != WebContentPolicySaveAndOpenExternally) {
-    	[dataSource _setResourceData:resourceData];
-    }
-
-    if (contentAction == WebContentPolicyShow) {
-        [[dataSource representation] finishedLoadingWithDataSource:dataSource];
-    }
-    
-    if (downloadHandler) {
-        WebError *downloadError = [downloadHandler finishedLoading];
-        if (downloadError) {
-            [self receivedError:downloadError forHandle:handle];
-        }else{
-            [downloadProgressDelegate resource:identifier didFinishLoadingFromDataSource:dataSource];
-        }
-        [dataSource _setPrimaryLoadComplete:YES];
-        [downloadHandler release];
-        downloadHandler = nil;
-    }
-    else {
-        [dataSource _finishedLoading];
-        [resourceProgressDelegate resource:identifier didFinishLoadingFromDataSource:dataSource];
-
-        // FIXME: Please let Chris know if this is really necessary?
-        // Either send a final error message or a final progress message.
-        WebError *nonTerminalError = [[dataSource response] error];
-        if (nonTerminalError) {
-            [self receivedError:nonTerminalError forHandle:handle];
-        } else {
-            [[dataSource controller] _mainReceivedProgressForResourceHandle:handle
-                                                                 bytesSoFar:[resourceData length]
-                                                             fromDataSource:dataSource
-                                                                   complete:YES];
-        }
-    }
-
-    [identifier release];
-    identifier = nil;
         
-    [self didStopLoading];
-    
     [self release];
+    
+    [super cancel];
 }
 
--(WebResourceRequest *)handle:(WebResourceHandle *)handle willSendRequest:(WebResourceRequest *)newRequest
+-(WebResourceRequest *)handle:(WebResourceHandle *)h willSendRequest:(WebResourceRequest *)newRequest
 {
     WebResourceRequest *result;
 
-    [newRequest setUserAgent:[[dataSource controller] userAgentForURL:[newRequest URL]]];
-
-    // Let the resourceProgressDelegate get a crack at modifying the request.
-    if (resourceProgressDelegate) {
-        if (identifier == nil){
-            // The identifier is released after the last callback, rather than in dealloc
-            // to avoid potential cycles.
-            identifier = [[resourceProgressDelegate identifierForInitialRequest: newRequest fromDataSource: dataSource] retain];
-        }
-        newRequest = [resourceProgressDelegate resource: identifier willSendRequest: newRequest fromDataSource: dataSource];
-    }
+    newRequest = [super handle: h willSendRequest: newRequest];
     
     ASSERT(newRequest != nil);
 
@@ -218,45 +126,36 @@
         if ([dataSource webFrame] == [[dataSource controller] mainFrame]) {
             [newRequest setCookiePolicyBaseURL:URL];
         }
-    
-        WebResourceRequest *copy = [newRequest copy];
-    
-        // Don't set this on the first request.  It is set
-        // when the main load was started.
-        if (request)
-            [dataSource _setRequest:copy];
-    
-        // Not the first send, so reload.
-        if (request) {
-            [self didStopLoading];
-            [self didStartLoadingWithURL:URL];
-        }
-    
-        [request release];
-        result = request = copy;
+        result = newRequest;
     }
         
     return result;
 }
 
--(void)handle:(WebResourceHandle *)handle didReceiveResponse:(WebResourceResponse *)r
+- (void)_notifyDelegatesOfInterruptionByPolicyChange
+{
+    WebError *interruptError;
+            
+    // Terminate the locationChangeDelegate correctly.
+    interruptError = [WebError errorWithCode:WebErrorLocationChangeInterruptedByPolicyChange inDomain:WebErrorDomainWebKit failingURL:nil];
+    [[[dataSource controller] locationChangeDelegate] locationChangeDone: interruptError forDataSource:dataSource];
+
+    // Terminate the resourceLoadDelegate correctly.
+    interruptError = [WebError errorWithCode:WebErrorResourceLoadInterruptedByPolicyChange inDomain:WebErrorDomainWebKit failingURL:nil];
+    [resourceLoadDelegate resource: identifier didFailLoadingWithError: interruptError fromDataSource: dataSource];
+}
+
+-(void)handle:(WebResourceHandle *)h didReceiveResponse:(WebResourceResponse *)r
 {
     ASSERT (response == nil);
     
-    response = [r retain];
-    
-    [dataSource _setResponse:response];
-
-    LOG(Download, "main content type: %@", [response contentType]);
+    [dataSource _setResponse:r];
 
-    // Retain the downloadProgressDelegate just in case this is a download.
-    // Alexander releases the WebController if no window is created for it.
-    // This happens in the cases mentioned in 2981866 and 2965312.
-    downloadProgressDelegate = [[[dataSource controller] downloadDelegate] retain];
+    LOG(Download, "main content type: %@", [r contentType]);
 
     // Figure out the content policy.
     WebContentPolicy *contentPolicy = [dataSource contentPolicy];
-    contentPolicy = [[[dataSource controller] policyDelegate] contentPolicyForResponse:response
+    contentPolicy = [[[dataSource controller] policyDelegate] contentPolicyForResponse:r
                                                                                 andURL:currentURL
                                                                                inFrame:[dataSource webFrame]
                                                                      withContentPolicy:contentPolicy];
@@ -266,75 +165,125 @@
 
     switch (policyAction) {
     case WebContentPolicyShow:
-        [resourceProgressDelegate resource: identifier didReceiveResponse: response fromDataSource: dataSource];
         break;
+        
     case WebContentPolicySave:
-    case WebContentPolicySaveAndOpenExternally:
-        [[dataSource webFrame] _setProvisionalDataSource:nil];
-	[[[dataSource controller] locationChangeDelegate] locationChangeDone:[WebError errorWithCode:WebErrorLocationChangeInterruptedByPolicyChange inDomain:WebErrorDomainWebKit failingURL:nil] forDataSource:dataSource];
-        downloadHandler = [[WebDownloadHandler alloc] initWithDataSource:dataSource];
-        WebError *downloadError = [downloadHandler receivedResponse:response];
-        [downloadProgressDelegate resource: identifier didReceiveResponse: response fromDataSource: dataSource];
-
-        if (downloadError) {
-            [self receivedError:downloadError forHandle:handle];
-            [handle cancel];
+    case WebContentPolicySaveAndOpenExternally: 
+        {
+            [[dataSource webFrame] _setProvisionalDataSource:nil];
+            
+            [self _notifyDelegatesOfInterruptionByPolicyChange];
+            
+            // Hand off the dataSource to the download handler.  This will cause the remaining
+            // handle delegate callbacks to go to the controller's download delegate.
+            downloadHandler = [[WebDownloadHandler alloc] initWithDataSource:dataSource];
+            [self setIsDownload: YES];
+            WebError *downloadError = [downloadHandler receivedResponse:r];
+            if (downloadError) {
+                [self receivedError:downloadError];
+                [handle cancel];
+            }
         }
         break;
-    case WebContentPolicyIgnore:
-        [handle cancel];
-        [self didCancelWithHandle:handle];
-        [[dataSource webFrame] _setProvisionalDataSource:nil];
-	[[[dataSource controller] locationChangeDelegate] locationChangeDone:[WebError errorWithCode:WebErrorLocationChangeInterruptedByPolicyChange inDomain:WebErrorDomainWebKit failingURL:nil] forDataSource:dataSource];
+    
+    case WebContentPolicyIgnore: 
+        {
+            [self cancel];
+            [[dataSource webFrame] _setProvisionalDataSource:nil];
+            [self _notifyDelegatesOfInterruptionByPolicyChange];
+        }
         break;
+    
     default:
         ERROR("contentPolicyForMIMEType:URL:inFrame: returned an invalid content policy.");
     }
+
+    [super handle: h didReceiveResponse: r];
 }
 
-- (void)handle:(WebResourceHandle *)handle didReceiveData:(NSData *)data
+- (void)handle:(WebResourceHandle *)h didReceiveData:(NSData *)data
 {
     LOG(Loading, "URL = %@, data = %p, length %d", currentURL, data, [data length]);
-        
+            
     if (downloadHandler) {
         [downloadHandler receivedData:data];
-        [downloadProgressDelegate resource: identifier didReceiveContentLength: [data length] fromDataSource:dataSource];
     } else {
         [resourceData appendData:data];
         [dataSource _receivedData:data];
-        [resourceProgressDelegate resource: identifier didReceiveContentLength: [data length] fromDataSource:dataSource];
-        [[dataSource controller] _mainReceivedProgressForResourceHandle:handle
-                                                             bytesSoFar:[resourceData length]
+        [[dataSource controller] _mainReceivedBytesSoFar:[resourceData length]
                                                          fromDataSource:dataSource
                                                                complete:NO];
     }
     
+    [super handle: h didReceiveData: data];
+
     LOG(Download, "%d of %d", [response contentLengthReceived], [response contentLength]);
 }
 
-- (void)handle:(WebResourceHandle *)handle didFailLoadingWithError:(WebError *)result
+- (void)handleDidFinishLoading:(WebResourceHandle *)h
 {
-    LOG(Loading, "URL = %@, result = %@", [result failingURL], [result errorDescription]);
+    LOG(Loading, "URL = %@", currentURL);
+        
+    // Calling receivedError will likely result in a call to release, so we must retain.
+    [self retain];
+
+    WebContentAction contentAction = [[dataSource contentPolicy] policyAction];
+    
+    // Don't retain data for downloaded files
+    if (contentAction != WebContentPolicySave && contentAction != WebContentPolicySaveAndOpenExternally) {
+    	[dataSource _setResourceData:resourceData];
+    }
+
+    if (contentAction == WebContentPolicyShow) {
+        [[dataSource representation] finishedLoadingWithDataSource:dataSource];
+    }
+    
+    if (downloadHandler) {
+        WebError *downloadError = [downloadHandler finishedLoading];
+        if (downloadError)
+            [self receivedError:downloadError];
 
-    if (!downloadHandler)
-        [resourceProgressDelegate resource: identifier didFailLoadingWithError: result fromDataSource: dataSource];
+        [dataSource _setPrimaryLoadComplete:YES];
+        [downloadHandler release];
+        downloadHandler = nil;
+    }
+    else {
+        [dataSource _finishedLoading];
+
+        // FIXME: Please let Chris know if this is really necessary?
+        // Either send a final error message or a final progress message.
+        WebError *nonTerminalError = [[dataSource response] error];
+        if (nonTerminalError) {
+            [self receivedError:nonTerminalError];
+        } else {
+            [[dataSource controller] _mainReceivedBytesSoFar:[resourceData length]
+                                                             fromDataSource:dataSource
+                                                                   complete:YES];
+        }
+    }
+    
+    [super handleDidFinishLoading: h];
+
+    [self release];
+}
+
+- (void)handle:(WebResourceHandle *)h didFailLoadingWithError:(WebError *)result
+{
+    LOG(Loading, "URL = %@, result = %@", [result failingURL], [result errorDescription]);
 
     // Calling receivedError will likely result in a call to release, so we must retain.
     [self retain];
 
-    [self receivedError:result forHandle:handle];
+    [self receivedError:result];
 
     if (downloadHandler) {
         [downloadHandler cancel];
         [downloadHandler release];
         downloadHandler = nil;
     }
-
-    [identifier release];
-    identifier = nil;
-    
-    [self didStopLoading];
     
+    [super handle: h didFailLoadingWithError: result];
+
     [self release];
 }
 
diff --git a/WebKit/WebView.subproj/WebMainResourceLoader.h b/WebKit/WebView.subproj/WebMainResourceLoader.h
index 39c1f7c..4354b4a 100644
--- a/WebKit/WebView.subproj/WebMainResourceLoader.h
+++ b/WebKit/WebView.subproj/WebMainResourceLoader.h
@@ -22,27 +22,13 @@
 
 @interface WebMainResourceClient : WebBaseResourceHandleDelegate
 {
-    NSURL *currentURL;
-    WebDataSource *dataSource;
     WebDownloadHandler *downloadHandler;
-    
-    // Both of these delegates are retained by the client.
-    id <WebResourceLoadDelegate> downloadProgressDelegate;
-    id <WebResourceLoadDelegate> resourceProgressDelegate;
-
     WebContentAction policyAction;
     NSMutableData *resourceData;
-    WebResourceRequest *request;
-    WebResourceResponse *response;
-    
-    id identifier;
 }
 
 - initWithDataSource:(WebDataSource *)dataSource;
 - (WebDownloadHandler *)downloadHandler;
 - (NSData *)resourceData;
 
-- (void)didStartLoadingWithURL:(NSURL *)URL;
-- (void)didCancelWithHandle:(WebResourceHandle *)handle;
-
 @end
diff --git a/WebKit/WebView.subproj/WebMainResourceLoader.m b/WebKit/WebView.subproj/WebMainResourceLoader.m
index 409e101..13f6043 100644
--- a/WebKit/WebView.subproj/WebMainResourceLoader.m
+++ b/WebKit/WebView.subproj/WebMainResourceLoader.m
@@ -10,13 +10,14 @@
 #import <WebKit/WebDataSourcePrivate.h>
 #import <WebKit/WebDocument.h>
 #import <WebKit/WebDownloadHandler.h>
-#import <WebKit/WebKitErrors.h>
 #import <WebKit/WebFrame.h>
 #import <WebKit/WebFramePrivate.h>
+#import <WebKit/WebKitErrors.h>
 #import <WebKit/WebKitLogging.h>
 #import <WebKit/WebLocationChangeDelegate.h>
 #import <WebKit/WebMainResourceClient.h>
 #import <WebKit/WebResourceLoadDelegate.h>
+#import <WebKit/WebStandardPanelsPrivate.h>
 #import <WebKit/WebView.h>
 
 #import <WebFoundation/WebError.h>
@@ -37,44 +38,18 @@
     self = [super init];
     
     if (self) {
-        dataSource = [ds retain];
         resourceData = [[NSMutableData alloc] init];
-        
-        // set the user agent for the request
-        // consult the data source's controller
-        WebController *controller = [dataSource controller];
-        resourceProgressDelegate = [[controller resourceLoadDelegate] retain];
+        [self setDataSource: ds];
     }
 
     return self;
 }
 
-- (void)didStartLoadingWithURL:(NSURL *)URL
-{
-    ASSERT(currentURL == nil);
-    currentURL = [URL retain];
-    [[dataSource controller] _didStartLoading:currentURL];
-}
-
-- (void)didStopLoading
-{
-    ASSERT(currentURL != nil);
-    [[dataSource controller] _didStopLoading:currentURL];
-    [currentURL release];
-    currentURL = nil;
-}
-
 - (void)dealloc
 {
-    ASSERT(currentURL == nil);
     ASSERT(downloadHandler == nil);
     
-    [downloadProgressDelegate release];
-    [resourceProgressDelegate release];
     [resourceData release];
-    [dataSource release];
-    [response release];
-    [request release];
     
     [super dealloc];
 }
@@ -89,19 +64,16 @@
     return downloadHandler;
 }
 
-- (void)receivedError:(WebError *)error forHandle:(WebResourceHandle *)handle
+- (void)receivedError:(WebError *)error
 {    
     WebContentAction contentAction = [[dataSource contentPolicy] policyAction];
 
-    if (contentAction == WebContentPolicySaveAndOpenExternally || contentAction == WebContentPolicySave) {
-        [downloadProgressDelegate resource: identifier didFailLoadingWithError:error fromDataSource:dataSource];
-    } else {
-        [[dataSource controller] _mainReceivedError:error forResourceHandle:handle 
-            fromDataSource:dataSource];
+    if (contentAction != WebContentPolicySaveAndOpenExternally && contentAction != WebContentPolicySave) {
+        [[dataSource controller] _mainReceivedError:error fromDataSource:dataSource];
     }
 }
 
-- (void)didCancelWithHandle:(WebResourceHandle *)handle
+- (void)cancel
 {
     if (currentURL == nil) {
         return;
@@ -116,7 +88,7 @@
     WebError *error = [[WebError alloc] initWithErrorCode:WebErrorCodeCancelled
                                                  inDomain:WebErrorDomainWebFoundation
                                                failingURL:[[[dataSource request] URL] absoluteString]];
-    [self receivedError:error forHandle:handle];
+    [self receivedError:error];
     [error release];
 
     if (downloadHandler) {
@@ -124,81 +96,17 @@
         [downloadHandler release];
         downloadHandler = nil;
     }
-    
-    [self didStopLoading];
-    
-    [self release];
-}
-
-- (void)handleDidFinishLoading:(WebResourceHandle *)handle
-{
-    LOG(Loading, "URL = %@", currentURL);
-    
-    // Calling receivedError will likely result in a call to release, so we must retain.
-    [self retain];
-
-    WebContentAction contentAction = [[dataSource contentPolicy] policyAction];
-    
-    // Don't retain data for downloaded files
-    if (contentAction != WebContentPolicySave && contentAction != WebContentPolicySaveAndOpenExternally) {
-    	[dataSource _setResourceData:resourceData];
-    }
-
-    if (contentAction == WebContentPolicyShow) {
-        [[dataSource representation] finishedLoadingWithDataSource:dataSource];
-    }
-    
-    if (downloadHandler) {
-        WebError *downloadError = [downloadHandler finishedLoading];
-        if (downloadError) {
-            [self receivedError:downloadError forHandle:handle];
-        }else{
-            [downloadProgressDelegate resource:identifier didFinishLoadingFromDataSource:dataSource];
-        }
-        [dataSource _setPrimaryLoadComplete:YES];
-        [downloadHandler release];
-        downloadHandler = nil;
-    }
-    else {
-        [dataSource _finishedLoading];
-        [resourceProgressDelegate resource:identifier didFinishLoadingFromDataSource:dataSource];
-
-        // FIXME: Please let Chris know if this is really necessary?
-        // Either send a final error message or a final progress message.
-        WebError *nonTerminalError = [[dataSource response] error];
-        if (nonTerminalError) {
-            [self receivedError:nonTerminalError forHandle:handle];
-        } else {
-            [[dataSource controller] _mainReceivedProgressForResourceHandle:handle
-                                                                 bytesSoFar:[resourceData length]
-                                                             fromDataSource:dataSource
-                                                                   complete:YES];
-        }
-    }
-
-    [identifier release];
-    identifier = nil;
         
-    [self didStopLoading];
-    
     [self release];
+    
+    [super cancel];
 }
 
--(WebResourceRequest *)handle:(WebResourceHandle *)handle willSendRequest:(WebResourceRequest *)newRequest
+-(WebResourceRequest *)handle:(WebResourceHandle *)h willSendRequest:(WebResourceRequest *)newRequest
 {
     WebResourceRequest *result;
 
-    [newRequest setUserAgent:[[dataSource controller] userAgentForURL:[newRequest URL]]];
-
-    // Let the resourceProgressDelegate get a crack at modifying the request.
-    if (resourceProgressDelegate) {
-        if (identifier == nil){
-            // The identifier is released after the last callback, rather than in dealloc
-            // to avoid potential cycles.
-            identifier = [[resourceProgressDelegate identifierForInitialRequest: newRequest fromDataSource: dataSource] retain];
-        }
-        newRequest = [resourceProgressDelegate resource: identifier willSendRequest: newRequest fromDataSource: dataSource];
-    }
+    newRequest = [super handle: h willSendRequest: newRequest];
     
     ASSERT(newRequest != nil);
 
@@ -218,45 +126,36 @@
         if ([dataSource webFrame] == [[dataSource controller] mainFrame]) {
             [newRequest setCookiePolicyBaseURL:URL];
         }
-    
-        WebResourceRequest *copy = [newRequest copy];
-    
-        // Don't set this on the first request.  It is set
-        // when the main load was started.
-        if (request)
-            [dataSource _setRequest:copy];
-    
-        // Not the first send, so reload.
-        if (request) {
-            [self didStopLoading];
-            [self didStartLoadingWithURL:URL];
-        }
-    
-        [request release];
-        result = request = copy;
+        result = newRequest;
     }
         
     return result;
 }
 
--(void)handle:(WebResourceHandle *)handle didReceiveResponse:(WebResourceResponse *)r
+- (void)_notifyDelegatesOfInterruptionByPolicyChange
+{
+    WebError *interruptError;
+            
+    // Terminate the locationChangeDelegate correctly.
+    interruptError = [WebError errorWithCode:WebErrorLocationChangeInterruptedByPolicyChange inDomain:WebErrorDomainWebKit failingURL:nil];
+    [[[dataSource controller] locationChangeDelegate] locationChangeDone: interruptError forDataSource:dataSource];
+
+    // Terminate the resourceLoadDelegate correctly.
+    interruptError = [WebError errorWithCode:WebErrorResourceLoadInterruptedByPolicyChange inDomain:WebErrorDomainWebKit failingURL:nil];
+    [resourceLoadDelegate resource: identifier didFailLoadingWithError: interruptError fromDataSource: dataSource];
+}
+
+-(void)handle:(WebResourceHandle *)h didReceiveResponse:(WebResourceResponse *)r
 {
     ASSERT (response == nil);
     
-    response = [r retain];
-    
-    [dataSource _setResponse:response];
-
-    LOG(Download, "main content type: %@", [response contentType]);
+    [dataSource _setResponse:r];
 
-    // Retain the downloadProgressDelegate just in case this is a download.
-    // Alexander releases the WebController if no window is created for it.
-    // This happens in the cases mentioned in 2981866 and 2965312.
-    downloadProgressDelegate = [[[dataSource controller] downloadDelegate] retain];
+    LOG(Download, "main content type: %@", [r contentType]);
 
     // Figure out the content policy.
     WebContentPolicy *contentPolicy = [dataSource contentPolicy];
-    contentPolicy = [[[dataSource controller] policyDelegate] contentPolicyForResponse:response
+    contentPolicy = [[[dataSource controller] policyDelegate] contentPolicyForResponse:r
                                                                                 andURL:currentURL
                                                                                inFrame:[dataSource webFrame]
                                                                      withContentPolicy:contentPolicy];
@@ -266,75 +165,125 @@
 
     switch (policyAction) {
     case WebContentPolicyShow:
-        [resourceProgressDelegate resource: identifier didReceiveResponse: response fromDataSource: dataSource];
         break;
+        
     case WebContentPolicySave:
-    case WebContentPolicySaveAndOpenExternally:
-        [[dataSource webFrame] _setProvisionalDataSource:nil];
-	[[[dataSource controller] locationChangeDelegate] locationChangeDone:[WebError errorWithCode:WebErrorLocationChangeInterruptedByPolicyChange inDomain:WebErrorDomainWebKit failingURL:nil] forDataSource:dataSource];
-        downloadHandler = [[WebDownloadHandler alloc] initWithDataSource:dataSource];
-        WebError *downloadError = [downloadHandler receivedResponse:response];
-        [downloadProgressDelegate resource: identifier didReceiveResponse: response fromDataSource: dataSource];
-
-        if (downloadError) {
-            [self receivedError:downloadError forHandle:handle];
-            [handle cancel];
+    case WebContentPolicySaveAndOpenExternally: 
+        {
+            [[dataSource webFrame] _setProvisionalDataSource:nil];
+            
+            [self _notifyDelegatesOfInterruptionByPolicyChange];
+            
+            // Hand off the dataSource to the download handler.  This will cause the remaining
+            // handle delegate callbacks to go to the controller's download delegate.
+            downloadHandler = [[WebDownloadHandler alloc] initWithDataSource:dataSource];
+            [self setIsDownload: YES];
+            WebError *downloadError = [downloadHandler receivedResponse:r];
+            if (downloadError) {
+                [self receivedError:downloadError];
+                [handle cancel];
+            }
         }
         break;
-    case WebContentPolicyIgnore:
-        [handle cancel];
-        [self didCancelWithHandle:handle];
-        [[dataSource webFrame] _setProvisionalDataSource:nil];
-	[[[dataSource controller] locationChangeDelegate] locationChangeDone:[WebError errorWithCode:WebErrorLocationChangeInterruptedByPolicyChange inDomain:WebErrorDomainWebKit failingURL:nil] forDataSource:dataSource];
+    
+    case WebContentPolicyIgnore: 
+        {
+            [self cancel];
+            [[dataSource webFrame] _setProvisionalDataSource:nil];
+            [self _notifyDelegatesOfInterruptionByPolicyChange];
+        }
         break;
+    
     default:
         ERROR("contentPolicyForMIMEType:URL:inFrame: returned an invalid content policy.");
     }
+
+    [super handle: h didReceiveResponse: r];
 }
 
-- (void)handle:(WebResourceHandle *)handle didReceiveData:(NSData *)data
+- (void)handle:(WebResourceHandle *)h didReceiveData:(NSData *)data
 {
     LOG(Loading, "URL = %@, data = %p, length %d", currentURL, data, [data length]);
-        
+            
     if (downloadHandler) {
         [downloadHandler receivedData:data];
-        [downloadProgressDelegate resource: identifier didReceiveContentLength: [data length] fromDataSource:dataSource];
     } else {
         [resourceData appendData:data];
         [dataSource _receivedData:data];
-        [resourceProgressDelegate resource: identifier didReceiveContentLength: [data length] fromDataSource:dataSource];
-        [[dataSource controller] _mainReceivedProgressForResourceHandle:handle
-                                                             bytesSoFar:[resourceData length]
+        [[dataSource controller] _mainReceivedBytesSoFar:[resourceData length]
                                                          fromDataSource:dataSource
                                                                complete:NO];
     }
     
+    [super handle: h didReceiveData: data];
+
     LOG(Download, "%d of %d", [response contentLengthReceived], [response contentLength]);
 }
 
-- (void)handle:(WebResourceHandle *)handle didFailLoadingWithError:(WebError *)result
+- (void)handleDidFinishLoading:(WebResourceHandle *)h
 {
-    LOG(Loading, "URL = %@, result = %@", [result failingURL], [result errorDescription]);
+    LOG(Loading, "URL = %@", currentURL);
+        
+    // Calling receivedError will likely result in a call to release, so we must retain.
+    [self retain];
+
+    WebContentAction contentAction = [[dataSource contentPolicy] policyAction];
+    
+    // Don't retain data for downloaded files
+    if (contentAction != WebContentPolicySave && contentAction != WebContentPolicySaveAndOpenExternally) {
+    	[dataSource _setResourceData:resourceData];
+    }
+
+    if (contentAction == WebContentPolicyShow) {
+        [[dataSource representation] finishedLoadingWithDataSource:dataSource];
+    }
+    
+    if (downloadHandler) {
+        WebError *downloadError = [downloadHandler finishedLoading];
+        if (downloadError)
+            [self receivedError:downloadError];
 
-    if (!downloadHandler)
-        [resourceProgressDelegate resource: identifier didFailLoadingWithError: result fromDataSource: dataSource];
+        [dataSource _setPrimaryLoadComplete:YES];
+        [downloadHandler release];
+        downloadHandler = nil;
+    }
+    else {
+        [dataSource _finishedLoading];
+
+        // FIXME: Please let Chris know if this is really necessary?
+        // Either send a final error message or a final progress message.
+        WebError *nonTerminalError = [[dataSource response] error];
+        if (nonTerminalError) {
+            [self receivedError:nonTerminalError];
+        } else {
+            [[dataSource controller] _mainReceivedBytesSoFar:[resourceData length]
+                                                             fromDataSource:dataSource
+                                                                   complete:YES];
+        }
+    }
+    
+    [super handleDidFinishLoading: h];
+
+    [self release];
+}
+
+- (void)handle:(WebResourceHandle *)h didFailLoadingWithError:(WebError *)result
+{
+    LOG(Loading, "URL = %@, result = %@", [result failingURL], [result errorDescription]);
 
     // Calling receivedError will likely result in a call to release, so we must retain.
     [self retain];
 
-    [self receivedError:result forHandle:handle];
+    [self receivedError:result];
 
     if (downloadHandler) {
         [downloadHandler cancel];
         [downloadHandler release];
         downloadHandler = nil;
     }
-
-    [identifier release];
-    identifier = nil;
-    
-    [self didStopLoading];
     
+    [super handle: h didFailLoadingWithError: result];
+
     [self release];
 }
 
diff --git a/WebKit/WebView.subproj/WebResourceLoadDelegate.h b/WebKit/WebView.subproj/WebResourceLoadDelegate.h
index 8e5ceb6..b41cc8d 100644
--- a/WebKit/WebView.subproj/WebResourceLoadDelegate.h
+++ b/WebKit/WebView.subproj/WebResourceLoadDelegate.h
@@ -4,6 +4,7 @@
         
         Public header file.
 */
+ at class WebDataSource;
 @class WebResourceResponse;
 @class WebResourceRequest;
 
diff --git a/WebKit/WebView.subproj/WebViewPrivate.h b/WebKit/WebView.subproj/WebViewPrivate.h
index 99f7214..b832078 100644
--- a/WebKit/WebView.subproj/WebViewPrivate.h
+++ b/WebKit/WebView.subproj/WebViewPrivate.h
@@ -45,11 +45,9 @@
 
 - (id <WebContextMenuDelegate>)_defaultContextMenuDelegate;
 - (void)_finsishedLoadingResourceFromDataSource:(WebDataSource *)dataSource;
-- (void)_receivedError:(WebError *)error forResourceHandle:(WebResourceHandle *)resourceHandle fromDataSource:(WebDataSource *)dataSource;
-- (void)_mainReceivedProgressForResourceHandle:(WebResourceHandle *)resourceHandle bytesSoFar:(unsigned)bytesSoFar fromDataSource:(WebDataSource *)dataSource complete:(BOOL)isComplete;
-- (void)_mainReceivedError:(WebError *)error forResourceHandle:(WebResourceHandle *)resourceHandle fromDataSource:(WebDataSource *)dataSource;
-- (void)_didStartLoading:(NSURL *)URL;
-- (void)_didStopLoading:(NSURL *)URL;
+- (void)_receivedError:(WebError *)error fromDataSource:(WebDataSource *)dataSource;
+- (void)_mainReceivedBytesSoFar:(unsigned)bytesSoFar fromDataSource:(WebDataSource *)dataSource complete:(BOOL)isComplete;
+- (void)_mainReceivedError:(WebError *)error fromDataSource:(WebDataSource *)dataSource;
 + (NSString *)_MIMETypeForFile:(NSString *)path;
 - (void)_downloadURL:(NSURL *)URL withContentPolicy:(WebContentPolicy *)contentPolicy;
 
diff --git a/WebKit/WebView.subproj/WebViewPrivate.m b/WebKit/WebView.subproj/WebViewPrivate.m
index e12acc4..d03fd7e 100644
--- a/WebKit/WebView.subproj/WebViewPrivate.m
+++ b/WebKit/WebView.subproj/WebViewPrivate.m
@@ -115,7 +115,7 @@
     }
 }
 
-- (void)_mainReceivedProgressForResourceHandle: (WebResourceHandle *)resourceHandle bytesSoFar: (unsigned)bytesSoFar fromDataSource: (WebDataSource *)dataSource complete: (BOOL)isComplete
+- (void)_mainReceivedBytesSoFar: (unsigned)bytesSoFar fromDataSource: (WebDataSource *)dataSource complete: (BOOL)isComplete
 {
     WebFrame *frame = [dataSource webFrame];
     
@@ -125,7 +125,7 @@
     if (frame == nil)
         return;
         
-    // This resouce has completed, so check if the load is complete for all frames.
+    // This resource has completed, so check if the load is complete for all frames.
     if (isComplete){
         // If the load is complete, mark the primary load as done.  The primary load is the load
         // of the main document.  Other resources may still be arriving.
@@ -143,24 +143,15 @@
 }
 
 
-
-- (void)_receivedError: (WebError *)error forResourceHandle: (WebResourceHandle *)resourceHandle fromDataSource: (WebDataSource *)dataSource
+- (void)_receivedError: (WebError *)error fromDataSource: (WebDataSource *)dataSource
 {
     WebFrame *frame = [dataSource webFrame];
 
-    NSString *resourceIdentifier = [[[resourceHandle _request] URL] absoluteString];
-    if (resourceIdentifier == nil) {
-        resourceIdentifier = [error failingURL];
-    }
-    if (resourceIdentifier) {
-        [dataSource _addError:error forResource:resourceIdentifier];
-    }
-    
     [frame _checkLoadComplete];
 }
 
 
-- (void)_mainReceivedError: (WebError *)error forResourceHandle: (WebResourceHandle *)resourceHandle fromDataSource: (WebDataSource *)dataSource
+- (void)_mainReceivedError: (WebError *)error fromDataSource: (WebDataSource *)dataSource
 {
     WebFrame *frame = [dataSource webFrame];
     
@@ -170,16 +161,6 @@
     [frame _checkLoadComplete];
 }
 
-- (void)_didStartLoading: (NSURL *)URL
-{
-    [[WebStandardPanels sharedStandardPanels] _didStartLoadingURL:URL inController:self];
-}
-
-- (void)_didStopLoading: (NSURL *)URL
-{
-    [[WebStandardPanels sharedStandardPanels] _didStopLoadingURL:URL inController:self];
-}
-
 + (NSString *)_MIMETypeForFile: (NSString *)path
 {
     NSString *result;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list