[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:23:00 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 4e761f27ea7b5ff2197796aedcaa3cdd9053eee7
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Jul 3 00:52:08 2002 +0000
WebFoundation:
* CacheLoader.subproj/IFURLCacheLoaderConstants.h: removed IFErrorCode enum
* Misc.subproj/IFError.h:
* Misc.subproj/IFError.m:
(classInitialize): removed WebKit error descriptions
(-[IFError description]): no changes
(+[IFError addErrorsFromDictionary:]): added, allows WebKit to register errors
WebKit:
- Moved all policy methods to IFWebControllerPolicyHandler.h
- Moved all file URL error checking to WebKit
- Implemented file URL policy methods
- Renamed IFContentPolicyOpenExternally to IFContentPolicySaveAndOpenExternally
* Misc.subproj/IFWebKitErrors.h: Added.
* WebKit.pbproj/project.pbxproj:
* WebView.subproj/IFLocationChangeHandler.h: removed content policy stuff
* WebView.subproj/IFMainURLHandleClient.mm:
(-[IFMainURLHandleClient IFURLHandleResourceDidFinishLoading:data:]): IFContentPolicySaveAndOpenExternally rename
(-[IFMainURLHandleClient IFURLHandle:resourceDataDidBecomeAvailable:]): call the policy handler for content policy stuff
* WebView.subproj/IFWebController.h:
* WebView.subproj/IFWebController.mm:
(-[IFWebController haveContentPolicy:andPath:forDataSource:]): sends a unableToImplementContentPolicy:
(+[IFWebController canShowFile:]): now calls _MIMETypeForFile
* WebView.subproj/IFWebControllerPolicyHandler.h: Added.
* WebView.subproj/IFWebControllerPrivate.h:
* WebView.subproj/IFWebControllerPrivate.mm:
(-[IFWebController _mainReceivedProgress:forResourceHandle:fromDataSource:complete:]): IFContentPolicySaveAndOpenExternally
WebBrowser:
- Moved all policy methods to IFWebControllerPolicyHandler
- Moved all file URL error checking to WebKit
- Implemented file URL policy methods
- Renamed IFContentPolicyOpenExternally to IFContentPolicySaveAndOpenExternally
* BrowserDocument.m:
(-[BrowserDocument _goToURL:withFrameLoadType:fallbackURLs:]): load frame only if setProvisionalDataSource returns YES
* BrowserWindow.h:
* BrowserWindow.m:
(-[BrowserWindow goToToolbarLocation:]): removed file URL error checking
* DownloadMonitor.m:
(-[DownloadMonitor monitorDownload:withProgress:error:dataSource:complete:]): minor clean-up
* LocationChangeHandler.m: removed content policy methods
* WebController.m:
(-[BrowserWebController receivedProgress:forResourceHandle:fromDataSource:complete:]): IFContentPolicySaveAndOpenExternally
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1497 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index de4f71a..4e74ac1 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,37 @@
+2002-07-02 Chris Blumenberg <cblu at apple.com>
+
+ - Moved all policy methods to IFWebControllerPolicyHandler.h
+ - Moved all file URL error checking to WebKit
+ - Implemented file URL policy methods
+ - Renamed IFContentPolicyOpenExternally to IFContentPolicySaveAndOpenExternally
+
+ * Misc.subproj/IFWebKitErrors.h: Added.
+ * WebKit.pbproj/project.pbxproj:
+ * WebView.subproj/IFLocationChangeHandler.h: removed content policy stuff
+ * WebView.subproj/IFMainURLHandleClient.mm:
+ (-[IFMainURLHandleClient IFURLHandleResourceDidFinishLoading:data:]): IFContentPolicySaveAndOpenExternally rename
+ (-[IFMainURLHandleClient IFURLHandle:resourceDataDidBecomeAvailable:]): call the policy handler for content policy stuff
+ * WebView.subproj/IFWebController.h:
+ * WebView.subproj/IFWebController.mm:
+ (-[IFWebController haveContentPolicy:andPath:forDataSource:]): sends a unableToImplementContentPolicy:
+ (+[IFWebController canShowFile:]): now calls _MIMETypeForFile
+ * WebView.subproj/IFWebControllerPolicyHandler.h: Added.
+ * WebView.subproj/IFWebControllerPrivate.h:
+ * WebView.subproj/IFWebControllerPrivate.mm:
+ (-[IFWebController _mainReceivedProgress:forResourceHandle:fromDataSource:complete:]): IFContentPolicySaveAndOpenExternally
+rename
+ (-[IFWebController _didStopLoading:]): no changes
+ (+[IFWebController _MIMETypeForFile:]): added
+ * WebView.subproj/IFWebDataSource.h:
+ * WebView.subproj/IFWebFrame.mm:
+ (-[IFWebFrame setProvisionalDataSource:]): calls _shouldShowDataSource
+ * WebView.subproj/IFWebFramePrivate.h:
+ * WebView.subproj/IFWebFramePrivate.mm:
+ (-[IFWebFrame _bridgeFrame]): no changes
+ (-[IFWebFrame _shouldShowDataSource:]): does the error handling
+ * WebView.subproj/IFWebView.mm:
+ (+[IFWebView initialize]): registers WebKit errors
+
2002-07-02 Richard Williamson <rjw at apple.com>
* WebView.subproj/IFRenderNode.mm:
diff --git a/WebKit/ChangeLog-2002-12-03 b/WebKit/ChangeLog-2002-12-03
index de4f71a..4e74ac1 100644
--- a/WebKit/ChangeLog-2002-12-03
+++ b/WebKit/ChangeLog-2002-12-03
@@ -1,3 +1,37 @@
+2002-07-02 Chris Blumenberg <cblu at apple.com>
+
+ - Moved all policy methods to IFWebControllerPolicyHandler.h
+ - Moved all file URL error checking to WebKit
+ - Implemented file URL policy methods
+ - Renamed IFContentPolicyOpenExternally to IFContentPolicySaveAndOpenExternally
+
+ * Misc.subproj/IFWebKitErrors.h: Added.
+ * WebKit.pbproj/project.pbxproj:
+ * WebView.subproj/IFLocationChangeHandler.h: removed content policy stuff
+ * WebView.subproj/IFMainURLHandleClient.mm:
+ (-[IFMainURLHandleClient IFURLHandleResourceDidFinishLoading:data:]): IFContentPolicySaveAndOpenExternally rename
+ (-[IFMainURLHandleClient IFURLHandle:resourceDataDidBecomeAvailable:]): call the policy handler for content policy stuff
+ * WebView.subproj/IFWebController.h:
+ * WebView.subproj/IFWebController.mm:
+ (-[IFWebController haveContentPolicy:andPath:forDataSource:]): sends a unableToImplementContentPolicy:
+ (+[IFWebController canShowFile:]): now calls _MIMETypeForFile
+ * WebView.subproj/IFWebControllerPolicyHandler.h: Added.
+ * WebView.subproj/IFWebControllerPrivate.h:
+ * WebView.subproj/IFWebControllerPrivate.mm:
+ (-[IFWebController _mainReceivedProgress:forResourceHandle:fromDataSource:complete:]): IFContentPolicySaveAndOpenExternally
+rename
+ (-[IFWebController _didStopLoading:]): no changes
+ (+[IFWebController _MIMETypeForFile:]): added
+ * WebView.subproj/IFWebDataSource.h:
+ * WebView.subproj/IFWebFrame.mm:
+ (-[IFWebFrame setProvisionalDataSource:]): calls _shouldShowDataSource
+ * WebView.subproj/IFWebFramePrivate.h:
+ * WebView.subproj/IFWebFramePrivate.mm:
+ (-[IFWebFrame _bridgeFrame]): no changes
+ (-[IFWebFrame _shouldShowDataSource:]): does the error handling
+ * WebView.subproj/IFWebView.mm:
+ (+[IFWebView initialize]): registers WebKit errors
+
2002-07-02 Richard Williamson <rjw at apple.com>
* WebView.subproj/IFRenderNode.mm:
diff --git a/WebKit/Misc.subproj/IFWebKitErrors.h b/WebKit/Misc.subproj/IFWebKitErrors.h
new file mode 100644
index 0000000..34af2bd
--- /dev/null
+++ b/WebKit/Misc.subproj/IFWebKitErrors.h
@@ -0,0 +1,34 @@
+/* IFWebKitErrors.h
+ Copyright 2002, Apple, Inc. All rights reserved.
+*/
+
+// WebFoundation error codes < 10000
+// WebKit error codes >= 10000
+
+typedef enum {
+ IFErrorCodeNoError = 0,
+ IFErrorCodeCantShowMIMEType = 10000,
+ IFErrorCodeFileDoesntExist = 10001,
+ IFErrorCodeCouldntFindApplicationForFile = 10002,
+ IFErrorCodeCouldntFindApplicationForURL = 10003,
+ IFErrorCodeFileNotReadable = 10004,
+ IFErrorCodeFinderCouldntOpenDirectory = 10005,
+ IFErrorCodeCantShowDirectory = 10006,
+ IFErrorCodeCantShowURL = 10007,
+} IFErrorCode;
+
+#define IFErrorDescriptionCantShowMIMEType NSLocalizedStringFromTable (@"Can't show content with specified mime type", @"IFError", @"IFErrorCodeCantShowMIMEType description")
+
+#define IFErrorDescriptionCouldntFindApplicationForFile NSLocalizedStringFromTable (@"Could not find application for specified file", @"IFError", @"IFErrorCodeCouldntFindApplicationForFile description")
+
+#define IFErrorDescriptionCouldntFindApplicationForURL NSLocalizedStringFromTable (@"Could not find application for specified URL", @"IFError", @"IFErrorCodeCouldntFindApplicationForURL description")
+
+#define IFErrorDescriptionFileDoesntExist NSLocalizedStringFromTable (@"Could not find file", @"IFError", @"IFErrorCodeFileDoesntExist description")
+
+#define IFErrorDescriptionFileNotReadable NSLocalizedStringFromTable (@"Could not read file", @"IFError", @"IFErrorCodeFileNotReadable description")
+
+#define IFErrorDescriptionFinderCouldntOpenDirectory NSLocalizedStringFromTable (@"Finder could not open directory", @"IFError", @"IFErrorCodeFinderCouldntOpenDirectory description")
+
+#define IFErrorDescriptionCantShowDirectory NSLocalizedStringFromTable (@"Can't show a file directory", @"IFError", @"IFErrorCodeCantShowDirectory description")
+
+#define IFErrorDescriptionCantShowURL NSLocalizedStringFromTable (@"Can't show the specified URL", @"IFError", @"IFErrorCodeCantShowURL description")
\ No newline at end of file
diff --git a/WebKit/Misc.subproj/WebKitErrors.h b/WebKit/Misc.subproj/WebKitErrors.h
new file mode 100644
index 0000000..34af2bd
--- /dev/null
+++ b/WebKit/Misc.subproj/WebKitErrors.h
@@ -0,0 +1,34 @@
+/* IFWebKitErrors.h
+ Copyright 2002, Apple, Inc. All rights reserved.
+*/
+
+// WebFoundation error codes < 10000
+// WebKit error codes >= 10000
+
+typedef enum {
+ IFErrorCodeNoError = 0,
+ IFErrorCodeCantShowMIMEType = 10000,
+ IFErrorCodeFileDoesntExist = 10001,
+ IFErrorCodeCouldntFindApplicationForFile = 10002,
+ IFErrorCodeCouldntFindApplicationForURL = 10003,
+ IFErrorCodeFileNotReadable = 10004,
+ IFErrorCodeFinderCouldntOpenDirectory = 10005,
+ IFErrorCodeCantShowDirectory = 10006,
+ IFErrorCodeCantShowURL = 10007,
+} IFErrorCode;
+
+#define IFErrorDescriptionCantShowMIMEType NSLocalizedStringFromTable (@"Can't show content with specified mime type", @"IFError", @"IFErrorCodeCantShowMIMEType description")
+
+#define IFErrorDescriptionCouldntFindApplicationForFile NSLocalizedStringFromTable (@"Could not find application for specified file", @"IFError", @"IFErrorCodeCouldntFindApplicationForFile description")
+
+#define IFErrorDescriptionCouldntFindApplicationForURL NSLocalizedStringFromTable (@"Could not find application for specified URL", @"IFError", @"IFErrorCodeCouldntFindApplicationForURL description")
+
+#define IFErrorDescriptionFileDoesntExist NSLocalizedStringFromTable (@"Could not find file", @"IFError", @"IFErrorCodeFileDoesntExist description")
+
+#define IFErrorDescriptionFileNotReadable NSLocalizedStringFromTable (@"Could not read file", @"IFError", @"IFErrorCodeFileNotReadable description")
+
+#define IFErrorDescriptionFinderCouldntOpenDirectory NSLocalizedStringFromTable (@"Finder could not open directory", @"IFError", @"IFErrorCodeFinderCouldntOpenDirectory description")
+
+#define IFErrorDescriptionCantShowDirectory NSLocalizedStringFromTable (@"Can't show a file directory", @"IFError", @"IFErrorCodeCantShowDirectory description")
+
+#define IFErrorDescriptionCantShowURL NSLocalizedStringFromTable (@"Can't show the specified URL", @"IFError", @"IFErrorCodeCantShowURL description")
\ No newline at end of file
diff --git a/WebKit/WebKit.pbproj/project.pbxproj b/WebKit/WebKit.pbproj/project.pbxproj
index c7307f5..ed142ae 100644
--- a/WebKit/WebKit.pbproj/project.pbxproj
+++ b/WebKit/WebKit.pbproj/project.pbxproj
@@ -257,6 +257,8 @@
F5E0E10A02BC45F8018635CA,
F5A7B11B02BC8413018635CA,
F5488CF602CB04EE01FF6274,
+ F5927D4B02D253C401CA2DBB,
+ F5927D4F02D26C5E01CA2DBB,
);
isa = PBXHeadersBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
@@ -421,6 +423,7 @@
F508946A02B71D59018A9CD4,
F59668C802AD2923018635CA,
F59668C902AD2923018635CA,
+ F5927D4E02D26C5E01CA2DBB,
2568C72C0174912D0ECA149E,
25C29825016E29620ECA149E,
F5C283730284676D018635CA,
@@ -1131,6 +1134,7 @@
35081DA902B6D4E40ACA2ACA,
3944606F020F50ED0ECA1767,
39446064020F50ED0ECA1767,
+ F5927D4A02D253C401CA2DBB,
39446065020F50ED0ECA1767,
39446066020F50ED0ECA1767,
39446070020F50ED0ECA1767,
@@ -1572,6 +1576,36 @@
isa = PBXBuildStyle;
name = Mixed;
};
+ F5927D4A02D253C401CA2DBB = {
+ isa = PBXFileReference;
+ name = IFWebControllerPolicyHandler.h;
+ path = WebView.subproj/IFWebControllerPolicyHandler.h;
+ refType = 4;
+ };
+ F5927D4B02D253C401CA2DBB = {
+ fileRef = F5927D4A02D253C401CA2DBB;
+ isa = PBXBuildFile;
+ settings = {
+ ATTRIBUTES = (
+ Public,
+ );
+ };
+ };
+ F5927D4E02D26C5E01CA2DBB = {
+ isa = PBXFileReference;
+ name = IFWebKitErrors.h;
+ path = Misc.subproj/IFWebKitErrors.h;
+ refType = 4;
+ };
+ F5927D4F02D26C5E01CA2DBB = {
+ fileRef = F5927D4E02D26C5E01CA2DBB;
+ isa = PBXBuildFile;
+ settings = {
+ ATTRIBUTES = (
+ Public,
+ );
+ };
+ };
F59668C802AD2923018635CA = {
isa = PBXFileReference;
name = IFStringTruncator.h;
diff --git a/WebKit/WebView.subproj/IFLocationChangeHandler.h b/WebKit/WebView.subproj/IFLocationChangeHandler.h
index 5f5929f..c7d5b4c 100644
--- a/WebKit/WebView.subproj/IFLocationChangeHandler.h
+++ b/WebKit/WebView.subproj/IFLocationChangeHandler.h
@@ -24,7 +24,6 @@
following messages, sent in order:
- (void)locationChangeStarted;
- - (void)requestContentPolicyForMIMEType: (NSString *)type;
- (void)locationChangeCommitted; // Only sent for the IFContentPolicyShow policy.
- (void)locationChangeDone: (IFError *)error;
@@ -34,24 +33,10 @@
=============================================================================
*/
-typedef enum {
- IFContentPolicyNone,
- IFContentPolicyShow,
- IFContentPolicySave,
- IFContentPolicyOpenExternally,
- IFContentPolicyIgnore
-} IFContentPolicy;
-
-
@protocol IFLocationChangeHandler <NSObject>
- (void)locationChangeStartedForDataSource: (IFWebDataSource *)dataSource;
-// Sent after locationChangeStarted.
-// Implementations typically call haveContentPolicy:forLocationChangeHandler: on IFWebController
-// after determining the appropriate policy, perhaps by presenting a non-blocking dialog to the user.
-- (void)requestContentPolicyForMIMEType: (NSString *)type dataSource: (IFWebDataSource *)dataSource;
-
- (void)locationChangeCommittedForDataSource: (IFWebDataSource *)dataSource;
- (void)locationChangeDone: (IFError *)error forDataSource: (IFWebDataSource *)dataSource;
@@ -60,8 +45,4 @@ typedef enum {
- (void)serverRedirectTo: (NSURL *)url forDataSource: (IFWebDataSource *)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: (IFError *)error forDataSource: (IFWebDataSource *)dataSource;
-
@end
diff --git a/WebKit/WebView.subproj/IFMainURLHandleClient.mm b/WebKit/WebView.subproj/IFMainURLHandleClient.mm
index c2c147f..909481a 100644
--- a/WebKit/WebView.subproj/IFMainURLHandleClient.mm
+++ b/WebKit/WebView.subproj/IFMainURLHandleClient.mm
@@ -9,6 +9,7 @@
#import <WebKit/IFLocationChangeHandler.h>
#import <WebKit/IFMainURLHandleClient.h>
#import <WebKit/IFWebController.h>
+#import <WebKit/IFWebControllerPolicyHandler.h>
#import <WebKit/IFWebControllerPrivate.h>
#import <WebKit/IFWebDataSource.h>
#import <WebKit/IFWebDataSourcePrivate.h>
@@ -85,7 +86,7 @@
// Don't retain download data
if([dataSource contentPolicy] != IFContentPolicySave &&
- [dataSource contentPolicy] != IFContentPolicyOpenExternally){
+ [dataSource contentPolicy] != IFContentPolicySaveAndOpenExternally){
[dataSource _setResourceData:data];
}
@@ -115,6 +116,7 @@
- (void)IFURLHandle:(IFURLHandle *)sender resourceDataDidBecomeAvailable:(NSData *)incomingData
{
+ IFWebController *controller = [dataSource controller];
NSString *contentType = [sender contentType];
IFWebFrame *frame = [dataSource webFrame];
IFWebView *view = [frame webView];
@@ -132,12 +134,12 @@
// and there is no extension, this is text/html
if([contentType isEqualToString:IFDefaultMIMEType] && [[[url path] pathExtension] isEqualToString:@""])
contentType = @"text/html";
-
- WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD, "main content type: %s", DEBUG_OBJECT(contentType));
[dataSource _setContentType:contentType];
[dataSource _setEncoding:[sender characterSet]];
- [[dataSource _locationChangeHandler] requestContentPolicyForMIMEType:contentType dataSource:dataSource];
+ [[controller policyHandler] requestContentPolicyForMIMEType:contentType dataSource:dataSource];
+
+ WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD, "main content type: %s", DEBUG_OBJECT(contentType));
}
contentPolicy = [dataSource contentPolicy];
@@ -161,7 +163,7 @@
[[dataSource representation] receivedData:data withDataSource:dataSource];
[[view documentView] dataSourceUpdated:dataSource];
- }else if(contentPolicy == IFContentPolicySave || contentPolicy == IFContentPolicyOpenExternally){
+ }else if(contentPolicy == IFContentPolicySave || contentPolicy == IFContentPolicySaveAndOpenExternally){
if(!downloadHandler){
[frame->_private setProvisionalDataSource:nil];
[[dataSource _locationChangeHandler] locationChangeDone:nil forDataSource:dataSource];
diff --git a/WebKit/WebView.subproj/IFWebController.h b/WebKit/WebView.subproj/IFWebController.h
index ce11b81..55832ee 100644
--- a/WebKit/WebView.subproj/IFWebController.h
+++ b/WebKit/WebView.subproj/IFWebController.h
@@ -9,6 +9,7 @@
#import <Foundation/Foundation.h>
#import <WebKit/IFLocationChangeHandler.h>
+#import <WebKit/IFWebControllerPolicyHandler.h>
/*
=============================================================================
@@ -70,38 +71,6 @@
/*
=============================================================================
- =============================================================================
-*/
-
-typedef enum {
- IFURLPolicyUseContentPolicy,
- IFURLPolicyOpenExternally,
- IFURLPolicyIgnore
-} IFURLPolicy;
-
-
- at protocol IFWebControllerPolicyHandler <NSObject>
-
-- (id <IFLocationChangeHandler>)provideLocationChangeHandlerForDataSource: (IFWebDataSource *)dataSource;
-
-// URLPolicyForURL: is used to determine what to do BEFORE a URL is loaded, i.e.
-// 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:.
-- (IFURLPolicy)URLPolicyForURL: (NSURL *)url;
-
-// We may have different errors that cause the the policy to be un-implementable, i.e.
-// launch services failure, etc.
-- (void)unableToImplementURLPolicyForURL: (NSURL *)url error: (IFError *)error;
-
-// Called when a plug-in for a certain mime type is not installed
-- (void)pluginNotFoundForMIMEType:(NSString *)mime pluginPageURL:(NSURL *)url;
-
- at end
-
-/*
- =============================================================================
-
A class that implements IFWindowContext provides window-related methods
that may be used by Javascript, plugins and other aspects of web pages.
diff --git a/WebKit/WebView.subproj/IFWebController.mm b/WebKit/WebView.subproj/IFWebController.mm
index 109eae0..cfb9428 100644
--- a/WebKit/WebView.subproj/IFWebController.mm
+++ b/WebKit/WebView.subproj/IFWebController.mm
@@ -14,10 +14,11 @@
#import <WebKit/IFWebFrame.h>
#import <WebKit/IFWebFramePrivate.h>
#import <WebKit/IFWebController.h>
+#import <WebKit/IFWebControllerPolicyHandler.h>
+#import <WebKit/IFWebKitErrors.h>
#import <WebKit/WebKitDebug.h>
#import <WebFoundation/WebFoundation.h>
-#import <WebFoundation/IFFileTypeMappings.h>
@implementation IFWebController
@@ -241,7 +242,9 @@
[webView _setDocumentView: documentView];
[documentView provisionalDataSourceChanged: dataSource];
}else{
- // return error with unableToImplementContentPolicy
+ IFError *error = [[IFError alloc] initWithErrorCode:IFErrorCodeCantShowMIMEType
+ inDomain:IFErrorCodeDomainWebKit failingURL: [dataSource inputURL]];
+ [[self policyHandler] unableToImplementContentPolicy:error forDataSource:dataSource];
}
}
}
@@ -277,11 +280,10 @@
}
+ (BOOL)canShowFile:(NSString *)path
-{
- NSString *MIMEType, *extension = [path pathExtension];
-
- MIMEType = [[IFFileTypeMappings sharedMappings] MIMETypeForExtension:extension];
+{
+ NSString *MIMEType;
+ MIMEType = [[self class] _MIMETypeForFile:path];
return [[self class] canShowMIMEType:MIMEType];
}
diff --git a/WebKit/WebView.subproj/IFWebControllerPolicyHandler.h b/WebKit/WebView.subproj/IFWebControllerPolicyHandler.h
new file mode 100644
index 0000000..8d99688
--- /dev/null
+++ b/WebKit/WebView.subproj/IFWebControllerPolicyHandler.h
@@ -0,0 +1,70 @@
+/*
+ IFWebControllerPolicyHandler.h
+ Copyright 2002, Apple, Inc. All rights reserved.
+
+ Public header file.
+*/
+
+#include <Cocoa/Cocoa.h>
+
+/*
+ =============================================================================
+
+ =============================================================================
+*/
+
+typedef enum {
+ IFURLPolicyUseContentPolicy,
+ IFURLPolicyOpenExternally,
+ IFURLPolicyIgnore
+} IFURLPolicy;
+
+typedef enum {
+ IFFileURLPolicyUseContentPolicy,
+ IFFileURLPolicyOpenExternally,
+ IFFileURLPolicyIgnore
+} IFFileURLPolicy;
+
+typedef enum {
+ IFContentPolicyNone,
+ IFContentPolicyShow,
+ IFContentPolicySave,
+ IFContentPolicySaveAndOpenExternally,
+ IFContentPolicyIgnore
+} IFContentPolicy;
+
+ at protocol IFWebControllerPolicyHandler <NSObject>
+
+- (id <IFLocationChangeHandler>)provideLocationChangeHandlerForDataSource: (IFWebDataSource *)dataSource;
+
+// URLPolicyForURL: is used to determine what to do BEFORE a URL is loaded, i.e.
+// 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:.
+- (IFURLPolicy)URLPolicyForURL: (NSURL *)url;
+
+// We may have different errors that cause the the policy to be un-implementable, i.e.
+// launch services failure, etc.
+- (void)unableToImplementURLPolicyForURL: (NSURL *)url error: (IFError *)error;
+
+// Called when the response to URLPolicyForURL is IFURLPolicyUseContentPolicy and the URL is
+// a file URL. This allows clients to special-case WebKit's behavior for file URLs.
+- (IFFileURLPolicy)fileURLPolicyForMIMEType: (NSString *)type dataSource: (IFWebDataSource *)dataSource isDirectory: (BOOL)isDirectory;
+
+// Called when a IFFileURLPolicy could not be completed. This is usually caused by files not
+// existing or not readable.
+- (void)unableToImplementFileURLPolicy: (IFError *)error forDataSource: (IFWebDataSource *)dataSource;
+
+// Sent after locationChangeStarted.
+// Implementations typically call haveContentPolicy:forLocationChangeHandler: on IFWebController
+// after determining the appropriate policy, perhaps by presenting a non-blocking dialog to the user.
+- (void)requestContentPolicyForMIMEType: (NSString *)type dataSource: (IFWebDataSource *)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: (IFError *)error forDataSource: (IFWebDataSource *)dataSource;
+
+// Called when a plug-in for a certain mime type is not installed
+- (void)pluginNotFoundForMIMEType:(NSString *)mime pluginPageURL:(NSURL *)url;
+
+ at end
\ No newline at end of file
diff --git a/WebKit/WebView.subproj/IFWebControllerPrivate.h b/WebKit/WebView.subproj/IFWebControllerPrivate.h
index bc31c42..9ddce45 100644
--- a/WebKit/WebView.subproj/IFWebControllerPrivate.h
+++ b/WebKit/WebView.subproj/IFWebControllerPrivate.h
@@ -25,4 +25,5 @@
- (void)_mainReceivedError: (IFError *)error forResourceHandle: (IFURLHandle *)resourceHandle partialProgress: (IFLoadProgress *)progress fromDataSource: (IFWebDataSource *)dataSource;
- (void)_didStartLoading: (NSURL *)url;
- (void)_didStopLoading: (NSURL *)url;
++ (NSString *)_MIMETypeForFile: (NSString *)path;
@end
diff --git a/WebKit/WebView.subproj/IFWebControllerPrivate.mm b/WebKit/WebView.subproj/IFWebControllerPrivate.mm
index 2839b55..499de5a 100644
--- a/WebKit/WebView.subproj/IFWebControllerPrivate.mm
+++ b/WebKit/WebView.subproj/IFWebControllerPrivate.mm
@@ -14,6 +14,7 @@
#import <WebKit/WebKitDebug.h>
#import <WebFoundation/IFError.h>
+#import <WebFoundation/IFFileTypeMappings.h>
#import <WebFoundation/IFURLCacheLoaderConstants.h>
#import <WebFoundation/IFURLHandle.h>
@@ -124,7 +125,7 @@
fromDataSource: dataSource complete:isComplete];
if(isComplete){
- if(contentPolicy == IFContentPolicyOpenExternally || contentPolicy == IFContentPolicySave)
+ if(contentPolicy == IFContentPolicySaveAndOpenExternally || contentPolicy == IFContentPolicySave)
[dataSource _setPrimaryLoadComplete: YES];
}
@@ -204,4 +205,11 @@
[[IFStandardPanels sharedStandardPanels] _didStopLoadingURL:url inController:self];
}
++ (NSString *)_MIMETypeForFile: (NSString *)path
+{
+ NSString *extension = [path pathExtension];
+
+ return [[IFFileTypeMappings sharedMappings] MIMETypeForExtension:extension];
+}
+
@end
diff --git a/WebKit/WebView.subproj/IFWebDataSource.h b/WebKit/WebView.subproj/IFWebDataSource.h
index 919bcc0..ba208ef 100644
--- a/WebKit/WebView.subproj/IFWebDataSource.h
+++ b/WebKit/WebView.subproj/IFWebDataSource.h
@@ -7,7 +7,7 @@
#import <Cocoa/Cocoa.h>
-#import <WebKit/IFLocationChangeHandler.h>
+#import <WebKit/IFWebController.h>
/*
=============================================================================
diff --git a/WebKit/WebView.subproj/IFWebFrame.mm b/WebKit/WebView.subproj/IFWebFrame.mm
index 1307202..1a4ccc8 100644
--- a/WebKit/WebView.subproj/IFWebFrame.mm
+++ b/WebKit/WebView.subproj/IFWebFrame.mm
@@ -9,7 +9,7 @@
#import <WebKit/IFHTMLRepresentationPrivate.h>
#import <WebKit/IFHTMLViewPrivate.h>
-#import <WebKit/IFWebControllerPrivate.h>
+#import <WebKit/IFWebController.h>
#import <WebKit/IFWebCoreBridge.h>
#import <WebKit/IFWebCoreFrame.h>
#import <WebKit/IFWebDataSourcePrivate.h>
@@ -129,9 +129,8 @@
// disallows by returning a IFURLPolicyIgnore.
- (BOOL)setProvisionalDataSource: (IFWebDataSource *)newDataSource
{
- IFWebDataSource *oldDataSource;
id <IFLocationChangeHandler>locationChangeHandler;
- IFURLPolicy urlPolicy;
+ IFWebDataSource *oldDataSource;
WEBKIT_ASSERT ([self controller] != nil);
@@ -140,13 +139,13 @@
// KDE drop we should fix this dependency.
WEBKIT_ASSERT ([self webView] != nil);
- urlPolicy = [[[self controller] policyHandler] URLPolicyForURL:[newDataSource inputURL]];
+ if ([self _state] != IFWEBFRAMESTATE_COMPLETE){
+ [self stopLoading];
+ }
- if(urlPolicy == IFURLPolicyUseContentPolicy){
-
- if ([self _state] != IFWEBFRAMESTATE_COMPLETE){
- [self stopLoading];
- }
+ // _shouldShowDataSource 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]){
locationChangeHandler = [[[self controller] policyHandler] provideLocationChangeHandlerForDataSource: newDataSource];
@@ -170,14 +169,11 @@
// once it has been created by the controller.
[self _setState: IFWEBFRAMESTATE_PROVISIONAL];
- }
- else if(urlPolicy == IFURLPolicyOpenExternally){
- return [[NSWorkspace sharedWorkspace] openURL:[newDataSource inputURL]];
- }
- else if (urlPolicy == IFURLPolicyIgnore)
- return NO;
- return YES;
+ return YES;
+ }
+
+ return NO;
}
diff --git a/WebKit/WebView.subproj/IFWebFramePrivate.h b/WebKit/WebView.subproj/IFWebFramePrivate.h
index 4e388d0..58b9b52 100644
--- a/WebKit/WebView.subproj/IFWebFramePrivate.h
+++ b/WebKit/WebView.subproj/IFWebFramePrivate.h
@@ -80,4 +80,5 @@ typedef enum {
- (void)_checkLoadComplete;
- (void)_timedLayout: userInfo;
- (IFWebCoreFrame *)_bridgeFrame;
+- (BOOL)_shouldShowDataSource:(IFWebDataSource *)dataSource;
@end
diff --git a/WebKit/WebView.subproj/IFWebFramePrivate.mm b/WebKit/WebView.subproj/IFWebFramePrivate.mm
index 52f49dc..6298906 100644
--- a/WebKit/WebView.subproj/IFWebFramePrivate.mm
+++ b/WebKit/WebView.subproj/IFWebFramePrivate.mm
@@ -9,15 +9,17 @@
#import <WebKit/IFLocationChangeHandler.h>
#import <WebKit/IFPreferencesPrivate.h>
#import <WebKit/IFWebController.h>
+#import <WebKit/IFWebControllerPrivate.h>
#import <WebKit/IFWebCoreBridge.h>
#import <WebKit/IFWebCoreFrame.h>
#import <WebKit/IFWebDataSource.h>
#import <WebKit/IFWebDataSourcePrivate.h>
#import <WebKit/IFWebFramePrivate.h>
+#import <WebKit/IFWebKitErrors.h>
#import <WebKit/IFWebViewPrivate.h>
#import <WebKit/WebKitDebug.h>
-#import <WebFoundation/IFError.h>
+#import <WebFoundation/WebFoundation.h>
// includes from kde
#import <khtmlview.h>
@@ -469,4 +471,113 @@ static const char * const stateNames[6] = {
return _private->bridgeFrame;
}
+- (BOOL)_shouldShowDataSource:(IFWebDataSource *)dataSource
+{
+ id <IFWebControllerPolicyHandler> policyHandler = [[self controller] policyHandler];
+ NSFileManager *fileManager = [NSFileManager defaultManager];
+ NSWorkspace *workspace = [NSWorkspace sharedWorkspace];
+ NSURL *url = [dataSource inputURL];
+ IFFileURLPolicy fileURLPolicy;
+ NSString *path = [url path];
+ BOOL isDirectory, fileExists;
+ IFError *error;
+
+ IFURLPolicy urlPolicy = [policyHandler URLPolicyForURL:url];
+
+ if(urlPolicy == IFURLPolicyUseContentPolicy){
+
+ if([url isFileURL]){
+
+ fileExists = [fileManager fileExistsAtPath:path isDirectory:&isDirectory];
+
+ NSString *type = [IFWebController _MIMETypeForFile: path];
+
+ if(isDirectory){
+ fileURLPolicy = [policyHandler fileURLPolicyForMIMEType: nil dataSource: dataSource isDirectory:YES];
+ }else{
+ fileURLPolicy = [policyHandler fileURLPolicyForMIMEType: type dataSource: dataSource isDirectory:NO];
+ }
+
+ if(fileURLPolicy == IFFileURLPolicyIgnore)
+ return NO;
+
+ if(!fileExists){
+ error = [[IFError alloc] initWithErrorCode:IFErrorCodeFileDoesntExist
+ inDomain:IFErrorCodeDomainWebKit failingURL:url];
+ [policyHandler unableToImplementFileURLPolicy: error forDataSource: dataSource];
+ return NO;
+ }
+
+ if(![fileManager isReadableFileAtPath:path]){
+ error = [[IFError alloc] initWithErrorCode:IFErrorCodeFileNotReadable
+ inDomain:IFErrorCodeDomainWebKit failingURL:url];
+ [policyHandler unableToImplementFileURLPolicy: error forDataSource: dataSource];
+ return NO;
+ }
+
+ if(fileURLPolicy == IFFileURLPolicyUseContentPolicy){
+ if(isDirectory){
+ error = [[IFError alloc] initWithErrorCode:IFErrorCodeCantShowDirectory
+ inDomain:IFErrorCodeDomainWebKit failingURL: url];
+ [policyHandler unableToImplementFileURLPolicy: error forDataSource: dataSource];
+ return NO;
+ }
+ else if(![IFWebController canShowMIMEType: type]){
+ error = [[IFError alloc] initWithErrorCode:IFErrorCodeCantShowMIMEType
+ inDomain:IFErrorCodeDomainWebKit failingURL: url];
+ [policyHandler unableToImplementFileURLPolicy: error forDataSource: dataSource];
+ return NO;
+ }else{
+ // File exists, its readable, we can show it
+ return YES;
+ }
+ }else if(fileURLPolicy == IFFileURLPolicyOpenExternally){
+ if(isDirectory){
+ if(![workspace selectFile:path inFileViewerRootedAtPath:@""]){
+ error = [[IFError alloc] initWithErrorCode:IFErrorCodeFinderCouldntOpenDirectory
+ inDomain:IFErrorCodeDomainWebKit failingURL: url];
+ [policyHandler unableToImplementFileURLPolicy: error forDataSource: dataSource];
+ }
+ return NO;
+ }else{
+ if(![workspace openFile:path]){
+ error = [[IFError alloc] initWithErrorCode:IFErrorCodeCouldntFindApplicationForFile
+ inDomain:IFErrorCodeDomainWebKit failingURL: url];
+ [policyHandler unableToImplementFileURLPolicy: error forDataSource: dataSource];
+ }
+ return NO;
+ }
+ }else{
+ [NSException raise:NSInvalidArgumentException format:
+ @"fileURLPolicyForMIMEType:dataSource:isDirectory: returned an invalid IFFileURLPolicy"];
+ return NO;
+ }
+ }else{
+ if(![IFURLHandle canInitWithURL:url]){
+ error = [[IFError alloc] initWithErrorCode:IFErrorCodeCantShowURL
+ inDomain:IFErrorCodeDomainWebKit failingURL: url];
+ [policyHandler unableToImplementURLPolicyForURL: url error: error];
+ return NO;
+ }
+ // we can handle this URL
+ return YES;
+ }
+ }
+ else if(urlPolicy == IFURLPolicyOpenExternally){
+ if(![workspace openURL:url]){
+ error = [[IFError alloc] initWithErrorCode:IFErrorCodeCouldntFindApplicationForURL
+ inDomain:IFErrorCodeDomainWebKit failingURL: url];
+ [policyHandler unableToImplementURLPolicyForURL: url error: error];
+ }
+ return NO;
+ }
+ else if(urlPolicy == IFURLPolicyIgnore){
+ return NO;
+ }
+ else{
+ [NSException raise:NSInvalidArgumentException format:@"URLPolicyForURL: returned an invalid IFURLPolicy"];
+ return NO;
+ }
+}
+
@end
diff --git a/WebKit/WebView.subproj/IFWebView.mm b/WebKit/WebView.subproj/IFWebView.mm
index 6796440..a5314f1 100644
--- a/WebKit/WebView.subproj/IFWebView.mm
+++ b/WebKit/WebView.subproj/IFWebView.mm
@@ -11,15 +11,34 @@
#import <WebKit/IFWebCoreViewFactory.h>
#import <WebKit/IFWebDataSource.h>
#import <WebKit/IFWebFrame.h>
+#import <WebKit/IFWebKitErrors.h>
#import <WebKit/IFTextRendererFactory.h>
#import <WebKit/IFImageRendererFactory.h>
#import <WebKit/IFCookieAdapter.h>
#import <WebFoundation/IFNSStringExtensions.h>
#import <WebFoundation/IFNSURLExtensions.h>
+#import <WebFoundation/WebFoundation.h>
@implementation IFWebView
++ (void)initialize
+{
+ NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
+
+ IFErrorDescriptionCantShowMIMEType, [NSNumber numberWithInt: IFErrorCodeCantShowMIMEType],
+ IFErrorDescriptionCouldntFindApplicationForFile, [NSNumber numberWithInt: IFErrorCodeCouldntFindApplicationForFile],
+ IFErrorDescriptionCouldntFindApplicationForURL, [NSNumber numberWithInt: IFErrorCodeCouldntFindApplicationForURL],
+ IFErrorDescriptionFileDoesntExist, [NSNumber numberWithInt: IFErrorCodeFileDoesntExist],
+ IFErrorDescriptionFileNotReadable, [NSNumber numberWithInt: IFErrorCodeFileNotReadable],
+ IFErrorDescriptionFinderCouldntOpenDirectory, [NSNumber numberWithInt: IFErrorCodeFinderCouldntOpenDirectory],
+ IFErrorDescriptionCantShowDirectory, [NSNumber numberWithInt: IFErrorCodeCantShowDirectory],
+ IFErrorDescriptionCantShowURL, [NSNumber numberWithInt: IFErrorCodeCantShowURL],
+ nil];
+
+ [IFError addErrorsFromDictionary:dict];
+}
+
- initWithFrame: (NSRect) frame
{
[super initWithFrame: frame];
diff --git a/WebKit/WebView.subproj/WebController.h b/WebKit/WebView.subproj/WebController.h
index ce11b81..55832ee 100644
--- a/WebKit/WebView.subproj/WebController.h
+++ b/WebKit/WebView.subproj/WebController.h
@@ -9,6 +9,7 @@
#import <Foundation/Foundation.h>
#import <WebKit/IFLocationChangeHandler.h>
+#import <WebKit/IFWebControllerPolicyHandler.h>
/*
=============================================================================
@@ -70,38 +71,6 @@
/*
=============================================================================
- =============================================================================
-*/
-
-typedef enum {
- IFURLPolicyUseContentPolicy,
- IFURLPolicyOpenExternally,
- IFURLPolicyIgnore
-} IFURLPolicy;
-
-
- at protocol IFWebControllerPolicyHandler <NSObject>
-
-- (id <IFLocationChangeHandler>)provideLocationChangeHandlerForDataSource: (IFWebDataSource *)dataSource;
-
-// URLPolicyForURL: is used to determine what to do BEFORE a URL is loaded, i.e.
-// 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:.
-- (IFURLPolicy)URLPolicyForURL: (NSURL *)url;
-
-// We may have different errors that cause the the policy to be un-implementable, i.e.
-// launch services failure, etc.
-- (void)unableToImplementURLPolicyForURL: (NSURL *)url error: (IFError *)error;
-
-// Called when a plug-in for a certain mime type is not installed
-- (void)pluginNotFoundForMIMEType:(NSString *)mime pluginPageURL:(NSURL *)url;
-
- at end
-
-/*
- =============================================================================
-
A class that implements IFWindowContext provides window-related methods
that may be used by Javascript, plugins and other aspects of web pages.
diff --git a/WebKit/WebView.subproj/WebController.m b/WebKit/WebView.subproj/WebController.m
index 109eae0..cfb9428 100644
--- a/WebKit/WebView.subproj/WebController.m
+++ b/WebKit/WebView.subproj/WebController.m
@@ -14,10 +14,11 @@
#import <WebKit/IFWebFrame.h>
#import <WebKit/IFWebFramePrivate.h>
#import <WebKit/IFWebController.h>
+#import <WebKit/IFWebControllerPolicyHandler.h>
+#import <WebKit/IFWebKitErrors.h>
#import <WebKit/WebKitDebug.h>
#import <WebFoundation/WebFoundation.h>
-#import <WebFoundation/IFFileTypeMappings.h>
@implementation IFWebController
@@ -241,7 +242,9 @@
[webView _setDocumentView: documentView];
[documentView provisionalDataSourceChanged: dataSource];
}else{
- // return error with unableToImplementContentPolicy
+ IFError *error = [[IFError alloc] initWithErrorCode:IFErrorCodeCantShowMIMEType
+ inDomain:IFErrorCodeDomainWebKit failingURL: [dataSource inputURL]];
+ [[self policyHandler] unableToImplementContentPolicy:error forDataSource:dataSource];
}
}
}
@@ -277,11 +280,10 @@
}
+ (BOOL)canShowFile:(NSString *)path
-{
- NSString *MIMEType, *extension = [path pathExtension];
-
- MIMEType = [[IFFileTypeMappings sharedMappings] MIMETypeForExtension:extension];
+{
+ NSString *MIMEType;
+ MIMEType = [[self class] _MIMETypeForFile:path];
return [[self class] canShowMIMEType:MIMEType];
}
diff --git a/WebKit/WebView.subproj/WebControllerPolicyDelegate.h b/WebKit/WebView.subproj/WebControllerPolicyDelegate.h
new file mode 100644
index 0000000..8d99688
--- /dev/null
+++ b/WebKit/WebView.subproj/WebControllerPolicyDelegate.h
@@ -0,0 +1,70 @@
+/*
+ IFWebControllerPolicyHandler.h
+ Copyright 2002, Apple, Inc. All rights reserved.
+
+ Public header file.
+*/
+
+#include <Cocoa/Cocoa.h>
+
+/*
+ =============================================================================
+
+ =============================================================================
+*/
+
+typedef enum {
+ IFURLPolicyUseContentPolicy,
+ IFURLPolicyOpenExternally,
+ IFURLPolicyIgnore
+} IFURLPolicy;
+
+typedef enum {
+ IFFileURLPolicyUseContentPolicy,
+ IFFileURLPolicyOpenExternally,
+ IFFileURLPolicyIgnore
+} IFFileURLPolicy;
+
+typedef enum {
+ IFContentPolicyNone,
+ IFContentPolicyShow,
+ IFContentPolicySave,
+ IFContentPolicySaveAndOpenExternally,
+ IFContentPolicyIgnore
+} IFContentPolicy;
+
+ at protocol IFWebControllerPolicyHandler <NSObject>
+
+- (id <IFLocationChangeHandler>)provideLocationChangeHandlerForDataSource: (IFWebDataSource *)dataSource;
+
+// URLPolicyForURL: is used to determine what to do BEFORE a URL is loaded, i.e.
+// 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:.
+- (IFURLPolicy)URLPolicyForURL: (NSURL *)url;
+
+// We may have different errors that cause the the policy to be un-implementable, i.e.
+// launch services failure, etc.
+- (void)unableToImplementURLPolicyForURL: (NSURL *)url error: (IFError *)error;
+
+// Called when the response to URLPolicyForURL is IFURLPolicyUseContentPolicy and the URL is
+// a file URL. This allows clients to special-case WebKit's behavior for file URLs.
+- (IFFileURLPolicy)fileURLPolicyForMIMEType: (NSString *)type dataSource: (IFWebDataSource *)dataSource isDirectory: (BOOL)isDirectory;
+
+// Called when a IFFileURLPolicy could not be completed. This is usually caused by files not
+// existing or not readable.
+- (void)unableToImplementFileURLPolicy: (IFError *)error forDataSource: (IFWebDataSource *)dataSource;
+
+// Sent after locationChangeStarted.
+// Implementations typically call haveContentPolicy:forLocationChangeHandler: on IFWebController
+// after determining the appropriate policy, perhaps by presenting a non-blocking dialog to the user.
+- (void)requestContentPolicyForMIMEType: (NSString *)type dataSource: (IFWebDataSource *)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: (IFError *)error forDataSource: (IFWebDataSource *)dataSource;
+
+// Called when a plug-in for a certain mime type is not installed
+- (void)pluginNotFoundForMIMEType:(NSString *)mime pluginPageURL:(NSURL *)url;
+
+ at end
\ No newline at end of file
diff --git a/WebKit/WebView.subproj/WebControllerPolicyHandler.h b/WebKit/WebView.subproj/WebControllerPolicyHandler.h
new file mode 100644
index 0000000..8d99688
--- /dev/null
+++ b/WebKit/WebView.subproj/WebControllerPolicyHandler.h
@@ -0,0 +1,70 @@
+/*
+ IFWebControllerPolicyHandler.h
+ Copyright 2002, Apple, Inc. All rights reserved.
+
+ Public header file.
+*/
+
+#include <Cocoa/Cocoa.h>
+
+/*
+ =============================================================================
+
+ =============================================================================
+*/
+
+typedef enum {
+ IFURLPolicyUseContentPolicy,
+ IFURLPolicyOpenExternally,
+ IFURLPolicyIgnore
+} IFURLPolicy;
+
+typedef enum {
+ IFFileURLPolicyUseContentPolicy,
+ IFFileURLPolicyOpenExternally,
+ IFFileURLPolicyIgnore
+} IFFileURLPolicy;
+
+typedef enum {
+ IFContentPolicyNone,
+ IFContentPolicyShow,
+ IFContentPolicySave,
+ IFContentPolicySaveAndOpenExternally,
+ IFContentPolicyIgnore
+} IFContentPolicy;
+
+ at protocol IFWebControllerPolicyHandler <NSObject>
+
+- (id <IFLocationChangeHandler>)provideLocationChangeHandlerForDataSource: (IFWebDataSource *)dataSource;
+
+// URLPolicyForURL: is used to determine what to do BEFORE a URL is loaded, i.e.
+// 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:.
+- (IFURLPolicy)URLPolicyForURL: (NSURL *)url;
+
+// We may have different errors that cause the the policy to be un-implementable, i.e.
+// launch services failure, etc.
+- (void)unableToImplementURLPolicyForURL: (NSURL *)url error: (IFError *)error;
+
+// Called when the response to URLPolicyForURL is IFURLPolicyUseContentPolicy and the URL is
+// a file URL. This allows clients to special-case WebKit's behavior for file URLs.
+- (IFFileURLPolicy)fileURLPolicyForMIMEType: (NSString *)type dataSource: (IFWebDataSource *)dataSource isDirectory: (BOOL)isDirectory;
+
+// Called when a IFFileURLPolicy could not be completed. This is usually caused by files not
+// existing or not readable.
+- (void)unableToImplementFileURLPolicy: (IFError *)error forDataSource: (IFWebDataSource *)dataSource;
+
+// Sent after locationChangeStarted.
+// Implementations typically call haveContentPolicy:forLocationChangeHandler: on IFWebController
+// after determining the appropriate policy, perhaps by presenting a non-blocking dialog to the user.
+- (void)requestContentPolicyForMIMEType: (NSString *)type dataSource: (IFWebDataSource *)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: (IFError *)error forDataSource: (IFWebDataSource *)dataSource;
+
+// Called when a plug-in for a certain mime type is not installed
+- (void)pluginNotFoundForMIMEType:(NSString *)mime pluginPageURL:(NSURL *)url;
+
+ at end
\ No newline at end of file
diff --git a/WebKit/WebView.subproj/WebControllerPrivate.h b/WebKit/WebView.subproj/WebControllerPrivate.h
index bc31c42..9ddce45 100644
--- a/WebKit/WebView.subproj/WebControllerPrivate.h
+++ b/WebKit/WebView.subproj/WebControllerPrivate.h
@@ -25,4 +25,5 @@
- (void)_mainReceivedError: (IFError *)error forResourceHandle: (IFURLHandle *)resourceHandle partialProgress: (IFLoadProgress *)progress fromDataSource: (IFWebDataSource *)dataSource;
- (void)_didStartLoading: (NSURL *)url;
- (void)_didStopLoading: (NSURL *)url;
++ (NSString *)_MIMETypeForFile: (NSString *)path;
@end
diff --git a/WebKit/WebView.subproj/WebControllerPrivate.m b/WebKit/WebView.subproj/WebControllerPrivate.m
index 2839b55..499de5a 100644
--- a/WebKit/WebView.subproj/WebControllerPrivate.m
+++ b/WebKit/WebView.subproj/WebControllerPrivate.m
@@ -14,6 +14,7 @@
#import <WebKit/WebKitDebug.h>
#import <WebFoundation/IFError.h>
+#import <WebFoundation/IFFileTypeMappings.h>
#import <WebFoundation/IFURLCacheLoaderConstants.h>
#import <WebFoundation/IFURLHandle.h>
@@ -124,7 +125,7 @@
fromDataSource: dataSource complete:isComplete];
if(isComplete){
- if(contentPolicy == IFContentPolicyOpenExternally || contentPolicy == IFContentPolicySave)
+ if(contentPolicy == IFContentPolicySaveAndOpenExternally || contentPolicy == IFContentPolicySave)
[dataSource _setPrimaryLoadComplete: YES];
}
@@ -204,4 +205,11 @@
[[IFStandardPanels sharedStandardPanels] _didStopLoadingURL:url inController:self];
}
++ (NSString *)_MIMETypeForFile: (NSString *)path
+{
+ NSString *extension = [path pathExtension];
+
+ return [[IFFileTypeMappings sharedMappings] MIMETypeForExtension:extension];
+}
+
@end
diff --git a/WebKit/WebView.subproj/WebDataSource.h b/WebKit/WebView.subproj/WebDataSource.h
index 919bcc0..ba208ef 100644
--- a/WebKit/WebView.subproj/WebDataSource.h
+++ b/WebKit/WebView.subproj/WebDataSource.h
@@ -7,7 +7,7 @@
#import <Cocoa/Cocoa.h>
-#import <WebKit/IFLocationChangeHandler.h>
+#import <WebKit/IFWebController.h>
/*
=============================================================================
diff --git a/WebKit/WebView.subproj/WebFrame.m b/WebKit/WebView.subproj/WebFrame.m
index 1307202..1a4ccc8 100644
--- a/WebKit/WebView.subproj/WebFrame.m
+++ b/WebKit/WebView.subproj/WebFrame.m
@@ -9,7 +9,7 @@
#import <WebKit/IFHTMLRepresentationPrivate.h>
#import <WebKit/IFHTMLViewPrivate.h>
-#import <WebKit/IFWebControllerPrivate.h>
+#import <WebKit/IFWebController.h>
#import <WebKit/IFWebCoreBridge.h>
#import <WebKit/IFWebCoreFrame.h>
#import <WebKit/IFWebDataSourcePrivate.h>
@@ -129,9 +129,8 @@
// disallows by returning a IFURLPolicyIgnore.
- (BOOL)setProvisionalDataSource: (IFWebDataSource *)newDataSource
{
- IFWebDataSource *oldDataSource;
id <IFLocationChangeHandler>locationChangeHandler;
- IFURLPolicy urlPolicy;
+ IFWebDataSource *oldDataSource;
WEBKIT_ASSERT ([self controller] != nil);
@@ -140,13 +139,13 @@
// KDE drop we should fix this dependency.
WEBKIT_ASSERT ([self webView] != nil);
- urlPolicy = [[[self controller] policyHandler] URLPolicyForURL:[newDataSource inputURL]];
+ if ([self _state] != IFWEBFRAMESTATE_COMPLETE){
+ [self stopLoading];
+ }
- if(urlPolicy == IFURLPolicyUseContentPolicy){
-
- if ([self _state] != IFWEBFRAMESTATE_COMPLETE){
- [self stopLoading];
- }
+ // _shouldShowDataSource 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]){
locationChangeHandler = [[[self controller] policyHandler] provideLocationChangeHandlerForDataSource: newDataSource];
@@ -170,14 +169,11 @@
// once it has been created by the controller.
[self _setState: IFWEBFRAMESTATE_PROVISIONAL];
- }
- else if(urlPolicy == IFURLPolicyOpenExternally){
- return [[NSWorkspace sharedWorkspace] openURL:[newDataSource inputURL]];
- }
- else if (urlPolicy == IFURLPolicyIgnore)
- return NO;
- return YES;
+ return YES;
+ }
+
+ return NO;
}
diff --git a/WebKit/WebView.subproj/WebFrameLoadDelegate.h b/WebKit/WebView.subproj/WebFrameLoadDelegate.h
index 5f5929f..c7d5b4c 100644
--- a/WebKit/WebView.subproj/WebFrameLoadDelegate.h
+++ b/WebKit/WebView.subproj/WebFrameLoadDelegate.h
@@ -24,7 +24,6 @@
following messages, sent in order:
- (void)locationChangeStarted;
- - (void)requestContentPolicyForMIMEType: (NSString *)type;
- (void)locationChangeCommitted; // Only sent for the IFContentPolicyShow policy.
- (void)locationChangeDone: (IFError *)error;
@@ -34,24 +33,10 @@
=============================================================================
*/
-typedef enum {
- IFContentPolicyNone,
- IFContentPolicyShow,
- IFContentPolicySave,
- IFContentPolicyOpenExternally,
- IFContentPolicyIgnore
-} IFContentPolicy;
-
-
@protocol IFLocationChangeHandler <NSObject>
- (void)locationChangeStartedForDataSource: (IFWebDataSource *)dataSource;
-// Sent after locationChangeStarted.
-// Implementations typically call haveContentPolicy:forLocationChangeHandler: on IFWebController
-// after determining the appropriate policy, perhaps by presenting a non-blocking dialog to the user.
-- (void)requestContentPolicyForMIMEType: (NSString *)type dataSource: (IFWebDataSource *)dataSource;
-
- (void)locationChangeCommittedForDataSource: (IFWebDataSource *)dataSource;
- (void)locationChangeDone: (IFError *)error forDataSource: (IFWebDataSource *)dataSource;
@@ -60,8 +45,4 @@ typedef enum {
- (void)serverRedirectTo: (NSURL *)url forDataSource: (IFWebDataSource *)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: (IFError *)error forDataSource: (IFWebDataSource *)dataSource;
-
@end
diff --git a/WebKit/WebView.subproj/WebFramePrivate.h b/WebKit/WebView.subproj/WebFramePrivate.h
index 4e388d0..58b9b52 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.h
+++ b/WebKit/WebView.subproj/WebFramePrivate.h
@@ -80,4 +80,5 @@ typedef enum {
- (void)_checkLoadComplete;
- (void)_timedLayout: userInfo;
- (IFWebCoreFrame *)_bridgeFrame;
+- (BOOL)_shouldShowDataSource:(IFWebDataSource *)dataSource;
@end
diff --git a/WebKit/WebView.subproj/WebFramePrivate.m b/WebKit/WebView.subproj/WebFramePrivate.m
index 52f49dc..6298906 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.m
+++ b/WebKit/WebView.subproj/WebFramePrivate.m
@@ -9,15 +9,17 @@
#import <WebKit/IFLocationChangeHandler.h>
#import <WebKit/IFPreferencesPrivate.h>
#import <WebKit/IFWebController.h>
+#import <WebKit/IFWebControllerPrivate.h>
#import <WebKit/IFWebCoreBridge.h>
#import <WebKit/IFWebCoreFrame.h>
#import <WebKit/IFWebDataSource.h>
#import <WebKit/IFWebDataSourcePrivate.h>
#import <WebKit/IFWebFramePrivate.h>
+#import <WebKit/IFWebKitErrors.h>
#import <WebKit/IFWebViewPrivate.h>
#import <WebKit/WebKitDebug.h>
-#import <WebFoundation/IFError.h>
+#import <WebFoundation/WebFoundation.h>
// includes from kde
#import <khtmlview.h>
@@ -469,4 +471,113 @@ static const char * const stateNames[6] = {
return _private->bridgeFrame;
}
+- (BOOL)_shouldShowDataSource:(IFWebDataSource *)dataSource
+{
+ id <IFWebControllerPolicyHandler> policyHandler = [[self controller] policyHandler];
+ NSFileManager *fileManager = [NSFileManager defaultManager];
+ NSWorkspace *workspace = [NSWorkspace sharedWorkspace];
+ NSURL *url = [dataSource inputURL];
+ IFFileURLPolicy fileURLPolicy;
+ NSString *path = [url path];
+ BOOL isDirectory, fileExists;
+ IFError *error;
+
+ IFURLPolicy urlPolicy = [policyHandler URLPolicyForURL:url];
+
+ if(urlPolicy == IFURLPolicyUseContentPolicy){
+
+ if([url isFileURL]){
+
+ fileExists = [fileManager fileExistsAtPath:path isDirectory:&isDirectory];
+
+ NSString *type = [IFWebController _MIMETypeForFile: path];
+
+ if(isDirectory){
+ fileURLPolicy = [policyHandler fileURLPolicyForMIMEType: nil dataSource: dataSource isDirectory:YES];
+ }else{
+ fileURLPolicy = [policyHandler fileURLPolicyForMIMEType: type dataSource: dataSource isDirectory:NO];
+ }
+
+ if(fileURLPolicy == IFFileURLPolicyIgnore)
+ return NO;
+
+ if(!fileExists){
+ error = [[IFError alloc] initWithErrorCode:IFErrorCodeFileDoesntExist
+ inDomain:IFErrorCodeDomainWebKit failingURL:url];
+ [policyHandler unableToImplementFileURLPolicy: error forDataSource: dataSource];
+ return NO;
+ }
+
+ if(![fileManager isReadableFileAtPath:path]){
+ error = [[IFError alloc] initWithErrorCode:IFErrorCodeFileNotReadable
+ inDomain:IFErrorCodeDomainWebKit failingURL:url];
+ [policyHandler unableToImplementFileURLPolicy: error forDataSource: dataSource];
+ return NO;
+ }
+
+ if(fileURLPolicy == IFFileURLPolicyUseContentPolicy){
+ if(isDirectory){
+ error = [[IFError alloc] initWithErrorCode:IFErrorCodeCantShowDirectory
+ inDomain:IFErrorCodeDomainWebKit failingURL: url];
+ [policyHandler unableToImplementFileURLPolicy: error forDataSource: dataSource];
+ return NO;
+ }
+ else if(![IFWebController canShowMIMEType: type]){
+ error = [[IFError alloc] initWithErrorCode:IFErrorCodeCantShowMIMEType
+ inDomain:IFErrorCodeDomainWebKit failingURL: url];
+ [policyHandler unableToImplementFileURLPolicy: error forDataSource: dataSource];
+ return NO;
+ }else{
+ // File exists, its readable, we can show it
+ return YES;
+ }
+ }else if(fileURLPolicy == IFFileURLPolicyOpenExternally){
+ if(isDirectory){
+ if(![workspace selectFile:path inFileViewerRootedAtPath:@""]){
+ error = [[IFError alloc] initWithErrorCode:IFErrorCodeFinderCouldntOpenDirectory
+ inDomain:IFErrorCodeDomainWebKit failingURL: url];
+ [policyHandler unableToImplementFileURLPolicy: error forDataSource: dataSource];
+ }
+ return NO;
+ }else{
+ if(![workspace openFile:path]){
+ error = [[IFError alloc] initWithErrorCode:IFErrorCodeCouldntFindApplicationForFile
+ inDomain:IFErrorCodeDomainWebKit failingURL: url];
+ [policyHandler unableToImplementFileURLPolicy: error forDataSource: dataSource];
+ }
+ return NO;
+ }
+ }else{
+ [NSException raise:NSInvalidArgumentException format:
+ @"fileURLPolicyForMIMEType:dataSource:isDirectory: returned an invalid IFFileURLPolicy"];
+ return NO;
+ }
+ }else{
+ if(![IFURLHandle canInitWithURL:url]){
+ error = [[IFError alloc] initWithErrorCode:IFErrorCodeCantShowURL
+ inDomain:IFErrorCodeDomainWebKit failingURL: url];
+ [policyHandler unableToImplementURLPolicyForURL: url error: error];
+ return NO;
+ }
+ // we can handle this URL
+ return YES;
+ }
+ }
+ else if(urlPolicy == IFURLPolicyOpenExternally){
+ if(![workspace openURL:url]){
+ error = [[IFError alloc] initWithErrorCode:IFErrorCodeCouldntFindApplicationForURL
+ inDomain:IFErrorCodeDomainWebKit failingURL: url];
+ [policyHandler unableToImplementURLPolicyForURL: url error: error];
+ }
+ return NO;
+ }
+ else if(urlPolicy == IFURLPolicyIgnore){
+ return NO;
+ }
+ else{
+ [NSException raise:NSInvalidArgumentException format:@"URLPolicyForURL: returned an invalid IFURLPolicy"];
+ return NO;
+ }
+}
+
@end
diff --git a/WebKit/WebView.subproj/WebFrameView.m b/WebKit/WebView.subproj/WebFrameView.m
index 6796440..a5314f1 100644
--- a/WebKit/WebView.subproj/WebFrameView.m
+++ b/WebKit/WebView.subproj/WebFrameView.m
@@ -11,15 +11,34 @@
#import <WebKit/IFWebCoreViewFactory.h>
#import <WebKit/IFWebDataSource.h>
#import <WebKit/IFWebFrame.h>
+#import <WebKit/IFWebKitErrors.h>
#import <WebKit/IFTextRendererFactory.h>
#import <WebKit/IFImageRendererFactory.h>
#import <WebKit/IFCookieAdapter.h>
#import <WebFoundation/IFNSStringExtensions.h>
#import <WebFoundation/IFNSURLExtensions.h>
+#import <WebFoundation/WebFoundation.h>
@implementation IFWebView
++ (void)initialize
+{
+ NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
+
+ IFErrorDescriptionCantShowMIMEType, [NSNumber numberWithInt: IFErrorCodeCantShowMIMEType],
+ IFErrorDescriptionCouldntFindApplicationForFile, [NSNumber numberWithInt: IFErrorCodeCouldntFindApplicationForFile],
+ IFErrorDescriptionCouldntFindApplicationForURL, [NSNumber numberWithInt: IFErrorCodeCouldntFindApplicationForURL],
+ IFErrorDescriptionFileDoesntExist, [NSNumber numberWithInt: IFErrorCodeFileDoesntExist],
+ IFErrorDescriptionFileNotReadable, [NSNumber numberWithInt: IFErrorCodeFileNotReadable],
+ IFErrorDescriptionFinderCouldntOpenDirectory, [NSNumber numberWithInt: IFErrorCodeFinderCouldntOpenDirectory],
+ IFErrorDescriptionCantShowDirectory, [NSNumber numberWithInt: IFErrorCodeCantShowDirectory],
+ IFErrorDescriptionCantShowURL, [NSNumber numberWithInt: IFErrorCodeCantShowURL],
+ nil];
+
+ [IFError addErrorsFromDictionary:dict];
+}
+
- initWithFrame: (NSRect) frame
{
[super initWithFrame: frame];
diff --git a/WebKit/WebView.subproj/WebLocationChangeDelegate.h b/WebKit/WebView.subproj/WebLocationChangeDelegate.h
index 5f5929f..c7d5b4c 100644
--- a/WebKit/WebView.subproj/WebLocationChangeDelegate.h
+++ b/WebKit/WebView.subproj/WebLocationChangeDelegate.h
@@ -24,7 +24,6 @@
following messages, sent in order:
- (void)locationChangeStarted;
- - (void)requestContentPolicyForMIMEType: (NSString *)type;
- (void)locationChangeCommitted; // Only sent for the IFContentPolicyShow policy.
- (void)locationChangeDone: (IFError *)error;
@@ -34,24 +33,10 @@
=============================================================================
*/
-typedef enum {
- IFContentPolicyNone,
- IFContentPolicyShow,
- IFContentPolicySave,
- IFContentPolicyOpenExternally,
- IFContentPolicyIgnore
-} IFContentPolicy;
-
-
@protocol IFLocationChangeHandler <NSObject>
- (void)locationChangeStartedForDataSource: (IFWebDataSource *)dataSource;
-// Sent after locationChangeStarted.
-// Implementations typically call haveContentPolicy:forLocationChangeHandler: on IFWebController
-// after determining the appropriate policy, perhaps by presenting a non-blocking dialog to the user.
-- (void)requestContentPolicyForMIMEType: (NSString *)type dataSource: (IFWebDataSource *)dataSource;
-
- (void)locationChangeCommittedForDataSource: (IFWebDataSource *)dataSource;
- (void)locationChangeDone: (IFError *)error forDataSource: (IFWebDataSource *)dataSource;
@@ -60,8 +45,4 @@ typedef enum {
- (void)serverRedirectTo: (NSURL *)url forDataSource: (IFWebDataSource *)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: (IFError *)error forDataSource: (IFWebDataSource *)dataSource;
-
@end
diff --git a/WebKit/WebView.subproj/WebLocationChangeHandler.h b/WebKit/WebView.subproj/WebLocationChangeHandler.h
index 5f5929f..c7d5b4c 100644
--- a/WebKit/WebView.subproj/WebLocationChangeHandler.h
+++ b/WebKit/WebView.subproj/WebLocationChangeHandler.h
@@ -24,7 +24,6 @@
following messages, sent in order:
- (void)locationChangeStarted;
- - (void)requestContentPolicyForMIMEType: (NSString *)type;
- (void)locationChangeCommitted; // Only sent for the IFContentPolicyShow policy.
- (void)locationChangeDone: (IFError *)error;
@@ -34,24 +33,10 @@
=============================================================================
*/
-typedef enum {
- IFContentPolicyNone,
- IFContentPolicyShow,
- IFContentPolicySave,
- IFContentPolicyOpenExternally,
- IFContentPolicyIgnore
-} IFContentPolicy;
-
-
@protocol IFLocationChangeHandler <NSObject>
- (void)locationChangeStartedForDataSource: (IFWebDataSource *)dataSource;
-// Sent after locationChangeStarted.
-// Implementations typically call haveContentPolicy:forLocationChangeHandler: on IFWebController
-// after determining the appropriate policy, perhaps by presenting a non-blocking dialog to the user.
-- (void)requestContentPolicyForMIMEType: (NSString *)type dataSource: (IFWebDataSource *)dataSource;
-
- (void)locationChangeCommittedForDataSource: (IFWebDataSource *)dataSource;
- (void)locationChangeDone: (IFError *)error forDataSource: (IFWebDataSource *)dataSource;
@@ -60,8 +45,4 @@ typedef enum {
- (void)serverRedirectTo: (NSURL *)url forDataSource: (IFWebDataSource *)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: (IFError *)error forDataSource: (IFWebDataSource *)dataSource;
-
@end
diff --git a/WebKit/WebView.subproj/WebMainResourceClient.m b/WebKit/WebView.subproj/WebMainResourceClient.m
index c2c147f..909481a 100644
--- a/WebKit/WebView.subproj/WebMainResourceClient.m
+++ b/WebKit/WebView.subproj/WebMainResourceClient.m
@@ -9,6 +9,7 @@
#import <WebKit/IFLocationChangeHandler.h>
#import <WebKit/IFMainURLHandleClient.h>
#import <WebKit/IFWebController.h>
+#import <WebKit/IFWebControllerPolicyHandler.h>
#import <WebKit/IFWebControllerPrivate.h>
#import <WebKit/IFWebDataSource.h>
#import <WebKit/IFWebDataSourcePrivate.h>
@@ -85,7 +86,7 @@
// Don't retain download data
if([dataSource contentPolicy] != IFContentPolicySave &&
- [dataSource contentPolicy] != IFContentPolicyOpenExternally){
+ [dataSource contentPolicy] != IFContentPolicySaveAndOpenExternally){
[dataSource _setResourceData:data];
}
@@ -115,6 +116,7 @@
- (void)IFURLHandle:(IFURLHandle *)sender resourceDataDidBecomeAvailable:(NSData *)incomingData
{
+ IFWebController *controller = [dataSource controller];
NSString *contentType = [sender contentType];
IFWebFrame *frame = [dataSource webFrame];
IFWebView *view = [frame webView];
@@ -132,12 +134,12 @@
// and there is no extension, this is text/html
if([contentType isEqualToString:IFDefaultMIMEType] && [[[url path] pathExtension] isEqualToString:@""])
contentType = @"text/html";
-
- WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD, "main content type: %s", DEBUG_OBJECT(contentType));
[dataSource _setContentType:contentType];
[dataSource _setEncoding:[sender characterSet]];
- [[dataSource _locationChangeHandler] requestContentPolicyForMIMEType:contentType dataSource:dataSource];
+ [[controller policyHandler] requestContentPolicyForMIMEType:contentType dataSource:dataSource];
+
+ WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD, "main content type: %s", DEBUG_OBJECT(contentType));
}
contentPolicy = [dataSource contentPolicy];
@@ -161,7 +163,7 @@
[[dataSource representation] receivedData:data withDataSource:dataSource];
[[view documentView] dataSourceUpdated:dataSource];
- }else if(contentPolicy == IFContentPolicySave || contentPolicy == IFContentPolicyOpenExternally){
+ }else if(contentPolicy == IFContentPolicySave || contentPolicy == IFContentPolicySaveAndOpenExternally){
if(!downloadHandler){
[frame->_private setProvisionalDataSource:nil];
[[dataSource _locationChangeHandler] locationChangeDone:nil forDataSource:dataSource];
diff --git a/WebKit/WebView.subproj/WebMainResourceLoader.m b/WebKit/WebView.subproj/WebMainResourceLoader.m
index c2c147f..909481a 100644
--- a/WebKit/WebView.subproj/WebMainResourceLoader.m
+++ b/WebKit/WebView.subproj/WebMainResourceLoader.m
@@ -9,6 +9,7 @@
#import <WebKit/IFLocationChangeHandler.h>
#import <WebKit/IFMainURLHandleClient.h>
#import <WebKit/IFWebController.h>
+#import <WebKit/IFWebControllerPolicyHandler.h>
#import <WebKit/IFWebControllerPrivate.h>
#import <WebKit/IFWebDataSource.h>
#import <WebKit/IFWebDataSourcePrivate.h>
@@ -85,7 +86,7 @@
// Don't retain download data
if([dataSource contentPolicy] != IFContentPolicySave &&
- [dataSource contentPolicy] != IFContentPolicyOpenExternally){
+ [dataSource contentPolicy] != IFContentPolicySaveAndOpenExternally){
[dataSource _setResourceData:data];
}
@@ -115,6 +116,7 @@
- (void)IFURLHandle:(IFURLHandle *)sender resourceDataDidBecomeAvailable:(NSData *)incomingData
{
+ IFWebController *controller = [dataSource controller];
NSString *contentType = [sender contentType];
IFWebFrame *frame = [dataSource webFrame];
IFWebView *view = [frame webView];
@@ -132,12 +134,12 @@
// and there is no extension, this is text/html
if([contentType isEqualToString:IFDefaultMIMEType] && [[[url path] pathExtension] isEqualToString:@""])
contentType = @"text/html";
-
- WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD, "main content type: %s", DEBUG_OBJECT(contentType));
[dataSource _setContentType:contentType];
[dataSource _setEncoding:[sender characterSet]];
- [[dataSource _locationChangeHandler] requestContentPolicyForMIMEType:contentType dataSource:dataSource];
+ [[controller policyHandler] requestContentPolicyForMIMEType:contentType dataSource:dataSource];
+
+ WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD, "main content type: %s", DEBUG_OBJECT(contentType));
}
contentPolicy = [dataSource contentPolicy];
@@ -161,7 +163,7 @@
[[dataSource representation] receivedData:data withDataSource:dataSource];
[[view documentView] dataSourceUpdated:dataSource];
- }else if(contentPolicy == IFContentPolicySave || contentPolicy == IFContentPolicyOpenExternally){
+ }else if(contentPolicy == IFContentPolicySave || contentPolicy == IFContentPolicySaveAndOpenExternally){
if(!downloadHandler){
[frame->_private setProvisionalDataSource:nil];
[[dataSource _locationChangeHandler] locationChangeDone:nil forDataSource:dataSource];
diff --git a/WebKit/WebView.subproj/WebPolicyDelegate.h b/WebKit/WebView.subproj/WebPolicyDelegate.h
new file mode 100644
index 0000000..8d99688
--- /dev/null
+++ b/WebKit/WebView.subproj/WebPolicyDelegate.h
@@ -0,0 +1,70 @@
+/*
+ IFWebControllerPolicyHandler.h
+ Copyright 2002, Apple, Inc. All rights reserved.
+
+ Public header file.
+*/
+
+#include <Cocoa/Cocoa.h>
+
+/*
+ =============================================================================
+
+ =============================================================================
+*/
+
+typedef enum {
+ IFURLPolicyUseContentPolicy,
+ IFURLPolicyOpenExternally,
+ IFURLPolicyIgnore
+} IFURLPolicy;
+
+typedef enum {
+ IFFileURLPolicyUseContentPolicy,
+ IFFileURLPolicyOpenExternally,
+ IFFileURLPolicyIgnore
+} IFFileURLPolicy;
+
+typedef enum {
+ IFContentPolicyNone,
+ IFContentPolicyShow,
+ IFContentPolicySave,
+ IFContentPolicySaveAndOpenExternally,
+ IFContentPolicyIgnore
+} IFContentPolicy;
+
+ at protocol IFWebControllerPolicyHandler <NSObject>
+
+- (id <IFLocationChangeHandler>)provideLocationChangeHandlerForDataSource: (IFWebDataSource *)dataSource;
+
+// URLPolicyForURL: is used to determine what to do BEFORE a URL is loaded, i.e.
+// 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:.
+- (IFURLPolicy)URLPolicyForURL: (NSURL *)url;
+
+// We may have different errors that cause the the policy to be un-implementable, i.e.
+// launch services failure, etc.
+- (void)unableToImplementURLPolicyForURL: (NSURL *)url error: (IFError *)error;
+
+// Called when the response to URLPolicyForURL is IFURLPolicyUseContentPolicy and the URL is
+// a file URL. This allows clients to special-case WebKit's behavior for file URLs.
+- (IFFileURLPolicy)fileURLPolicyForMIMEType: (NSString *)type dataSource: (IFWebDataSource *)dataSource isDirectory: (BOOL)isDirectory;
+
+// Called when a IFFileURLPolicy could not be completed. This is usually caused by files not
+// existing or not readable.
+- (void)unableToImplementFileURLPolicy: (IFError *)error forDataSource: (IFWebDataSource *)dataSource;
+
+// Sent after locationChangeStarted.
+// Implementations typically call haveContentPolicy:forLocationChangeHandler: on IFWebController
+// after determining the appropriate policy, perhaps by presenting a non-blocking dialog to the user.
+- (void)requestContentPolicyForMIMEType: (NSString *)type dataSource: (IFWebDataSource *)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: (IFError *)error forDataSource: (IFWebDataSource *)dataSource;
+
+// Called when a plug-in for a certain mime type is not installed
+- (void)pluginNotFoundForMIMEType:(NSString *)mime pluginPageURL:(NSURL *)url;
+
+ at end
\ No newline at end of file
diff --git a/WebKit/WebView.subproj/WebView.h b/WebKit/WebView.subproj/WebView.h
index ce11b81..55832ee 100644
--- a/WebKit/WebView.subproj/WebView.h
+++ b/WebKit/WebView.subproj/WebView.h
@@ -9,6 +9,7 @@
#import <Foundation/Foundation.h>
#import <WebKit/IFLocationChangeHandler.h>
+#import <WebKit/IFWebControllerPolicyHandler.h>
/*
=============================================================================
@@ -70,38 +71,6 @@
/*
=============================================================================
- =============================================================================
-*/
-
-typedef enum {
- IFURLPolicyUseContentPolicy,
- IFURLPolicyOpenExternally,
- IFURLPolicyIgnore
-} IFURLPolicy;
-
-
- at protocol IFWebControllerPolicyHandler <NSObject>
-
-- (id <IFLocationChangeHandler>)provideLocationChangeHandlerForDataSource: (IFWebDataSource *)dataSource;
-
-// URLPolicyForURL: is used to determine what to do BEFORE a URL is loaded, i.e.
-// 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:.
-- (IFURLPolicy)URLPolicyForURL: (NSURL *)url;
-
-// We may have different errors that cause the the policy to be un-implementable, i.e.
-// launch services failure, etc.
-- (void)unableToImplementURLPolicyForURL: (NSURL *)url error: (IFError *)error;
-
-// Called when a plug-in for a certain mime type is not installed
-- (void)pluginNotFoundForMIMEType:(NSString *)mime pluginPageURL:(NSURL *)url;
-
- at end
-
-/*
- =============================================================================
-
A class that implements IFWindowContext provides window-related methods
that may be used by Javascript, plugins and other aspects of web pages.
diff --git a/WebKit/WebView.subproj/WebView.m b/WebKit/WebView.subproj/WebView.m
index 109eae0..cfb9428 100644
--- a/WebKit/WebView.subproj/WebView.m
+++ b/WebKit/WebView.subproj/WebView.m
@@ -14,10 +14,11 @@
#import <WebKit/IFWebFrame.h>
#import <WebKit/IFWebFramePrivate.h>
#import <WebKit/IFWebController.h>
+#import <WebKit/IFWebControllerPolicyHandler.h>
+#import <WebKit/IFWebKitErrors.h>
#import <WebKit/WebKitDebug.h>
#import <WebFoundation/WebFoundation.h>
-#import <WebFoundation/IFFileTypeMappings.h>
@implementation IFWebController
@@ -241,7 +242,9 @@
[webView _setDocumentView: documentView];
[documentView provisionalDataSourceChanged: dataSource];
}else{
- // return error with unableToImplementContentPolicy
+ IFError *error = [[IFError alloc] initWithErrorCode:IFErrorCodeCantShowMIMEType
+ inDomain:IFErrorCodeDomainWebKit failingURL: [dataSource inputURL]];
+ [[self policyHandler] unableToImplementContentPolicy:error forDataSource:dataSource];
}
}
}
@@ -277,11 +280,10 @@
}
+ (BOOL)canShowFile:(NSString *)path
-{
- NSString *MIMEType, *extension = [path pathExtension];
-
- MIMEType = [[IFFileTypeMappings sharedMappings] MIMETypeForExtension:extension];
+{
+ NSString *MIMEType;
+ MIMEType = [[self class] _MIMETypeForFile:path];
return [[self class] canShowMIMEType:MIMEType];
}
diff --git a/WebKit/WebView.subproj/WebViewPrivate.h b/WebKit/WebView.subproj/WebViewPrivate.h
index bc31c42..9ddce45 100644
--- a/WebKit/WebView.subproj/WebViewPrivate.h
+++ b/WebKit/WebView.subproj/WebViewPrivate.h
@@ -25,4 +25,5 @@
- (void)_mainReceivedError: (IFError *)error forResourceHandle: (IFURLHandle *)resourceHandle partialProgress: (IFLoadProgress *)progress fromDataSource: (IFWebDataSource *)dataSource;
- (void)_didStartLoading: (NSURL *)url;
- (void)_didStopLoading: (NSURL *)url;
++ (NSString *)_MIMETypeForFile: (NSString *)path;
@end
diff --git a/WebKit/WebView.subproj/WebViewPrivate.m b/WebKit/WebView.subproj/WebViewPrivate.m
index 2839b55..499de5a 100644
--- a/WebKit/WebView.subproj/WebViewPrivate.m
+++ b/WebKit/WebView.subproj/WebViewPrivate.m
@@ -14,6 +14,7 @@
#import <WebKit/WebKitDebug.h>
#import <WebFoundation/IFError.h>
+#import <WebFoundation/IFFileTypeMappings.h>
#import <WebFoundation/IFURLCacheLoaderConstants.h>
#import <WebFoundation/IFURLHandle.h>
@@ -124,7 +125,7 @@
fromDataSource: dataSource complete:isComplete];
if(isComplete){
- if(contentPolicy == IFContentPolicyOpenExternally || contentPolicy == IFContentPolicySave)
+ if(contentPolicy == IFContentPolicySaveAndOpenExternally || contentPolicy == IFContentPolicySave)
[dataSource _setPrimaryLoadComplete: YES];
}
@@ -204,4 +205,11 @@
[[IFStandardPanels sharedStandardPanels] _didStopLoadingURL:url inController:self];
}
++ (NSString *)_MIMETypeForFile: (NSString *)path
+{
+ NSString *extension = [path pathExtension];
+
+ return [[IFFileTypeMappings sharedMappings] MIMETypeForExtension:extension];
+}
+
@end
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list