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

cblu cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 06:49:38 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 6afc0b8fb9232f3c1dd7fbc76d406350eed9c4bd
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Oct 15 17:34:31 2002 +0000

    	If a file is renamed during download because a file of the same name already exists, show this in the UI.
    
            * Misc.subproj/WebDownloadHandler.h:
            * Misc.subproj/WebDownloadHandler.m:
            (-[WebDownloadHandler receivedResponse:]): added, create file here
            (-[WebDownloadHandler receivedData:]): don't create file here
            * WebView.subproj/WebMainResourceClient.m:
            (-[WebMainResourceClient handleDidFinishLoading:]): call [dataSource _setPrimaryLoadComplete:YES] for downloads
            (-[WebMainResourceClient handle:didReceiveResponse:]): call [WebDownloadHandler receivedResponse:]
            (-[WebMainResourceClient handle:didReceiveData:]): no download error to handle
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2325 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index c99e761..2b1a5a9 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,16 @@
+2002-10-15  Chris Blumenberg  <cblu at apple.com>
+
+	If a file is renamed during download because a file of the same name already exists, show this in the UI.
+
+        * Misc.subproj/WebDownloadHandler.h:
+        * Misc.subproj/WebDownloadHandler.m:
+        (-[WebDownloadHandler receivedResponse:]): added, create file here
+        (-[WebDownloadHandler receivedData:]): don't create file here
+        * WebView.subproj/WebMainResourceClient.m:
+        (-[WebMainResourceClient handleDidFinishLoading:]): call [dataSource _setPrimaryLoadComplete:YES] for downloads
+        (-[WebMainResourceClient handle:didReceiveResponse:]): call [WebDownloadHandler receivedResponse:]
+        (-[WebMainResourceClient handle:didReceiveData:]): no download error to handle
+
 2002-10-14  Chris Blumenberg  <cblu at apple.com>
 
 	- Made all downloads no matter how prompted, pass through the content policy API so the client can properly choose the file name and correct the extension if necessary. We now ask for the content policy even if one has been predetermined. 
diff --git a/WebKit/ChangeLog-2002-12-03 b/WebKit/ChangeLog-2002-12-03
index c99e761..2b1a5a9 100644
--- a/WebKit/ChangeLog-2002-12-03
+++ b/WebKit/ChangeLog-2002-12-03
@@ -1,3 +1,16 @@
+2002-10-15  Chris Blumenberg  <cblu at apple.com>
+
+	If a file is renamed during download because a file of the same name already exists, show this in the UI.
+
+        * Misc.subproj/WebDownloadHandler.h:
+        * Misc.subproj/WebDownloadHandler.m:
+        (-[WebDownloadHandler receivedResponse:]): added, create file here
+        (-[WebDownloadHandler receivedData:]): don't create file here
+        * WebView.subproj/WebMainResourceClient.m:
+        (-[WebMainResourceClient handleDidFinishLoading:]): call [dataSource _setPrimaryLoadComplete:YES] for downloads
+        (-[WebMainResourceClient handle:didReceiveResponse:]): call [WebDownloadHandler receivedResponse:]
+        (-[WebMainResourceClient handle:didReceiveData:]): no download error to handle
+
 2002-10-14  Chris Blumenberg  <cblu at apple.com>
 
 	- Made all downloads no matter how prompted, pass through the content policy API so the client can properly choose the file name and correct the extension if necessary. We now ask for the content policy even if one has been predetermined. 
diff --git a/WebKit/Misc.subproj/WebDownloadHandler.h b/WebKit/Misc.subproj/WebDownloadHandler.h
index ba1b434..0596849 100644
--- a/WebKit/Misc.subproj/WebDownloadHandler.h
+++ b/WebKit/Misc.subproj/WebDownloadHandler.h
@@ -10,6 +10,7 @@
 
 @class WebDataSource;
 @class WebError;
+ at class WebResourceResponse;
 
 @interface WebDownloadHandler : NSObject
 {
@@ -18,7 +19,8 @@
 }
 
 - initWithDataSource:(WebDataSource *)dSource;
-- (WebError *)receivedData:(NSData *)data;
+- (WebError *)receivedResponse:(WebResourceResponse *)response; 
+- (void)receivedData:(NSData *)data;
 - (WebError *)finishedLoading;
 - (WebError *)cancel;
 @end
diff --git a/WebKit/Misc.subproj/WebDownloadHandler.m b/WebKit/Misc.subproj/WebDownloadHandler.m
index 1b583b1..b879f10 100644
--- a/WebKit/Misc.subproj/WebDownloadHandler.m
+++ b/WebKit/Misc.subproj/WebDownloadHandler.m
@@ -39,49 +39,47 @@
     return [WebError errorWithCode:code inDomain:WebErrorDomainWebKit failingURL:[[dataSource URL] absoluteString]];
 }
 
-- (WebError *)receivedData:(NSData *)data
+- (WebError *)receivedResponse:(WebResourceResponse *)response
 {
     NSString *path = [[dataSource contentPolicy] path];
-    NSString *pathWithoutExtension, *newPathWithoutExtension, *extension;
-    NSFileManager *fileManager;
-    NSWorkspace *workspace;
-    unsigned i;
-    
-    if(!fileHandle){
-        fileManager = [NSFileManager defaultManager];
+    NSFileManager *fileManager = [NSFileManager defaultManager];
+
+    if([fileManager fileExistsAtPath:path]){
+        NSString *pathWithoutExtension = [path stringByDeletingPathExtension];
+        NSString *extension = [path pathExtension];
+        NSString *newPathWithoutExtension;
+        unsigned i;
         
-        if([fileManager fileExistsAtPath:path]){
-            pathWithoutExtension = [path stringByDeletingPathExtension];
-            extension = [path pathExtension];
-            
-            for(i=1; 1; i++){
-                newPathWithoutExtension = [NSString stringWithFormat:@"%@-%d", pathWithoutExtension, i];
-                path = [newPathWithoutExtension stringByAppendingPathExtension:extension];
-                if(![fileManager fileExistsAtPath:path]){
-                    [[dataSource contentPolicy] _setPath:path];
-                    break;
-                }
+        for(i=1; 1; i++){
+            newPathWithoutExtension = [NSString stringWithFormat:@"%@-%d", pathWithoutExtension, i];
+            path = [newPathWithoutExtension stringByAppendingPathExtension:extension];
+            if(![fileManager fileExistsAtPath:path]){
+                [[dataSource contentPolicy] _setPath:path];
+                break;
             }
         }
-        
-        if(![fileManager createFileAtPath:path contents:nil attributes:nil]){
-            return [self errorWithCode:WebErrorCannotCreateFile];
-        }
-        
-        fileHandle = [[NSFileHandle fileHandleForWritingAtPath:path] retain];
-        if(!fileHandle){
-            return [self errorWithCode:WebErrorCannotOpenFile];
-        }
-        
-        workspace = [NSWorkspace sharedWorkspace];
-        [workspace noteFileSystemChanged:path];
     }
-    
-    [fileHandle writeData:data];
+
+    if(![fileManager createFileAtPath:path contents:nil attributes:nil]){
+        return [self errorWithCode:WebErrorCannotCreateFile];
+    }
+
+    fileHandle = [[NSFileHandle fileHandleForWritingAtPath:path] retain];
+    if(!fileHandle){
+        return [self errorWithCode:WebErrorCannotOpenFile];
+    }
+
+    NSWorkspace *workspace = [NSWorkspace sharedWorkspace];
+    [workspace noteFileSystemChanged:path];
 
     return nil;
 }
 
+- (void)receivedData:(NSData *)data
+{
+    [fileHandle writeData:data];
+}
+
 - (WebError *)finishedLoading
 {
     NSString *path = [[dataSource contentPolicy] path];
diff --git a/WebKit/WebView.subproj/WebMainResourceClient.m b/WebKit/WebView.subproj/WebMainResourceClient.m
index 676fdef..641af8c 100644
--- a/WebKit/WebView.subproj/WebMainResourceClient.m
+++ b/WebKit/WebView.subproj/WebMainResourceClient.m
@@ -88,20 +88,6 @@
     return downloadHandler;
 }
 
-- (void)receivedProgressWithHandle:(WebResourceHandle *)handle complete:(BOOL)isComplete
-{
-    WebContentAction contentAction = [[dataSource contentPolicy] policyAction];
-
-    if (contentAction == WebContentPolicySaveAndOpenExternally || contentAction == WebContentPolicySave) {
-        if (isComplete) {
-            [dataSource _setPrimaryLoadComplete:YES];
-        }
-    } else {
-        [[dataSource controller] _mainReceivedProgressForResourceHandle:handle 
-            bytesSoFar: [resourceData length] fromDataSource:dataSource complete:isComplete];
-    }
-}
-
 - (void)receivedError:(WebError *)error forHandle:(WebResourceHandle *)handle
 {    
     WebContentAction contentAction = [[dataSource contentPolicy] policyAction];
@@ -168,6 +154,7 @@
         }else{
             [downloadProgressDelegate resourceRequest:[handle _request] didFinishLoadingFromDataSource:dataSource];
         }
+        [dataSource _setPrimaryLoadComplete:YES];
         [downloadHandler release];
         downloadHandler = nil;
     }
@@ -181,7 +168,10 @@
         if (nonTerminalError) {
             [self receivedError:nonTerminalError forHandle:handle];
         } else {
-            [self receivedProgressWithHandle:handle complete:YES];
+            [[dataSource controller] _mainReceivedProgressForResourceHandle:handle
+                                                                 bytesSoFar:[resourceData length]
+                                                             fromDataSource:dataSource
+                                                                   complete:YES];
         }
     }
     
@@ -262,7 +252,13 @@
         [[dataSource webFrame] _setProvisionalDataSource:nil];
         [[[dataSource controller] locationChangeDelegate] locationChangeDone:nil forDataSource:dataSource];
         downloadHandler = [[WebDownloadHandler alloc] initWithDataSource:dataSource];
+        WebError *downloadError = [downloadHandler receivedResponse:response];
         [downloadProgressDelegate resourceRequest: request didReceiveResponse: response fromDataSource: dataSource];
+
+        if (downloadError) {
+            [self receivedError:downloadError forHandle:handle];
+            [handle cancel];
+        }
         break;
     case WebContentPolicyIgnore:
         [handle cancel];
@@ -278,23 +274,18 @@
 - (void)handle:(WebResourceHandle *)handle didReceiveData:(NSData *)data
 {
     LOG(Loading, "URL = %@, data = %p, length %d", currentURL, data, [data length]);
-    
-    WebError *downloadError = nil;
-    
+        
     if (downloadHandler) {
-        downloadError = [downloadHandler receivedData:data];
+        [downloadHandler receivedData:data];
         [downloadProgressDelegate resourceRequest: request didReceiveContentLength: [data length] fromDataSource:dataSource];
     } else {
         [resourceData appendData:data];
         [dataSource _receivedData:data];
         [resourceProgressDelegate resourceRequest: request didReceiveContentLength: [data length] fromDataSource:dataSource];
-    }
-
-    [self receivedProgressWithHandle:handle complete:NO];
-
-    if (downloadError) {
-        [self receivedError:downloadError forHandle:handle];
-        [handle cancel];
+        [[dataSource controller] _mainReceivedProgressForResourceHandle:handle
+                                                             bytesSoFar:[resourceData length]
+                                                         fromDataSource:dataSource
+                                                               complete:NO];
     }
     
     LOG(Download, "%d of %d", [response contentLengthReceived], [response contentLength]);
diff --git a/WebKit/WebView.subproj/WebMainResourceLoader.m b/WebKit/WebView.subproj/WebMainResourceLoader.m
index 676fdef..641af8c 100644
--- a/WebKit/WebView.subproj/WebMainResourceLoader.m
+++ b/WebKit/WebView.subproj/WebMainResourceLoader.m
@@ -88,20 +88,6 @@
     return downloadHandler;
 }
 
-- (void)receivedProgressWithHandle:(WebResourceHandle *)handle complete:(BOOL)isComplete
-{
-    WebContentAction contentAction = [[dataSource contentPolicy] policyAction];
-
-    if (contentAction == WebContentPolicySaveAndOpenExternally || contentAction == WebContentPolicySave) {
-        if (isComplete) {
-            [dataSource _setPrimaryLoadComplete:YES];
-        }
-    } else {
-        [[dataSource controller] _mainReceivedProgressForResourceHandle:handle 
-            bytesSoFar: [resourceData length] fromDataSource:dataSource complete:isComplete];
-    }
-}
-
 - (void)receivedError:(WebError *)error forHandle:(WebResourceHandle *)handle
 {    
     WebContentAction contentAction = [[dataSource contentPolicy] policyAction];
@@ -168,6 +154,7 @@
         }else{
             [downloadProgressDelegate resourceRequest:[handle _request] didFinishLoadingFromDataSource:dataSource];
         }
+        [dataSource _setPrimaryLoadComplete:YES];
         [downloadHandler release];
         downloadHandler = nil;
     }
@@ -181,7 +168,10 @@
         if (nonTerminalError) {
             [self receivedError:nonTerminalError forHandle:handle];
         } else {
-            [self receivedProgressWithHandle:handle complete:YES];
+            [[dataSource controller] _mainReceivedProgressForResourceHandle:handle
+                                                                 bytesSoFar:[resourceData length]
+                                                             fromDataSource:dataSource
+                                                                   complete:YES];
         }
     }
     
@@ -262,7 +252,13 @@
         [[dataSource webFrame] _setProvisionalDataSource:nil];
         [[[dataSource controller] locationChangeDelegate] locationChangeDone:nil forDataSource:dataSource];
         downloadHandler = [[WebDownloadHandler alloc] initWithDataSource:dataSource];
+        WebError *downloadError = [downloadHandler receivedResponse:response];
         [downloadProgressDelegate resourceRequest: request didReceiveResponse: response fromDataSource: dataSource];
+
+        if (downloadError) {
+            [self receivedError:downloadError forHandle:handle];
+            [handle cancel];
+        }
         break;
     case WebContentPolicyIgnore:
         [handle cancel];
@@ -278,23 +274,18 @@
 - (void)handle:(WebResourceHandle *)handle didReceiveData:(NSData *)data
 {
     LOG(Loading, "URL = %@, data = %p, length %d", currentURL, data, [data length]);
-    
-    WebError *downloadError = nil;
-    
+        
     if (downloadHandler) {
-        downloadError = [downloadHandler receivedData:data];
+        [downloadHandler receivedData:data];
         [downloadProgressDelegate resourceRequest: request didReceiveContentLength: [data length] fromDataSource:dataSource];
     } else {
         [resourceData appendData:data];
         [dataSource _receivedData:data];
         [resourceProgressDelegate resourceRequest: request didReceiveContentLength: [data length] fromDataSource:dataSource];
-    }
-
-    [self receivedProgressWithHandle:handle complete:NO];
-
-    if (downloadError) {
-        [self receivedError:downloadError forHandle:handle];
-        [handle cancel];
+        [[dataSource controller] _mainReceivedProgressForResourceHandle:handle
+                                                             bytesSoFar:[resourceData length]
+                                                         fromDataSource:dataSource
+                                                               complete:NO];
     }
     
     LOG(Download, "%d of %d", [response contentLengthReceived], [response contentLength]);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list