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

sullivan sullivan at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 06:33:03 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 692eabb00c34aff57d34ccf84b5b5051828aab18
Author: sullivan <sullivan at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Aug 20 21:16:14 2002 +0000

    WebKit:
    
    	WebKit part of fixes for:
    	- 3027491 -- failure loading frame's resource leads to misbehaving panel
    	- 3027494 -- failure loading frame's resource leads to error message in Alex, silence in IE
    	- 3027697 -- alert box for missing file covered by browser window; should be a sheet
    	- 3014123 -- error sheet when iframe has URL with bad path
    
    	Cleaned up the WebPolicy APIs to pass frames and URLs consistently. Also cleaned
    	up _shouldShowURL: (formerly _shouldShowDataSource:) method quite a bit.
    
            * WebView.subproj/WebControllerPolicyHandler.h:
            * WebView.subproj/WebDefaultContextMenuHandler.m:
            (-[WebDefaultContextMenuHandler downloadURL:]):
            * WebView.subproj/WebDefaultPolicyHandler.m:
            (-[WebDefaultPolicyHandler URLPolicyForURL:inFrame:]):
            (-[WebDefaultPolicyHandler fileURLPolicyForMIMEType:inFrame:isDirectory:]):
            (-[WebDefaultPolicyHandler unableToImplementPolicy:error:forURL:inFrame:]):
            * WebView.subproj/WebFrame.m:
            (-[WebFrame setProvisionalDataSource:]):
            * WebView.subproj/WebMainResourceClient.m:
            (-[WebMainResourceClient handleDidReceiveData:data:]):
    	Made various Policy-related methods pass the frame and when necessary the
    	URL instead of the dataSource (or not even that in some broken cases).
    	Collapsed the three unableToImplementXXXPolicy: methods into one.
    
            * WebView.subproj/WebFramePrivate.h: Change _shouldShowDataSource: to
    	_shouldShowURL:
            * WebView.subproj/WebFramePrivate.m:
            (-[WebFrame handleUnimplementablePolicy:errorCode:forURL:]): New helper method.
            (-[WebFrame _shouldShowURL:]): use case statements instead of nested ifs;
    	use handleUnimplementablePolicy: to reduce duplicated code; update for API
    	changes; eliminate non-useful local variables.
    
    WebBrowser:
    
    	WebBrowser part of fixes for:
    	- 3027491 -- failure loading frame's resource leads to misbehaving panel
    	- 3027494 -- failure loading frame's resource leads to error message in Alex, silence in IE
    	- 3027697 -- alert box for missing file covered by browser window; should be a sheet
    	- 3014123 -- error sheet when iframe has URL with bad path
    
            * BrowserDocument.m:
            (-[BrowserDocument _goToURL:withFrameLoadType:fallbackURLs:]): now pass frame
    	to URLPolicyForURL:inFrame:
    
            * BrowserWebController.m:
            (-[BrowserWebController URLPolicyForURL:inFrame:]): add frame parameter to match changed API
            (-[BrowserWebController unableToImplementPolicy:error:forURL:inFrame:]): New method, replaces
    	unableToImplementURLPolicy:error:forURL:, unableToImplementFileURLPolicy:error:forDataSource:,
    	and unableToImplementContentPolicy:error:forDataSource:. Don't display error to user if it's
    	not in the main frame. This matches the behavior of other browsers, and matches what Alexander
    	does when a non-main-frame page fails to load.
    
            (-[BrowserWebController fileURLPolicyForMIMEType:inFrame:isDirectory:]):
            (-[BrowserWebController contentPolicyForMIMEType:URL:inFrame:]):
    	Updated signatures to match WebKit API changes.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1880 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 8d6fdd0..4b499c1 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,37 @@
+2002-08-20  John Sullivan  <sullivan at apple.com>
+
+	WebKit part of fixes for:
+	- 3027491 -- failure loading frame's resource leads to misbehaving panel
+	- 3027494 -- failure loading frame's resource leads to error message in Alex, silence in IE
+	- 3027697 -- alert box for missing file covered by browser window; should be a sheet
+	- 3014123 -- error sheet when iframe has URL with bad path
+
+	Cleaned up the WebPolicy APIs to pass frames and URLs consistently. Also cleaned
+	up _shouldShowURL: (formerly _shouldShowDataSource:) method quite a bit.
+
+        * WebView.subproj/WebControllerPolicyHandler.h:
+        * WebView.subproj/WebDefaultContextMenuHandler.m:
+        (-[WebDefaultContextMenuHandler downloadURL:]):
+        * WebView.subproj/WebDefaultPolicyHandler.m:
+        (-[WebDefaultPolicyHandler URLPolicyForURL:inFrame:]):
+        (-[WebDefaultPolicyHandler fileURLPolicyForMIMEType:inFrame:isDirectory:]):
+        (-[WebDefaultPolicyHandler unableToImplementPolicy:error:forURL:inFrame:]):
+        * WebView.subproj/WebFrame.m:
+        (-[WebFrame setProvisionalDataSource:]):
+        * WebView.subproj/WebMainResourceClient.m:
+        (-[WebMainResourceClient handleDidReceiveData:data:]):
+	Made various Policy-related methods pass the frame and when necessary the
+	URL instead of the dataSource (or not even that in some broken cases).
+	Collapsed the three unableToImplementXXXPolicy: methods into one.
+
+        * WebView.subproj/WebFramePrivate.h: Change _shouldShowDataSource: to
+	_shouldShowURL:
+        * WebView.subproj/WebFramePrivate.m:
+        (-[WebFrame handleUnimplementablePolicy:errorCode:forURL:]): New helper method.
+        (-[WebFrame _shouldShowURL:]): use case statements instead of nested ifs;
+	use handleUnimplementablePolicy: to reduce duplicated code; update for API
+	changes; eliminate non-useful local variables.
+
 2002-08-20  Darin Adler  <darin at apple.com>
 
 	- fixed 3023076 -- Strange font chosen, widths screwed up, when text includes 007F characters
diff --git a/WebKit/ChangeLog-2002-12-03 b/WebKit/ChangeLog-2002-12-03
index 8d6fdd0..4b499c1 100644
--- a/WebKit/ChangeLog-2002-12-03
+++ b/WebKit/ChangeLog-2002-12-03
@@ -1,3 +1,37 @@
+2002-08-20  John Sullivan  <sullivan at apple.com>
+
+	WebKit part of fixes for:
+	- 3027491 -- failure loading frame's resource leads to misbehaving panel
+	- 3027494 -- failure loading frame's resource leads to error message in Alex, silence in IE
+	- 3027697 -- alert box for missing file covered by browser window; should be a sheet
+	- 3014123 -- error sheet when iframe has URL with bad path
+
+	Cleaned up the WebPolicy APIs to pass frames and URLs consistently. Also cleaned
+	up _shouldShowURL: (formerly _shouldShowDataSource:) method quite a bit.
+
+        * WebView.subproj/WebControllerPolicyHandler.h:
+        * WebView.subproj/WebDefaultContextMenuHandler.m:
+        (-[WebDefaultContextMenuHandler downloadURL:]):
+        * WebView.subproj/WebDefaultPolicyHandler.m:
+        (-[WebDefaultPolicyHandler URLPolicyForURL:inFrame:]):
+        (-[WebDefaultPolicyHandler fileURLPolicyForMIMEType:inFrame:isDirectory:]):
+        (-[WebDefaultPolicyHandler unableToImplementPolicy:error:forURL:inFrame:]):
+        * WebView.subproj/WebFrame.m:
+        (-[WebFrame setProvisionalDataSource:]):
+        * WebView.subproj/WebMainResourceClient.m:
+        (-[WebMainResourceClient handleDidReceiveData:data:]):
+	Made various Policy-related methods pass the frame and when necessary the
+	URL instead of the dataSource (or not even that in some broken cases).
+	Collapsed the three unableToImplementXXXPolicy: methods into one.
+
+        * WebView.subproj/WebFramePrivate.h: Change _shouldShowDataSource: to
+	_shouldShowURL:
+        * WebView.subproj/WebFramePrivate.m:
+        (-[WebFrame handleUnimplementablePolicy:errorCode:forURL:]): New helper method.
+        (-[WebFrame _shouldShowURL:]): use case statements instead of nested ifs;
+	use handleUnimplementablePolicy: to reduce duplicated code; update for API
+	changes; eliminate non-useful local variables.
+
 2002-08-20  Darin Adler  <darin at apple.com>
 
 	- fixed 3023076 -- Strange font chosen, widths screwed up, when text includes 007F characters
diff --git a/WebKit/WebView.subproj/WebControllerPolicyDelegate.h b/WebKit/WebView.subproj/WebControllerPolicyDelegate.h
index e9dbd9f..8314f86 100644
--- a/WebKit/WebView.subproj/WebControllerPolicyDelegate.h
+++ b/WebKit/WebView.subproj/WebControllerPolicyDelegate.h
@@ -8,7 +8,7 @@
 #import <Cocoa/Cocoa.h>
 
 @class WebPolicyPrivate;
- at class WebDataSource;
+ at class WebFrame;
 @class WebError;
 
 typedef enum {
@@ -86,31 +86,21 @@ typedef enum {
 // before it is clicked or loaded via a URL bar.  Clients can choose to handle the
 // URL normally, hand the URL off to launch services, or
 // ignore the URL.  The default implementation could return +defaultURLPolicyForURL:.
-- (WebURLPolicy *)URLPolicyForURL: (NSURL *)URL;
+- (WebURLPolicy *)URLPolicyForURL:(NSURL *)URL inFrame:(WebFrame *)frame;
 
 // Sent after locationChangeStarted.
 // Implementations typically call haveContentPolicy:forLocationChangeHandler: on WebController
 // after determining the appropriate policy, perhaps by presenting a non-blocking dialog to the user.
-- (WebContentPolicy *)contentPolicyForMIMEType: (NSString *)type dataSource: (WebDataSource *)dataSource;
+- (WebContentPolicy *)contentPolicyForMIMEType: (NSString *)type URL:(NSURL *)URL inFrame:(WebFrame *)frame;
 
 // 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.
-- (WebFileURLPolicy *)fileURLPolicyForMIMEType: (NSString *)type dataSource: (WebDataSource *)dataSource isDirectory: (BOOL)isDirectory;
+- (WebFileURLPolicy *)fileURLPolicyForMIMEType: (NSString *)type inFrame:(WebFrame *)frame isDirectory: (BOOL)isDirectory;
 
 - (WebClickPolicy *)clickPolicyForElement: (NSDictionary *)elementInformation button: (NSEventType)eventType modifierMask: (unsigned int)eventMask;
 
-// We may have different errors that cause the the policy to be un-implementable, i.e.
-// launch services failure, etc.
-- (void)unableToImplementURLPolicy: (WebPolicy *)policy error: (WebError *)error forURL: (NSURL *)URL;
-
-// Called when a WebFileURLPolicy could not be completed. This is usually caused by files not
-// existing or not readable.
-- (void)unableToImplementFileURLPolicy: (WebPolicy *)policy error: (WebError *)error forDataSource: (WebDataSource *)dataSource;
-
-
-// Sent when errors are encountered with an un-implementable policy, i.e.
-// file i/o failure, launch services failure, type mismatches, etc.
-- (void)unableToImplementContentPolicy: (WebPolicy *)policy error: (WebError *)error forDataSource: (WebDataSource *)dataSource;
+// Called when a WebPolicy could not be implemented. It is up to the client to display appropriate feedback.
+- (void)unableToImplementPolicy:(WebPolicy *)policy error:(WebError *)error forURL:(NSURL *)URL inFrame:(WebFrame *)frame;
 
 // Called when a plug-in for a certain mime type is not installed
 - (void)pluginNotFoundForMIMEType:(NSString *)mime pluginPageURL:(NSURL *)URL;
diff --git a/WebKit/WebView.subproj/WebControllerPolicyHandler.h b/WebKit/WebView.subproj/WebControllerPolicyHandler.h
index e9dbd9f..8314f86 100644
--- a/WebKit/WebView.subproj/WebControllerPolicyHandler.h
+++ b/WebKit/WebView.subproj/WebControllerPolicyHandler.h
@@ -8,7 +8,7 @@
 #import <Cocoa/Cocoa.h>
 
 @class WebPolicyPrivate;
- at class WebDataSource;
+ at class WebFrame;
 @class WebError;
 
 typedef enum {
@@ -86,31 +86,21 @@ typedef enum {
 // before it is clicked or loaded via a URL bar.  Clients can choose to handle the
 // URL normally, hand the URL off to launch services, or
 // ignore the URL.  The default implementation could return +defaultURLPolicyForURL:.
-- (WebURLPolicy *)URLPolicyForURL: (NSURL *)URL;
+- (WebURLPolicy *)URLPolicyForURL:(NSURL *)URL inFrame:(WebFrame *)frame;
 
 // Sent after locationChangeStarted.
 // Implementations typically call haveContentPolicy:forLocationChangeHandler: on WebController
 // after determining the appropriate policy, perhaps by presenting a non-blocking dialog to the user.
-- (WebContentPolicy *)contentPolicyForMIMEType: (NSString *)type dataSource: (WebDataSource *)dataSource;
+- (WebContentPolicy *)contentPolicyForMIMEType: (NSString *)type URL:(NSURL *)URL inFrame:(WebFrame *)frame;
 
 // 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.
-- (WebFileURLPolicy *)fileURLPolicyForMIMEType: (NSString *)type dataSource: (WebDataSource *)dataSource isDirectory: (BOOL)isDirectory;
+- (WebFileURLPolicy *)fileURLPolicyForMIMEType: (NSString *)type inFrame:(WebFrame *)frame isDirectory: (BOOL)isDirectory;
 
 - (WebClickPolicy *)clickPolicyForElement: (NSDictionary *)elementInformation button: (NSEventType)eventType modifierMask: (unsigned int)eventMask;
 
-// We may have different errors that cause the the policy to be un-implementable, i.e.
-// launch services failure, etc.
-- (void)unableToImplementURLPolicy: (WebPolicy *)policy error: (WebError *)error forURL: (NSURL *)URL;
-
-// Called when a WebFileURLPolicy could not be completed. This is usually caused by files not
-// existing or not readable.
-- (void)unableToImplementFileURLPolicy: (WebPolicy *)policy error: (WebError *)error forDataSource: (WebDataSource *)dataSource;
-
-
-// Sent when errors are encountered with an un-implementable policy, i.e.
-// file i/o failure, launch services failure, type mismatches, etc.
-- (void)unableToImplementContentPolicy: (WebPolicy *)policy error: (WebError *)error forDataSource: (WebDataSource *)dataSource;
+// Called when a WebPolicy could not be implemented. It is up to the client to display appropriate feedback.
+- (void)unableToImplementPolicy:(WebPolicy *)policy error:(WebError *)error forURL:(NSURL *)URL inFrame:(WebFrame *)frame;
 
 // Called when a plug-in for a certain mime type is not installed
 - (void)pluginNotFoundForMIMEType:(NSString *)mime pluginPageURL:(NSURL *)URL;
diff --git a/WebKit/WebView.subproj/WebDefaultContextMenuDelegate.m b/WebKit/WebView.subproj/WebDefaultContextMenuDelegate.m
index 0436f58..a34b8a9 100644
--- a/WebKit/WebView.subproj/WebDefaultContextMenuDelegate.m
+++ b/WebKit/WebView.subproj/WebDefaultContextMenuDelegate.m
@@ -101,10 +101,7 @@
 {
     WebFrame *webFrame = [element objectForKey:WebContextFrame];
     WebController *controller = [webFrame controller];
-    WebDataSource *dataSource = [[WebDataSource alloc] initWithURL:URL];
-
-    // FIXME: This is a hack
-    WebContentPolicy *contentPolicy = [[controller policyHandler] contentPolicyForMIMEType:@"application/octet-stream" dataSource:dataSource];
+    WebContentPolicy *contentPolicy = [[controller policyHandler] contentPolicyForMIMEType:@"application/octet-stream" URL:URL inFrame:webFrame];
     [controller _downloadURL:URL toPath:[contentPolicy path]];
 }
 
diff --git a/WebKit/WebView.subproj/WebDefaultContextMenuHandler.m b/WebKit/WebView.subproj/WebDefaultContextMenuHandler.m
index 0436f58..a34b8a9 100644
--- a/WebKit/WebView.subproj/WebDefaultContextMenuHandler.m
+++ b/WebKit/WebView.subproj/WebDefaultContextMenuHandler.m
@@ -101,10 +101,7 @@
 {
     WebFrame *webFrame = [element objectForKey:WebContextFrame];
     WebController *controller = [webFrame controller];
-    WebDataSource *dataSource = [[WebDataSource alloc] initWithURL:URL];
-
-    // FIXME: This is a hack
-    WebContentPolicy *contentPolicy = [[controller policyHandler] contentPolicyForMIMEType:@"application/octet-stream" dataSource:dataSource];
+    WebContentPolicy *contentPolicy = [[controller policyHandler] contentPolicyForMIMEType:@"application/octet-stream" URL:URL inFrame:webFrame];
     [controller _downloadURL:URL toPath:[contentPolicy path]];
 }
 
diff --git a/WebKit/WebView.subproj/WebDefaultPolicyDelegate.m b/WebKit/WebView.subproj/WebDefaultPolicyDelegate.m
index 6ac6bcb..2dcf6cc 100644
--- a/WebKit/WebView.subproj/WebDefaultPolicyDelegate.m
+++ b/WebKit/WebView.subproj/WebDefaultPolicyDelegate.m
@@ -18,12 +18,12 @@
     return self;
 }
 
-- (WebURLPolicy *)URLPolicyForURL: (NSURL *)URL
+- (WebURLPolicy *)URLPolicyForURL:(NSURL *)URL inFrame:(WebFrame *)frame
 {
-    return [WebController defaultURLPolicyForURL: URL];
+    return [WebController defaultURLPolicyForURL:URL];
 }
 
-- (WebFileURLPolicy *)fileURLPolicyForMIMEType: (NSString *)type dataSource: (WebDataSource *)dataSource isDirectory:(BOOL)isDirectory
+- (WebFileURLPolicy *)fileURLPolicyForMIMEType:(NSString *)type inFrame:(WebFrame *)frame isDirectory:(BOOL)isDirectory
 {
     if(isDirectory)
         return [WebFileURLPolicy webPolicyWithFileAction:WebFileURLPolicyIgnore];
@@ -32,12 +32,13 @@
     return [WebFileURLPolicy webPolicyWithFileAction:WebFileURLPolicyIgnore];;
 }
 
-- (void)unableToImplementFileURLPolicy: (WebPolicy *)policy error: (WebError *)error forDataSource: (WebDataSource *)dataSource
+- (void)unableToImplementPolicy:(WebPolicy *)policy error:(WebError *)error forURL:(NSURL *)URL inFrame:(WebFrame *)frame
 {
-    NSLog (@"unableToImplementFileURLPolicy:forDataSource: - error %@\n", error);
+    NSLog (@"called unableToImplementPolicy:%derror:%@:inFrame:%@", policy, error, frame);
 }
 
-- (WebContentPolicy *)contentPolicyForMIMEType: (NSString *)type dataSource: (WebDataSource *)dataSource;
+
+- (WebContentPolicy *)contentPolicyForMIMEType: (NSString *)type URL:(NSURL *)URL inFrame:(WebFrame *)frame;
 {
     if([WebController canShowMIMEType:type]){
         return [WebContentPolicy webPolicyWithContentAction: WebContentPolicyShow andPath:nil];
@@ -47,17 +48,6 @@
     }
 }
 
-- (void)unableToImplementURLPolicy: (WebPolicy *)policy error: (WebError *)error forURL: (NSURL *)URL
-{
-    NSLog (@"unableToImplementURLPolicyForURL:error: - URL %@, error %@\n", URL, error);
-}
-
-
-- (void)unableToImplementContentPolicy: (WebPolicy *)policy error: (WebError *)error forDataSource: (WebDataSource *)dataSource;
-{
-    NSLog (@"unableToImplementContentPolicy:forDataSource: - error %@\n", error);
-}
-
 - (void)pluginNotFoundForMIMEType:(NSString *)mime pluginPageURL:(NSURL *)URL
 {
     NSLog (@"pluginNotFoundForMIMEType:pluginPageURL: - MIME %@, URL \n", mime, URL);
diff --git a/WebKit/WebView.subproj/WebDefaultPolicyHandler.m b/WebKit/WebView.subproj/WebDefaultPolicyHandler.m
index 6ac6bcb..2dcf6cc 100644
--- a/WebKit/WebView.subproj/WebDefaultPolicyHandler.m
+++ b/WebKit/WebView.subproj/WebDefaultPolicyHandler.m
@@ -18,12 +18,12 @@
     return self;
 }
 
-- (WebURLPolicy *)URLPolicyForURL: (NSURL *)URL
+- (WebURLPolicy *)URLPolicyForURL:(NSURL *)URL inFrame:(WebFrame *)frame
 {
-    return [WebController defaultURLPolicyForURL: URL];
+    return [WebController defaultURLPolicyForURL:URL];
 }
 
-- (WebFileURLPolicy *)fileURLPolicyForMIMEType: (NSString *)type dataSource: (WebDataSource *)dataSource isDirectory:(BOOL)isDirectory
+- (WebFileURLPolicy *)fileURLPolicyForMIMEType:(NSString *)type inFrame:(WebFrame *)frame isDirectory:(BOOL)isDirectory
 {
     if(isDirectory)
         return [WebFileURLPolicy webPolicyWithFileAction:WebFileURLPolicyIgnore];
@@ -32,12 +32,13 @@
     return [WebFileURLPolicy webPolicyWithFileAction:WebFileURLPolicyIgnore];;
 }
 
-- (void)unableToImplementFileURLPolicy: (WebPolicy *)policy error: (WebError *)error forDataSource: (WebDataSource *)dataSource
+- (void)unableToImplementPolicy:(WebPolicy *)policy error:(WebError *)error forURL:(NSURL *)URL inFrame:(WebFrame *)frame
 {
-    NSLog (@"unableToImplementFileURLPolicy:forDataSource: - error %@\n", error);
+    NSLog (@"called unableToImplementPolicy:%derror:%@:inFrame:%@", policy, error, frame);
 }
 
-- (WebContentPolicy *)contentPolicyForMIMEType: (NSString *)type dataSource: (WebDataSource *)dataSource;
+
+- (WebContentPolicy *)contentPolicyForMIMEType: (NSString *)type URL:(NSURL *)URL inFrame:(WebFrame *)frame;
 {
     if([WebController canShowMIMEType:type]){
         return [WebContentPolicy webPolicyWithContentAction: WebContentPolicyShow andPath:nil];
@@ -47,17 +48,6 @@
     }
 }
 
-- (void)unableToImplementURLPolicy: (WebPolicy *)policy error: (WebError *)error forURL: (NSURL *)URL
-{
-    NSLog (@"unableToImplementURLPolicyForURL:error: - URL %@, error %@\n", URL, error);
-}
-
-
-- (void)unableToImplementContentPolicy: (WebPolicy *)policy error: (WebError *)error forDataSource: (WebDataSource *)dataSource;
-{
-    NSLog (@"unableToImplementContentPolicy:forDataSource: - error %@\n", error);
-}
-
 - (void)pluginNotFoundForMIMEType:(NSString *)mime pluginPageURL:(NSURL *)URL
 {
     NSLog (@"pluginNotFoundForMIMEType:pluginPageURL: - MIME %@, URL \n", mime, URL);
diff --git a/WebKit/WebView.subproj/WebFrame.m b/WebKit/WebView.subproj/WebFrame.m
index 288bc47..2d352b0 100644
--- a/WebKit/WebView.subproj/WebFrame.m
+++ b/WebKit/WebView.subproj/WebFrame.m
@@ -145,9 +145,9 @@
 
     [self _setLoadType: WebFrameLoadTypeStandard];
 
-    // _shouldShowDataSource asks the client for the URL policies and reports errors if there are any
+    // _shouldShowURL asks the client for the URL policies and reports errors if there are any
     // returns YES if we should show the data source
-    if([self _shouldShowDataSource:newDataSource]){
+    if([self _shouldShowURL:[newDataSource URL]]){
         
         locationChangeHandler = [[self controller] locationChangeHandler];
         
diff --git a/WebKit/WebView.subproj/WebFramePrivate.h b/WebKit/WebView.subproj/WebFramePrivate.h
index c16d933..987d923 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.h
+++ b/WebKit/WebView.subproj/WebFramePrivate.h
@@ -87,7 +87,7 @@ typedef enum {
 - (void)_checkLoadComplete;
 - (void)_timedLayout: userInfo;
 - (WebBridge *)_bridge;
-- (BOOL)_shouldShowDataSource:(WebDataSource *)dataSource;
+- (BOOL)_shouldShowURL:(NSURL *)URL;
 - (void)_setProvisionalDataSource:(WebDataSource *)d;
 - (void)_setLoadType: (WebFrameLoadType)loadType;
 - (WebFrameLoadType)_loadType;
diff --git a/WebKit/WebView.subproj/WebFramePrivate.m b/WebKit/WebView.subproj/WebFramePrivate.m
index df68382..f64d711 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.m
+++ b/WebKit/WebView.subproj/WebFramePrivate.m
@@ -543,103 +543,92 @@ static const char * const stateNames[] = {
     return _private->bridge;
 }
 
-- (BOOL)_shouldShowDataSource:(WebDataSource *)dataSource
+- (void)handleUnimplementablePolicy:(WebPolicy *)policy errorCode:(int)code forURL:(NSURL *)URL
+{
+    WebError *error = [WebError errorWithCode:code
+                                     inDomain:WebErrorDomainWebKit
+                                   failingURL:[URL absoluteString]];
+    [[[self controller] policyHandler] unableToImplementPolicy:policy error:error forURL:URL inFrame:self];    
+}
+
+- (BOOL)_shouldShowURL:(NSURL *)URL
 {
     id <WebControllerPolicyHandler> policyHandler = [[self controller] policyHandler];
-    NSFileManager *fileManager = [NSFileManager defaultManager];
-    NSWorkspace *workspace = [NSWorkspace sharedWorkspace];
-    NSURL *URL = [dataSource originalURL];
-    WebFileURLPolicy *fileURLPolicy;
-    NSString *path = [URL path], *URLString = [URL absoluteString];
-    BOOL isDirectory, fileExists;
-    WebError *error;
-    
-    WebURLPolicy *URLPolicy = [policyHandler URLPolicyForURL:URL];
-    
-    if([URLPolicy policyAction] == WebURLPolicyUseContentPolicy){
-                    
-        if([URL isFileURL]){
-        
-            fileExists = [fileManager fileExistsAtPath:path isDirectory:&isDirectory];
-            
-            NSString *type = [WebController _MIMETypeForFile: path];
-                
-            if(isDirectory){
-                fileURLPolicy = [policyHandler fileURLPolicyForMIMEType: nil dataSource: dataSource isDirectory:YES];
-            }else{
-                fileURLPolicy = [policyHandler fileURLPolicyForMIMEType: type dataSource: dataSource isDirectory:NO];
-            }
-            
-            if([fileURLPolicy policyAction] == WebFileURLPolicyIgnore)
-                return NO;
-            
-            if(!fileExists){
-                error = [WebError errorWithCode:WebErrorFileDoesNotExist inDomain:WebErrorDomainWebKit failingURL:URLString];
-                [policyHandler unableToImplementFileURLPolicy: fileURLPolicy error: error forDataSource: dataSource];
-                return NO;
-            }
-            
-            if(![fileManager isReadableFileAtPath:path]){
-                error = [WebError errorWithCode:WebErrorFileNotReadable  inDomain:WebErrorDomainWebKit failingURL:URLString];
-                [policyHandler unableToImplementFileURLPolicy: fileURLPolicy error: error forDataSource: dataSource];
-                return NO;
+    WebURLPolicy *URLPolicy = [policyHandler URLPolicyForURL:URL inFrame:self];
+
+    switch ([URLPolicy policyAction]) {
+        case WebURLPolicyIgnore:
+            return NO;
+
+        case WebURLPolicyOpenExternally:
+            if(![[NSWorkspace sharedWorkspace] openURL:URL]){
+                [self handleUnimplementablePolicy:URLPolicy errorCode:WebErrorCouldNotFindApplicationForURL forURL:URL];
             }
-            
-            if([fileURLPolicy policyAction] == WebFileURLPolicyUseContentPolicy){
-                if(isDirectory){
-                    error = [WebError errorWithCode:WebErrorCannotShowDirectory  inDomain:WebErrorDomainWebKit failingURL:URLString];
-                    [policyHandler unableToImplementFileURLPolicy: fileURLPolicy error: error forDataSource: dataSource];
+            return NO;
 
+        case WebURLPolicyUseContentPolicy:
+            // handle non-file case first because it's short and sweet
+            if (![URL isFileURL]) {
+                if (![WebResourceHandle canInitWithURL:URL]) {
+                    [self handleUnimplementablePolicy:URLPolicy errorCode:WebErrorCannotShowURL forURL:URL];
                     return NO;
                 }
-                else if(![WebController canShowMIMEType: type]){
-                    error = [WebError errorWithCode:WebErrorCannotShowMIMEType  inDomain:WebErrorDomainWebKit failingURL:URLString];
-                    [policyHandler unableToImplementFileURLPolicy: fileURLPolicy error: error forDataSource: dataSource];
+                return YES;
+            } else {
+                // file URL
+                NSFileManager *fileManager = [NSFileManager defaultManager];
+                NSString *path = [URL path];
+                BOOL isDirectory;
+                BOOL fileExists = [fileManager fileExistsAtPath:path isDirectory:&isDirectory];
+                NSString *type = [WebController _MIMETypeForFile: path];
+                WebFileURLPolicy *fileURLPolicy = [policyHandler fileURLPolicyForMIMEType:type inFrame:self isDirectory:YES];
+
+                if([fileURLPolicy policyAction] == WebFileURLPolicyIgnore)
+                    return NO;
+
+                if(!fileExists){
+                    [self handleUnimplementablePolicy:fileURLPolicy errorCode:WebErrorFileDoesNotExist forURL:URL];
                     return NO;
-                }else{
-                    // File exists, its readable, we can show it
-                    return YES;
                 }
-            }else if([fileURLPolicy policyAction] == WebFileURLPolicyOpenExternally){
-                if(![workspace openFile:path]){
-                    error = [WebError errorWithCode:WebErrorCouldNotFindApplicationForFile  inDomain:WebErrorDomainWebKit failingURL:URLString];
-                    [policyHandler unableToImplementFileURLPolicy: fileURLPolicy error: error forDataSource: dataSource];
+
+                if(![fileManager isReadableFileAtPath:path]){
+                    [self handleUnimplementablePolicy:fileURLPolicy errorCode:WebErrorFileNotReadable forURL:URL];
+                    return NO;
+                }
+
+                switch ([fileURLPolicy policyAction]) {
+                    case WebFileURLPolicyUseContentPolicy:
+                        if (isDirectory) {
+                            [self handleUnimplementablePolicy:fileURLPolicy errorCode:WebErrorCannotShowDirectory forURL:URL];
+                            return NO;
+                        } else if (![WebController canShowMIMEType: type]) {
+                            [self handleUnimplementablePolicy:fileURLPolicy errorCode:WebErrorCannotShowMIMEType forURL:URL];
+                            return NO;
+                        }
+                        return YES;
+                        
+                    case WebFileURLPolicyOpenExternally:
+                        if(![[NSWorkspace sharedWorkspace] openFile:path]){
+                            [self handleUnimplementablePolicy:fileURLPolicy errorCode:WebErrorCouldNotFindApplicationForFile forURL:URL];
+                        }
+                        return NO;
+
+                    case WebFileURLPolicyRevealInFinder:
+                        if(![[NSWorkspace sharedWorkspace] selectFile:path inFileViewerRootedAtPath:@""]){
+                            [self handleUnimplementablePolicy:fileURLPolicy errorCode:WebErrorFinderCouldNotOpenDirectory forURL:URL];
+                        }
+                        return NO;
+
+                    default:
+                        [NSException raise:NSInvalidArgumentException format:
+                @"fileURLPolicyForMIMEType:inFrame:isDirectory: returned WebFileURLPolicy with invalid action %d", [fileURLPolicy policyAction]];
+                        return NO;
                 }
-                return NO;
-            }else if([fileURLPolicy policyAction] == WebFileURLPolicyRevealInFinder){
-                if(![workspace selectFile:path inFileViewerRootedAtPath:@""]){
-                        error = [WebError errorWithCode:WebErrorFinderCouldNotOpenDirectory  inDomain:WebErrorDomainWebKit failingURL:URLString];
-                        [policyHandler unableToImplementFileURLPolicy: fileURLPolicy error: error forDataSource: dataSource];
-                    }
-                return NO;
-            }else{
-                [NSException raise:NSInvalidArgumentException format:
-                    @"fileURLPolicyForMIMEType:dataSource:isDirectory: returned an invalid WebFileURLPolicy"];
-                return NO;
-            }
-        }else{
-            if(![WebResourceHandle canInitWithURL:URL]){
-            	error = [WebError errorWithCode:WebErrorCannotShowURL inDomain:WebErrorDomainWebKit failingURL:URLString];
-                [policyHandler unableToImplementURLPolicy: URLPolicy error: error forURL: URL];
-                return NO;
             }
-            // we can handle this URL
-            return YES;
-        }
-    }
-    else if([URLPolicy policyAction] == WebURLPolicyOpenExternally){
-        if(![workspace openURL:URL]){
-            error = [WebError errorWithCode:WebErrorCouldNotFindApplicationForURL inDomain:WebErrorDomainWebKit failingURL:URLString];
-            [policyHandler unableToImplementURLPolicy: URLPolicy error: error forURL: URL];
-        }
-        return NO;
-    }
-    else if([URLPolicy policyAction] == WebURLPolicyIgnore){
-        return NO;
-    }
-    else{
-        [NSException raise:NSInvalidArgumentException format:@"URLPolicyForURL: returned an invalid WebURLPolicy"];
-        return NO;
+
+        default:
+            [NSException raise:NSInvalidArgumentException format:@"URLPolicyForURL: returned an invalid WebURLPolicy"];
+            return NO;
     }
 }
 
diff --git a/WebKit/WebView.subproj/WebMainResourceClient.m b/WebKit/WebView.subproj/WebMainResourceClient.m
index c1b5ef5..be0d3e3 100644
--- a/WebKit/WebView.subproj/WebMainResourceClient.m
+++ b/WebKit/WebView.subproj/WebMainResourceClient.m
@@ -194,10 +194,10 @@
         downloadProgressHandler = [[[dataSource controller] downloadProgressHandler] retain];
 
         if(![dataSource contentPolicy]){
-            contentPolicy = [[controller policyHandler] contentPolicyForMIMEType: contentType dataSource: dataSource];
+            contentPolicy = [[controller policyHandler] contentPolicyForMIMEType: contentType URL:currentURL inFrame:frame];
             [dataSource _setContentPolicy:contentPolicy];
         }
-        policyAction = [[dataSource contentPolicy] policyAction];
+        policyAction = [contentPolicy policyAction];
         
         WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD, "main content type: %s", DEBUG_OBJECT(contentType));
     }
@@ -222,7 +222,7 @@
         break;
     default:
         [NSException raise:NSInvalidArgumentException format:
-             @"contentPolicyForMIMEType: dataSource: returned an invalid content policy."];
+@"contentPolicyForMIMEType:URL:inFrame: returned an invalid content policy."];
     }
 
     [self receivedProgressWithHandle:handle complete:NO];
diff --git a/WebKit/WebView.subproj/WebMainResourceLoader.m b/WebKit/WebView.subproj/WebMainResourceLoader.m
index c1b5ef5..be0d3e3 100644
--- a/WebKit/WebView.subproj/WebMainResourceLoader.m
+++ b/WebKit/WebView.subproj/WebMainResourceLoader.m
@@ -194,10 +194,10 @@
         downloadProgressHandler = [[[dataSource controller] downloadProgressHandler] retain];
 
         if(![dataSource contentPolicy]){
-            contentPolicy = [[controller policyHandler] contentPolicyForMIMEType: contentType dataSource: dataSource];
+            contentPolicy = [[controller policyHandler] contentPolicyForMIMEType: contentType URL:currentURL inFrame:frame];
             [dataSource _setContentPolicy:contentPolicy];
         }
-        policyAction = [[dataSource contentPolicy] policyAction];
+        policyAction = [contentPolicy policyAction];
         
         WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD, "main content type: %s", DEBUG_OBJECT(contentType));
     }
@@ -222,7 +222,7 @@
         break;
     default:
         [NSException raise:NSInvalidArgumentException format:
-             @"contentPolicyForMIMEType: dataSource: returned an invalid content policy."];
+@"contentPolicyForMIMEType:URL:inFrame: returned an invalid content policy."];
     }
 
     [self receivedProgressWithHandle:handle complete:NO];
diff --git a/WebKit/WebView.subproj/WebPolicyDelegate.h b/WebKit/WebView.subproj/WebPolicyDelegate.h
index e9dbd9f..8314f86 100644
--- a/WebKit/WebView.subproj/WebPolicyDelegate.h
+++ b/WebKit/WebView.subproj/WebPolicyDelegate.h
@@ -8,7 +8,7 @@
 #import <Cocoa/Cocoa.h>
 
 @class WebPolicyPrivate;
- at class WebDataSource;
+ at class WebFrame;
 @class WebError;
 
 typedef enum {
@@ -86,31 +86,21 @@ typedef enum {
 // before it is clicked or loaded via a URL bar.  Clients can choose to handle the
 // URL normally, hand the URL off to launch services, or
 // ignore the URL.  The default implementation could return +defaultURLPolicyForURL:.
-- (WebURLPolicy *)URLPolicyForURL: (NSURL *)URL;
+- (WebURLPolicy *)URLPolicyForURL:(NSURL *)URL inFrame:(WebFrame *)frame;
 
 // Sent after locationChangeStarted.
 // Implementations typically call haveContentPolicy:forLocationChangeHandler: on WebController
 // after determining the appropriate policy, perhaps by presenting a non-blocking dialog to the user.
-- (WebContentPolicy *)contentPolicyForMIMEType: (NSString *)type dataSource: (WebDataSource *)dataSource;
+- (WebContentPolicy *)contentPolicyForMIMEType: (NSString *)type URL:(NSURL *)URL inFrame:(WebFrame *)frame;
 
 // 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.
-- (WebFileURLPolicy *)fileURLPolicyForMIMEType: (NSString *)type dataSource: (WebDataSource *)dataSource isDirectory: (BOOL)isDirectory;
+- (WebFileURLPolicy *)fileURLPolicyForMIMEType: (NSString *)type inFrame:(WebFrame *)frame isDirectory: (BOOL)isDirectory;
 
 - (WebClickPolicy *)clickPolicyForElement: (NSDictionary *)elementInformation button: (NSEventType)eventType modifierMask: (unsigned int)eventMask;
 
-// We may have different errors that cause the the policy to be un-implementable, i.e.
-// launch services failure, etc.
-- (void)unableToImplementURLPolicy: (WebPolicy *)policy error: (WebError *)error forURL: (NSURL *)URL;
-
-// Called when a WebFileURLPolicy could not be completed. This is usually caused by files not
-// existing or not readable.
-- (void)unableToImplementFileURLPolicy: (WebPolicy *)policy error: (WebError *)error forDataSource: (WebDataSource *)dataSource;
-
-
-// Sent when errors are encountered with an un-implementable policy, i.e.
-// file i/o failure, launch services failure, type mismatches, etc.
-- (void)unableToImplementContentPolicy: (WebPolicy *)policy error: (WebError *)error forDataSource: (WebDataSource *)dataSource;
+// Called when a WebPolicy could not be implemented. It is up to the client to display appropriate feedback.
+- (void)unableToImplementPolicy:(WebPolicy *)policy error:(WebError *)error forURL:(NSURL *)URL inFrame:(WebFrame *)frame;
 
 // Called when a plug-in for a certain mime type is not installed
 - (void)pluginNotFoundForMIMEType:(NSString *)mime pluginPageURL:(NSURL *)URL;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list