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

mjs mjs at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:00:09 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 61d1c33719632b7e69c7d88657412b7d5ec729bf
Author: mjs <mjs at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Nov 14 13:18:36 2002 +0000

    WebKit:
    
    	Combined file URL policy with content policy. We don't actually
    	bother to ask earlier for file URLs yet, since that will make
    	things more complicated.
    
            * Misc.subproj/WebKitErrors.h:
            * WebView.subproj/WebControllerPolicyDelegate.h:
            * WebView.subproj/WebDefaultPolicyDelegate.m:
            * WebView.subproj/WebFramePrivate.h:
            * WebView.subproj/WebFramePrivate.m:
            (-[WebFrame _handleUnimplementablePolicy:errorCode:forURL:]):
            (-[WebFrame _continueAfterNavigationPolicyForRequest:dataSource:]):
            * WebView.subproj/WebMainResourceClient.h:
            * WebView.subproj/WebMainResourceClient.m:
            (-[WebMainResourceClient stopLoadingAfterContentPolicy]):
            (-[WebMainResourceClient handle:didReceiveResponse:]):
            * WebView.subproj/WebView.m:
            (+[WebView initialize]):
    
    WebBrowser:
    
    	Combined file URL policy with content policy. Also adjusted error
    	handling to continue to handle file errors well.
    
            * BrowserWebController.m:
            (-[BrowserWebController unableToImplementPolicy:error:forURL:inFrame:]):
            (-[BrowserWebController contentPolicyForMIMEType:andRequest:inFrame:]):
            * LocationChangeError.m:
            (-[LocationChangeHandler specializedTitleForError:]):
            (-[LocationChangeHandler specializedMessageForError:]):
            * LocationChangeHandler.m:
            (-[LocationChangeHandler locationChangeDone:forDataSource:]):
            * WebBrowser.pbproj/project.pbxproj:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2671 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 2eeff63..cba49af 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,23 @@
+2002-11-14  Maciej Stachowiak  <mjs at apple.com>
+
+	Combined file URL policy with content policy. We don't actually
+	bother to ask earlier for file URLs yet, since that will make
+	things more complicated.
+	
+        * Misc.subproj/WebKitErrors.h:
+        * WebView.subproj/WebControllerPolicyDelegate.h:
+        * WebView.subproj/WebDefaultPolicyDelegate.m:
+        * WebView.subproj/WebFramePrivate.h:
+        * WebView.subproj/WebFramePrivate.m:
+        (-[WebFrame _handleUnimplementablePolicy:errorCode:forURL:]):
+        (-[WebFrame _continueAfterNavigationPolicyForRequest:dataSource:]):
+        * WebView.subproj/WebMainResourceClient.h:
+        * WebView.subproj/WebMainResourceClient.m:
+        (-[WebMainResourceClient stopLoadingAfterContentPolicy]):
+        (-[WebMainResourceClient handle:didReceiveResponse:]):
+        * WebView.subproj/WebView.m:
+        (+[WebView initialize]):
+
 2002-11-14  Darin Adler  <darin at apple.com>
 
 	- fixed 3099240 -- REGRESSION: repro assert d->m_doc->parsing
diff --git a/WebKit/ChangeLog-2002-12-03 b/WebKit/ChangeLog-2002-12-03
index 2eeff63..cba49af 100644
--- a/WebKit/ChangeLog-2002-12-03
+++ b/WebKit/ChangeLog-2002-12-03
@@ -1,3 +1,23 @@
+2002-11-14  Maciej Stachowiak  <mjs at apple.com>
+
+	Combined file URL policy with content policy. We don't actually
+	bother to ask earlier for file URLs yet, since that will make
+	things more complicated.
+	
+        * Misc.subproj/WebKitErrors.h:
+        * WebView.subproj/WebControllerPolicyDelegate.h:
+        * WebView.subproj/WebDefaultPolicyDelegate.m:
+        * WebView.subproj/WebFramePrivate.h:
+        * WebView.subproj/WebFramePrivate.m:
+        (-[WebFrame _handleUnimplementablePolicy:errorCode:forURL:]):
+        (-[WebFrame _continueAfterNavigationPolicyForRequest:dataSource:]):
+        * WebView.subproj/WebMainResourceClient.h:
+        * WebView.subproj/WebMainResourceClient.m:
+        (-[WebMainResourceClient stopLoadingAfterContentPolicy]):
+        (-[WebMainResourceClient handle:didReceiveResponse:]):
+        * WebView.subproj/WebView.m:
+        (+[WebView initialize]):
+
 2002-11-14  Darin Adler  <darin at apple.com>
 
 	- fixed 3099240 -- REGRESSION: repro assert d->m_doc->parsing
diff --git a/WebKit/Misc.subproj/WebKitErrors.h b/WebKit/Misc.subproj/WebKitErrors.h
index f4cefc1..0528cb6 100644
--- a/WebKit/Misc.subproj/WebKitErrors.h
+++ b/WebKit/Misc.subproj/WebKitErrors.h
@@ -12,10 +12,8 @@ extern NSString *WebErrorDomainWebKit;
 
 /*!
     @enum
-    @constant WebErrorCannotFindFile
     @constant WebErrorCannotCreateFile
     @constant WebErrorCannotOpenFile
-    @constant WebErrorCannotReadFile
     @constant WebErrorCannotWriteToFile
     @constant WebErrorCannotRemoveFile
     @constant WebErrorCannotFindApplicationForFile
@@ -29,10 +27,8 @@ extern NSString *WebErrorDomainWebKit;
     @constant WebErrorDownloadDecodingFailedToComplete
 */
 enum {
-    WebErrorCannotFindFile,
     WebErrorCannotCreateFile,
     WebErrorCannotOpenFile,
-    WebErrorCannotReadFile,
     WebErrorCannotWriteToFile,
     WebErrorCannotRemoveFile,
     WebErrorCannotFindApplicationForFile,
diff --git a/WebKit/WebView.subproj/WebControllerPolicyDelegate.h b/WebKit/WebView.subproj/WebControllerPolicyDelegate.h
index 4a7cab5..05829d4 100644
--- a/WebKit/WebView.subproj/WebControllerPolicyDelegate.h
+++ b/WebKit/WebView.subproj/WebControllerPolicyDelegate.h
@@ -54,37 +54,20 @@ typedef enum {
     WebPolicyOpenURL,
     WebPolicyOpenNewWindow,
     WebPolicyOpenNewWindowBehind,
-    WebPolicyIgnore
+    WebPolicyIgnore,
+    WebPolicyShow
 } WebPolicyAction;
 
-/*!
-    @enum WebFileAction
-    @constant WebFileURLPolicyUseContentPolicy Continue processing the file, ask for content policy.
-    @constant WebFileURLPolicyOpenExternally Open the file in another application.
-    @constant WebFileURLPolicyRevealInFinder Reveal the file in the Finder.
-    @constant WebFileURLPolicyIgnore Do nothing with the file.
-*/
-typedef enum {
-    WebFileURLPolicyUseContentPolicy = WebPolicyUse,
-    WebFileURLPolicyOpenExternally = WebPolicyOpenURL,
-    WebFileURLPolicyRevealInFinder = WebPolicyRevealInFinder,
-    WebFileURLPolicyIgnore = WebPolicyIgnore
-} WebFileAction;
 
-/*!
-    @enum WebContentAction
-    @constant WebContentPolicyNone Unitialized state.
-    @constant WebContentPolicyShow Show the content in WebKit.
-    @constant WebContentPolicySave Save the content to disk.
-    @constant WebContentPolicyIgnore Do nothing with the content.
-*/
-typedef enum {
-    WebContentPolicyNone = WebPolicyNone,
-    WebContentPolicyShow = WebPolicyUse,
-    WebContentPolicySave = WebPolicySave,
-    WebContentPolicyIgnore = WebPolicyIgnore
-} WebContentAction;
+ at class WebPolicyDecisionListenerPrivate;
+
+ at interface WebPolicyDecisionListener : NSObject
+{
+ at private
+    WebPolicyDecisionListenerPrivate *_private
+}
 
+ at end
 
 
 /*!
@@ -94,7 +77,6 @@ typedef enum {
     the URL represents. Typically, the policy handler methods are called in this order:
 
     navigationPolicyForAction:andRequest:inFrame:<BR>
-    fileURLPolicyForMIMEType:andRequest:inFrame:<BR>
     contentPolicyForMIMEType:andRequest:inFrame:<BR>
 */
 @protocol WebControllerPolicyDelegate <NSObject>
@@ -111,17 +93,6 @@ typedef enum {
                                   andRequest:(WebResourceRequest *)request
                                      inFrame:(WebFrame *)frame;
 
-/*!
-     @method fileURLPolicyForMIMEType:inFrame:isDirectory:
-     @discussion Called when the response to URLPolicyForURL is WebURLPolicyUseContentPolicy and the URL is
-     a file URL. This allows clients to special-case WebKit's behavior for file URLs.
-     @param type MIME type for the file.
-     @param request WebResourceRequest to be used to load the item
-     @param frame The frame which will load the file.
-*/
-- (WebFileAction)fileURLPolicyForMIMEType:(NSString *)type
-                               andRequest:(WebResourceRequest *)request
-                                  inFrame:(WebFrame *)frame;
 
 /*!
     @method contentPolicyForResponse:andRequest:inFrame:withContentPolicy:
@@ -130,9 +101,9 @@ typedef enum {
     @param request A WebResourceRequest for the partially loaded content.
     @param frame The frame which is loading the URL.
 */
-- (WebContentAction)contentPolicyForMIMEType:(NSString *)type
-                                    andRequest:(WebResourceRequest *)request
-                                       inFrame:(WebFrame *)frame;
+- (WebPolicyAction)contentPolicyForMIMEType:(NSString *)type
+                                 andRequest:(WebResourceRequest *)request
+                                    inFrame:(WebFrame *)frame;
 
 
 /*!
diff --git a/WebKit/WebView.subproj/WebDefaultPolicyDelegate.m b/WebKit/WebView.subproj/WebDefaultPolicyDelegate.m
index 42c779e..19ab04a 100644
--- a/WebKit/WebView.subproj/WebDefaultPolicyDelegate.m
+++ b/WebKit/WebView.subproj/WebDefaultPolicyDelegate.m
@@ -21,18 +21,6 @@
     return self;
 }
 
-- (WebFileAction)fileURLPolicyForMIMEType:(NSString *)type andRequest:(WebResourceRequest *)request inFrame:(WebFrame *)frame
-{
-    BOOL isDirectory;
-    [[NSFileManager defaultManager] fileExistsAtPath:[[request URL] path] isDirectory:&isDirectory];
-
-    if(isDirectory)
-        return WebFileURLPolicyIgnore;
-    if([WebController canShowMIMEType:type])
-        return WebFileURLPolicyUseContentPolicy;
-    return WebFileURLPolicyIgnore;
-}
-
 - (void)unableToImplementPolicy:(WebPolicyAction)policy error:(WebError *)error forURL:(NSURL *)URL inFrame:(WebFrame *)frame
 {
     NSLog (@"called unableToImplementPolicy:%derror:%@:inFrame:%@", policy, error, frame);
@@ -43,10 +31,21 @@
 				 andRequest:(WebResourceRequest *)request
 				    inFrame:(WebFrame *)frame;
 {
+    if ([[request URL] isFileURL]) {
+	BOOL isDirectory;
+	[[NSFileManager defaultManager] fileExistsAtPath:[[request URL] path] isDirectory:&isDirectory];
+	
+	if(isDirectory)
+	    return WebPolicyIgnore;
+	if([WebController canShowMIMEType:type])
+	    return WebPolicyShow;
+	return WebPolicyIgnore;
+    }
+
     if ([WebController canShowMIMEType:type]) {
-        return WebContentPolicyShow;
+        return WebPolicyShow;
     } else {
-        return WebContentPolicyIgnore;
+        return WebPolicyIgnore;
     }
 }
 
diff --git a/WebKit/WebView.subproj/WebFramePrivate.h b/WebKit/WebView.subproj/WebFramePrivate.h
index 62f0462..fa13050 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.h
+++ b/WebKit/WebView.subproj/WebFramePrivate.h
@@ -137,5 +137,6 @@ typedef enum {
 
 - (WebHistoryItem *)_itemForSavingDocState;
 - (WebHistoryItem *)_itemForRestoringDocState;
+- (void)_handleUnimplementablePolicy:(WebPolicyAction)policy errorCode:(int)code forURL:(NSURL *)URL;
 
 @end
diff --git a/WebKit/WebView.subproj/WebFramePrivate.m b/WebKit/WebView.subproj/WebFramePrivate.m
index 6bb1000..656bce4 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.m
+++ b/WebKit/WebView.subproj/WebFramePrivate.m
@@ -731,7 +731,7 @@ static const char * const stateNames[] = {
     return _private->bridge;
 }
 
-- (void)handleUnimplementablePolicy:(WebPolicyAction)policy errorCode:(int)code forURL:(NSURL *)URL
+- (void)_handleUnimplementablePolicy:(WebPolicyAction)policy errorCode:(int)code forURL:(NSURL *)URL
 {
     WebError *error = [WebError errorWithCode:code
                                      inDomain:WebErrorDomainWebKit
@@ -932,59 +932,6 @@ static const char * const stateNames[] = {
 			 forKey:WebActionNavigationTypeKey];
 }
 
--(BOOL)_continueAfterFileURLPolicyForRequest:(WebResourceRequest *)request
-{
-    NSFileManager *fileManager = [NSFileManager defaultManager];
-    NSString *path = [[request URL] path];
-    NSString *type = [WebController _MIMETypeForFile: path];
-    WebFileAction fileURLPolicy = [[[self controller] policyDelegate] fileURLPolicyForMIMEType:type andRequest:request inFrame:self];
-    
-    if(fileURLPolicy == WebFileURLPolicyIgnore)
-	return NO;
-    
-    BOOL isDirectory;
-    BOOL fileExists = [fileManager fileExistsAtPath:[[request URL] path] isDirectory:&isDirectory];
-    
-    if(!fileExists){
-	[self handleUnimplementablePolicy:fileURLPolicy errorCode:WebErrorCannotFindFile forURL:[request URL]];
-	return NO;
-    }
-    
-    if(![fileManager isReadableFileAtPath:path]){
-	[self handleUnimplementablePolicy:fileURLPolicy errorCode:WebErrorCannotReadFile forURL:[request URL]];
-	return NO;
-    }
-    
-    switch (fileURLPolicy) {
-    case WebFileURLPolicyUseContentPolicy:
-	if (isDirectory) {
-	    [self handleUnimplementablePolicy:fileURLPolicy errorCode:WebErrorCannotShowDirectory forURL:[request URL]];
-	    return NO;
-	} else if (![WebController canShowMIMEType: type]) {
-	    [self handleUnimplementablePolicy:fileURLPolicy errorCode:WebErrorCannotShowMIMEType forURL:[request URL]];
-	    return NO;
-	}
-	return YES;
-	
-    case WebFileURLPolicyOpenExternally:
-	if(![[NSWorkspace sharedWorkspace] openFile:path]){
-	    [self handleUnimplementablePolicy:fileURLPolicy errorCode:WebErrorCannotFindApplicationForFile forURL:[request URL]];
-	}
-	return NO;
-	
-    case WebFileURLPolicyRevealInFinder:
-	if(![[NSWorkspace sharedWorkspace] selectFile:path inFileViewerRootedAtPath:@""]){
-	    [self handleUnimplementablePolicy:fileURLPolicy errorCode:WebErrorFinderCannotOpenDirectory forURL:[request URL]];
-	}
-	return NO;
-	
-    default:
-	[NSException raise:NSInvalidArgumentException format:
-			 @"fileURLPolicyForMIMEType:inFrame:isDirectory: returned WebFileURLPolicy with invalid action %d", fileURLPolicy];
-	return NO;
-    }
-}
-
 -(BOOL)_continueAfterNavigationPolicyForRequest:(WebResourceRequest *)request dataSource:(WebDataSource *)dataSource
 {
     NSDictionary *action = [dataSource _triggeringAction];
@@ -1008,8 +955,14 @@ static const char * const stateNames[] = {
     case WebPolicyIgnore:
 	break;
     case WebPolicyOpenURL:
-	if(![[NSWorkspace sharedWorkspace] openURL:[request URL]]){
-	    [self handleUnimplementablePolicy:policy errorCode:WebErrorCannotNotFindApplicationForURL forURL:[request URL]];
+	if ([[request URL] isFileURL]) {
+	    if(![[NSWorkspace sharedWorkspace] openFile:[[request URL] path]]){
+		[[dataSource webFrame] _handleUnimplementablePolicy:policy errorCode:WebErrorCannotFindApplicationForFile forURL:[request URL]];
+	    }
+	} else {
+	    if(![[NSWorkspace sharedWorkspace] openURL:[request URL]]){
+		[[dataSource webFrame] _handleUnimplementablePolicy:policy errorCode:WebErrorCannotNotFindApplicationForURL forURL:[request URL]];
+	    }
 	}
 	break;
     case WebPolicyOpenNewWindow:
@@ -1021,17 +974,20 @@ static const char * const stateNames[] = {
     case WebPolicySave:
 	[[self controller] _downloadURL:[request URL]];
 	break;
-    case WebPolicyUse:
-	if ([[request URL] isFileURL]) {
-	    return [self _continueAfterFileURLPolicyForRequest:request];
-	} else {
-	    if (![WebResourceHandle canInitWithRequest:request]) {
-		[self handleUnimplementablePolicy:policy errorCode:WebErrorCannotShowURL forURL:[request URL]];
-	    } else {
-		return YES;
-	    }
+    case WebPolicyRevealInFinder:
+	if (![[request URL] isFileURL]) {
+	    [NSException raise:NSInvalidArgumentException
+			 format:@"clickPolicyForElement:button:modifierFlags: returned an invalid WebClickPolicy"];
+	} else if (![[NSWorkspace sharedWorkspace] selectFile:[[request URL] path] inFileViewerRootedAtPath:@""]) {
+	    [self _handleUnimplementablePolicy:policy errorCode:WebErrorFinderCannotOpenDirectory forURL:[request URL]];
 	}
 	break;
+    case WebPolicyUse:
+	if (![WebResourceHandle canInitWithRequest:request]) {
+	    [self _handleUnimplementablePolicy:policy errorCode:WebErrorCannotShowURL forURL:[request URL]];
+	}
+	return YES;
+
     default:
 	[NSException raise:NSInvalidArgumentException
 		     format:@"clickPolicyForElement:button:modifierFlags: returned an invalid WebClickPolicy"];
diff --git a/WebKit/WebView.subproj/WebFrameView.m b/WebKit/WebView.subproj/WebFrameView.m
index 700dd87..e3dd735 100644
--- a/WebKit/WebView.subproj/WebFrameView.m
+++ b/WebKit/WebView.subproj/WebFrameView.m
@@ -38,10 +38,8 @@ NSString *WebErrorDomainWebKit = @"WebErrorDomainWebKit";
 
 @implementation WebView
 
-#define WebErrorDescriptionCannotFindFile UI_STRING("Cannot find file", "WebErrorCannotFindFile description")
 #define WebErrorDescriptionCannotCreateFile UI_STRING("Cannot create file", "WebErrorCannotCreateFile description")
 #define WebErrorDescriptionCannotOpenFile UI_STRING("Cannot open file", "WebErrorCannotOpenFile description")
-#define WebErrorDescriptionCannotReadFile UI_STRING("Cannot read file", "WebErrorCannotReadFile description")
 #define WebErrorDescriptionCannotWriteToFile UI_STRING("Cannot write file", "WebErrorCannotWriteToFile description")
 #define WebErrorDescriptionCannotRemoveFile UI_STRING("Cannot remove file", "WebErrorCannotRemoveFile description")
 #define WebErrorDescriptionCannotFindApplicationForFile UI_STRING("Cannot find application for file", "WebErrorCannotFindApplicationForFile description")
@@ -57,10 +55,8 @@ NSString *WebErrorDomainWebKit = @"WebErrorDomainWebKit";
 + (void)initialize
 {
     NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
-    WebErrorDescriptionCannotFindFile, 			[NSNumber numberWithInt: WebErrorCannotFindFile],
     WebErrorDescriptionCannotCreateFile, 		[NSNumber numberWithInt: WebErrorCannotCreateFile],
     WebErrorDescriptionCannotOpenFile, 			[NSNumber numberWithInt: WebErrorCannotOpenFile],
-    WebErrorDescriptionCannotReadFile, 			[NSNumber numberWithInt: WebErrorCannotReadFile],
     WebErrorDescriptionCannotWriteToFile, 		[NSNumber numberWithInt: WebErrorCannotWriteToFile],
     WebErrorDescriptionCannotRemoveFile, 		[NSNumber numberWithInt: WebErrorCannotRemoveFile],
     WebErrorDescriptionCannotFindApplicationForFile, 	[NSNumber numberWithInt: WebErrorCannotFindApplicationForFile],
diff --git a/WebKit/WebView.subproj/WebMainResourceClient.h b/WebKit/WebView.subproj/WebMainResourceClient.h
index 7cb20d5..8e84eb8 100644
--- a/WebKit/WebView.subproj/WebMainResourceClient.h
+++ b/WebKit/WebView.subproj/WebMainResourceClient.h
@@ -23,7 +23,6 @@
 @interface WebMainResourceClient : WebBaseResourceHandleDelegate
 {
     WebDownloadHandler *downloadHandler;
-    WebContentAction policyAction;
     NSMutableData *resourceData;
     int _contentLength; // for logging only
     int _bytesReceived; // for logging only
diff --git a/WebKit/WebView.subproj/WebMainResourceClient.m b/WebKit/WebView.subproj/WebMainResourceClient.m
index 1bc4aa5..1078484 100644
--- a/WebKit/WebView.subproj/WebMainResourceClient.m
+++ b/WebKit/WebView.subproj/WebMainResourceClient.m
@@ -133,57 +133,94 @@
     [super notifyDelegatesOfInterruptionByPolicyChange];
 }
 
+
+-(void)stopLoadingAfterContentPolicy
+{
+    [[dataSource webFrame] _setProvisionalDataSource:nil];
+    [self notifyDelegatesOfInterruptionByPolicyChange];
+    [self cancelQuietly];
+}
+
 -(void)handle:(WebResourceHandle *)h didReceiveResponse:(WebResourceResponse *)r
 {
     [dataSource _setResponse:r];
 
     LOG(Download, "main content type: %@", [r contentType]);
 
-    WebContentAction contentPolicy;
+    WebPolicyAction contentPolicy;
+
+    WebResourceRequest *req = [dataSource request];
+
 
     // Figure out the content policy.
     if (![dataSource isDownloading]) {
 	contentPolicy = [[[dataSource controller] policyDelegate] contentPolicyForMIMEType:[r contentType]
-								  andRequest:[dataSource request]
+								  andRequest:req
 								  inFrame:[dataSource webFrame]];
     } else {
-	contentPolicy = WebContentPolicySave;
+	contentPolicy = WebPolicySave;
     }
 
     switch (contentPolicy) {
-    case WebContentPolicyShow:
+    case WebPolicyShow:
+	if (![WebController canShowMIMEType:[r contentType]]) {
+	    [[dataSource webFrame] _handleUnimplementablePolicy:contentPolicy errorCode:WebErrorCannotShowMIMEType forURL:[req URL]];
+	    [self stopLoadingAfterContentPolicy];
+	    return;
+	}
         break;
         
-    case WebContentPolicySave:
-        {
-	    [dataSource _setIsDownloading:YES];
+    case WebPolicySave:
+	[dataSource _setIsDownloading:YES];
+	
+	if ([dataSource downloadPath] == nil) {
+	    NSString *saveFilename = [[[dataSource controller] policyDelegate] saveFilenameForResponse:r andRequest:req];
+	    [dataSource _setDownloadPath:saveFilename];
+	}
+	
+	[[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];
+        break;
 
-	    if ([dataSource downloadPath] == nil) {
-		NSString *saveFilename = [[[dataSource controller] policyDelegate] saveFilenameForResponse:r andRequest:[dataSource request]];
-		[dataSource _setDownloadPath:saveFilename];
+    case WebPolicyOpenURL:
+	if ([[req URL] isFileURL]) {
+	    if(![[NSWorkspace sharedWorkspace] openFile:[[req URL] path]]){
+		[[dataSource webFrame] _handleUnimplementablePolicy:contentPolicy errorCode:WebErrorCannotFindApplicationForFile forURL:[req URL]];
 	    }
-
-            [[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];
-        }
-        break;
+	} else {
+	    if(![[NSWorkspace sharedWorkspace] openURL:[req URL]]){
+		[[dataSource webFrame] _handleUnimplementablePolicy:contentPolicy errorCode:WebErrorCannotNotFindApplicationForURL forURL:[req URL]];
+	    }
+	}
+
+	[self stopLoadingAfterContentPolicy];
+	return;
+	break;
+	
+    case WebPolicyRevealInFinder:
+	if (![[req URL] isFileURL]) {
+	    ERROR("contentPolicyForMIMEType:andRequest:inFrame: returned an invalid content policy.");
+	} else if (![[NSWorkspace sharedWorkspace] selectFile:[[req URL] path] inFileViewerRootedAtPath:@""]) {
+	    [[dataSource webFrame] _handleUnimplementablePolicy:contentPolicy errorCode:WebErrorFinderCannotOpenDirectory forURL:[req URL]];
+	}
+
+	[self stopLoadingAfterContentPolicy];
+	return;
+	break;
     
-    case WebContentPolicyIgnore:
-        {
-            [self cancel];
-            [[dataSource webFrame] _setProvisionalDataSource:nil];
-            [self notifyDelegatesOfInterruptionByPolicyChange];
-        }
+    case WebPolicyIgnore:
+	[self stopLoadingAfterContentPolicy];
+	return;
         break;
     
     default:
-        ERROR("contentPolicyForMIMEType:URL:inFrame: returned an invalid content policy.");
+        ERROR("contentPolicyForMIMEType:andRequest:inFrame: returned an invalid content policy.");
     }
 
     [super handle:h didReceiveResponse:r];
diff --git a/WebKit/WebView.subproj/WebMainResourceLoader.h b/WebKit/WebView.subproj/WebMainResourceLoader.h
index 7cb20d5..8e84eb8 100644
--- a/WebKit/WebView.subproj/WebMainResourceLoader.h
+++ b/WebKit/WebView.subproj/WebMainResourceLoader.h
@@ -23,7 +23,6 @@
 @interface WebMainResourceClient : WebBaseResourceHandleDelegate
 {
     WebDownloadHandler *downloadHandler;
-    WebContentAction policyAction;
     NSMutableData *resourceData;
     int _contentLength; // for logging only
     int _bytesReceived; // for logging only
diff --git a/WebKit/WebView.subproj/WebMainResourceLoader.m b/WebKit/WebView.subproj/WebMainResourceLoader.m
index 1bc4aa5..1078484 100644
--- a/WebKit/WebView.subproj/WebMainResourceLoader.m
+++ b/WebKit/WebView.subproj/WebMainResourceLoader.m
@@ -133,57 +133,94 @@
     [super notifyDelegatesOfInterruptionByPolicyChange];
 }
 
+
+-(void)stopLoadingAfterContentPolicy
+{
+    [[dataSource webFrame] _setProvisionalDataSource:nil];
+    [self notifyDelegatesOfInterruptionByPolicyChange];
+    [self cancelQuietly];
+}
+
 -(void)handle:(WebResourceHandle *)h didReceiveResponse:(WebResourceResponse *)r
 {
     [dataSource _setResponse:r];
 
     LOG(Download, "main content type: %@", [r contentType]);
 
-    WebContentAction contentPolicy;
+    WebPolicyAction contentPolicy;
+
+    WebResourceRequest *req = [dataSource request];
+
 
     // Figure out the content policy.
     if (![dataSource isDownloading]) {
 	contentPolicy = [[[dataSource controller] policyDelegate] contentPolicyForMIMEType:[r contentType]
-								  andRequest:[dataSource request]
+								  andRequest:req
 								  inFrame:[dataSource webFrame]];
     } else {
-	contentPolicy = WebContentPolicySave;
+	contentPolicy = WebPolicySave;
     }
 
     switch (contentPolicy) {
-    case WebContentPolicyShow:
+    case WebPolicyShow:
+	if (![WebController canShowMIMEType:[r contentType]]) {
+	    [[dataSource webFrame] _handleUnimplementablePolicy:contentPolicy errorCode:WebErrorCannotShowMIMEType forURL:[req URL]];
+	    [self stopLoadingAfterContentPolicy];
+	    return;
+	}
         break;
         
-    case WebContentPolicySave:
-        {
-	    [dataSource _setIsDownloading:YES];
+    case WebPolicySave:
+	[dataSource _setIsDownloading:YES];
+	
+	if ([dataSource downloadPath] == nil) {
+	    NSString *saveFilename = [[[dataSource controller] policyDelegate] saveFilenameForResponse:r andRequest:req];
+	    [dataSource _setDownloadPath:saveFilename];
+	}
+	
+	[[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];
+        break;
 
-	    if ([dataSource downloadPath] == nil) {
-		NSString *saveFilename = [[[dataSource controller] policyDelegate] saveFilenameForResponse:r andRequest:[dataSource request]];
-		[dataSource _setDownloadPath:saveFilename];
+    case WebPolicyOpenURL:
+	if ([[req URL] isFileURL]) {
+	    if(![[NSWorkspace sharedWorkspace] openFile:[[req URL] path]]){
+		[[dataSource webFrame] _handleUnimplementablePolicy:contentPolicy errorCode:WebErrorCannotFindApplicationForFile forURL:[req URL]];
 	    }
-
-            [[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];
-        }
-        break;
+	} else {
+	    if(![[NSWorkspace sharedWorkspace] openURL:[req URL]]){
+		[[dataSource webFrame] _handleUnimplementablePolicy:contentPolicy errorCode:WebErrorCannotNotFindApplicationForURL forURL:[req URL]];
+	    }
+	}
+
+	[self stopLoadingAfterContentPolicy];
+	return;
+	break;
+	
+    case WebPolicyRevealInFinder:
+	if (![[req URL] isFileURL]) {
+	    ERROR("contentPolicyForMIMEType:andRequest:inFrame: returned an invalid content policy.");
+	} else if (![[NSWorkspace sharedWorkspace] selectFile:[[req URL] path] inFileViewerRootedAtPath:@""]) {
+	    [[dataSource webFrame] _handleUnimplementablePolicy:contentPolicy errorCode:WebErrorFinderCannotOpenDirectory forURL:[req URL]];
+	}
+
+	[self stopLoadingAfterContentPolicy];
+	return;
+	break;
     
-    case WebContentPolicyIgnore:
-        {
-            [self cancel];
-            [[dataSource webFrame] _setProvisionalDataSource:nil];
-            [self notifyDelegatesOfInterruptionByPolicyChange];
-        }
+    case WebPolicyIgnore:
+	[self stopLoadingAfterContentPolicy];
+	return;
         break;
     
     default:
-        ERROR("contentPolicyForMIMEType:URL:inFrame: returned an invalid content policy.");
+        ERROR("contentPolicyForMIMEType:andRequest:inFrame: returned an invalid content policy.");
     }
 
     [super handle:h didReceiveResponse:r];
diff --git a/WebKit/WebView.subproj/WebPolicyDelegate.h b/WebKit/WebView.subproj/WebPolicyDelegate.h
index 4a7cab5..05829d4 100644
--- a/WebKit/WebView.subproj/WebPolicyDelegate.h
+++ b/WebKit/WebView.subproj/WebPolicyDelegate.h
@@ -54,37 +54,20 @@ typedef enum {
     WebPolicyOpenURL,
     WebPolicyOpenNewWindow,
     WebPolicyOpenNewWindowBehind,
-    WebPolicyIgnore
+    WebPolicyIgnore,
+    WebPolicyShow
 } WebPolicyAction;
 
-/*!
-    @enum WebFileAction
-    @constant WebFileURLPolicyUseContentPolicy Continue processing the file, ask for content policy.
-    @constant WebFileURLPolicyOpenExternally Open the file in another application.
-    @constant WebFileURLPolicyRevealInFinder Reveal the file in the Finder.
-    @constant WebFileURLPolicyIgnore Do nothing with the file.
-*/
-typedef enum {
-    WebFileURLPolicyUseContentPolicy = WebPolicyUse,
-    WebFileURLPolicyOpenExternally = WebPolicyOpenURL,
-    WebFileURLPolicyRevealInFinder = WebPolicyRevealInFinder,
-    WebFileURLPolicyIgnore = WebPolicyIgnore
-} WebFileAction;
 
-/*!
-    @enum WebContentAction
-    @constant WebContentPolicyNone Unitialized state.
-    @constant WebContentPolicyShow Show the content in WebKit.
-    @constant WebContentPolicySave Save the content to disk.
-    @constant WebContentPolicyIgnore Do nothing with the content.
-*/
-typedef enum {
-    WebContentPolicyNone = WebPolicyNone,
-    WebContentPolicyShow = WebPolicyUse,
-    WebContentPolicySave = WebPolicySave,
-    WebContentPolicyIgnore = WebPolicyIgnore
-} WebContentAction;
+ at class WebPolicyDecisionListenerPrivate;
+
+ at interface WebPolicyDecisionListener : NSObject
+{
+ at private
+    WebPolicyDecisionListenerPrivate *_private
+}
 
+ at end
 
 
 /*!
@@ -94,7 +77,6 @@ typedef enum {
     the URL represents. Typically, the policy handler methods are called in this order:
 
     navigationPolicyForAction:andRequest:inFrame:<BR>
-    fileURLPolicyForMIMEType:andRequest:inFrame:<BR>
     contentPolicyForMIMEType:andRequest:inFrame:<BR>
 */
 @protocol WebControllerPolicyDelegate <NSObject>
@@ -111,17 +93,6 @@ typedef enum {
                                   andRequest:(WebResourceRequest *)request
                                      inFrame:(WebFrame *)frame;
 
-/*!
-     @method fileURLPolicyForMIMEType:inFrame:isDirectory:
-     @discussion Called when the response to URLPolicyForURL is WebURLPolicyUseContentPolicy and the URL is
-     a file URL. This allows clients to special-case WebKit's behavior for file URLs.
-     @param type MIME type for the file.
-     @param request WebResourceRequest to be used to load the item
-     @param frame The frame which will load the file.
-*/
-- (WebFileAction)fileURLPolicyForMIMEType:(NSString *)type
-                               andRequest:(WebResourceRequest *)request
-                                  inFrame:(WebFrame *)frame;
 
 /*!
     @method contentPolicyForResponse:andRequest:inFrame:withContentPolicy:
@@ -130,9 +101,9 @@ typedef enum {
     @param request A WebResourceRequest for the partially loaded content.
     @param frame The frame which is loading the URL.
 */
-- (WebContentAction)contentPolicyForMIMEType:(NSString *)type
-                                    andRequest:(WebResourceRequest *)request
-                                       inFrame:(WebFrame *)frame;
+- (WebPolicyAction)contentPolicyForMIMEType:(NSString *)type
+                                 andRequest:(WebResourceRequest *)request
+                                    inFrame:(WebFrame *)frame;
 
 
 /*!

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list