[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:08:42 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 8cb045f85b263a52df67e156a1aa293134f7a4e7
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Apr 22 18:28:17 2002 +0000

    WebBrowser:
            * LocationChangeHandler.m:
            (-[LocationChangeHandler requestContentPolicyForMIMEType:]):
            Initial implementation of Alex's interaction with out content policy API.
            Simply made Alex show types that we handle inline and save types we don't
    
            * WebController.m:
            Removed some deprecated methods.
    
    WebKit:
            * MIME.subproj/IFMIMEHandler.h:
            * MIME.subproj/IFMIMEHandler.m:
            (+[IFMIMEHandler showableMIMETypes]):
            (+[IFMIMEHandler saveFileWithPath:andData:]):
            (+[IFMIMEHandler saveAndOpenFileWithPath:andData:]):
    
            Added the above factory methods.
    
            * WebView.subproj/IFBaseWebController.mm:
            (-[IFBaseWebController haveContentPolicy:andPath:forLocationChangeHandler:]):
    
            Save the content policy and download path on the datasource.
    
            * WebView.subproj/IFMainURLHandleClient.mm:
            (-[IFMainURLHandleClient IFURLHandleResourceDidCancelLoading:]):
            (-[IFMainURLHandleClient IFURLHandleResourceDidFinishLoading:data:]):
            (-[IFMainURLHandleClient IFURLHandle:resourceDataDidBecomeAvailable:]):
            (-[IFMainURLHandleClient IFURLHandle:resourceDidFailLoadingWithResult:]):
    
            Made IFMainURLHandleClient use our new content policy API rather than
            IFDownloadHandler.
    
            * WebView.subproj/IFWebController.h:
    
            Removed some deprecated methods.
    
            * WebView.subproj/IFWebDataSourcePrivate.h:
            * WebView.subproj/IFWebDataSourcePrivate.mm:
            (-[IFWebDataSource _downloadPath]):
            (-[IFWebDataSource _setDownloadPath:]):
            (-[IFWebDataSource _contentPolicy]):
            (-[IFWebDataSource _setContentPolicy:]):
    
            Added the above methods.
    
    WebCore:
            Added a new method to WCPluginDatabase allHandledMIMETypes.
            It returns an  array of the mime types that plug-ins handle.
    
            * kwq/WCPluginDatabase.h:
            * kwq/WCPluginDatabase.mm:
            (-[WCPluginDatabase allHandledMIMETypes]):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1058 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index 0606f1d..066ea45 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,12 @@
+2002-04-22  Chris Blumenberg  <cblu at apple.com>
+
+	Added a new method to WCPluginDatabase allHandledMIMETypes.
+	It returns an  array of the mime types that plug-ins handle.
+
+	* kwq/WCPluginDatabase.h:
+	* kwq/WCPluginDatabase.mm:
+	(-[WCPluginDatabase allHandledMIMETypes]):
+
 2002-04-20  Darin Adler  <darin at apple.com>
 
 	Problems loading iframes seemed to be due to NSURL objects that
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 0606f1d..066ea45 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,12 @@
+2002-04-22  Chris Blumenberg  <cblu at apple.com>
+
+	Added a new method to WCPluginDatabase allHandledMIMETypes.
+	It returns an  array of the mime types that plug-ins handle.
+
+	* kwq/WCPluginDatabase.h:
+	* kwq/WCPluginDatabase.mm:
+	(-[WCPluginDatabase allHandledMIMETypes]):
+
 2002-04-20  Darin Adler  <darin at apple.com>
 
 	Problems loading iframes seemed to be due to NSURL objects that
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 0606f1d..066ea45 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,12 @@
+2002-04-22  Chris Blumenberg  <cblu at apple.com>
+
+	Added a new method to WCPluginDatabase allHandledMIMETypes.
+	It returns an  array of the mime types that plug-ins handle.
+
+	* kwq/WCPluginDatabase.h:
+	* kwq/WCPluginDatabase.mm:
+	(-[WCPluginDatabase allHandledMIMETypes]):
+
 2002-04-20  Darin Adler  <darin at apple.com>
 
 	Problems loading iframes seemed to be due to NSURL objects that
diff --git a/WebCore/kwq/WCPluginDatabase.h b/WebCore/kwq/WCPluginDatabase.h
index 0443373..3255d0b 100644
--- a/WebCore/kwq/WCPluginDatabase.h
+++ b/WebCore/kwq/WCPluginDatabase.h
@@ -34,6 +34,7 @@
 - (WCPlugin *)getPluginForMimeType:(NSString *)mimeType;
 - (WCPlugin *)getPluginForExtension:(NSString *)extension;
 - (WCPlugin *)getPluginForFilename:(NSString *)filename;
+- (NSArray *) allHandledMIMETypes;
 - (NSArray *) plugins;
 
 @end
diff --git a/WebCore/kwq/WCPluginDatabase.mm b/WebCore/kwq/WCPluginDatabase.mm
index cd14e7c..44bc789 100644
--- a/WebCore/kwq/WCPluginDatabase.mm
+++ b/WebCore/kwq/WCPluginDatabase.mm
@@ -97,6 +97,24 @@ static WCPluginDatabase *__WCPluginDatabase = nil;
     return plugins;
 }
 
+- (NSArray *) allHandledMIMETypes
+{
+    NSMutableArray *allHandledMIMETypes;
+    WCPlugin *plugin;
+    NSArray *mimeArray;
+    uint i, n;
+        
+    allHandledMIMETypes = [NSMutableArray arrayWithCapacity:20];
+    for(i=0; i<[plugins count]; i++){
+        plugin = [plugins objectAtIndex:i];
+        mimeArray = [plugin mimeTypes];
+        for(n=0; n<[mimeArray count]; n++){
+            [allHandledMIMETypes addObject:[[mimeArray objectAtIndex:n] objectAtIndex:0]];
+        }
+    }
+    return allHandledMIMETypes;
+}
+
 @end
 
 NSArray *pluginLocations(void)
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index b07b3d7..1f53267 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,40 @@
+2002-04-22  Chris Blumenberg  <cblu at apple.com>
+
+	* MIME.subproj/IFMIMEHandler.h:
+	* MIME.subproj/IFMIMEHandler.m:
+	(+[IFMIMEHandler showableMIMETypes]):
+	(+[IFMIMEHandler saveFileWithPath:andData:]):
+	(+[IFMIMEHandler saveAndOpenFileWithPath:andData:]):
+
+	Added the above factory methods.
+
+	* WebView.subproj/IFBaseWebController.mm:
+	(-[IFBaseWebController haveContentPolicy:andPath:forLocationChangeHandler:]):
+	
+	Save the content policy and download path on the datasource.
+
+	* WebView.subproj/IFMainURLHandleClient.mm:
+	(-[IFMainURLHandleClient IFURLHandleResourceDidCancelLoading:]):
+	(-[IFMainURLHandleClient IFURLHandleResourceDidFinishLoading:data:]):
+	(-[IFMainURLHandleClient IFURLHandle:resourceDataDidBecomeAvailable:]):
+	(-[IFMainURLHandleClient IFURLHandle:resourceDidFailLoadingWithResult:]):
+	
+	Made IFMainURLHandleClient use our new content policy API rather than
+	IFDownloadHandler.
+	
+	* WebView.subproj/IFWebController.h:
+
+	Removed some deprecated methods.
+
+	* WebView.subproj/IFWebDataSourcePrivate.h:
+	* WebView.subproj/IFWebDataSourcePrivate.mm:
+	(-[IFWebDataSource _downloadPath]):
+	(-[IFWebDataSource _setDownloadPath:]):
+	(-[IFWebDataSource _contentPolicy]):
+	(-[IFWebDataSource _setContentPolicy:]):
+
+	Added the above methods.
+
 2002-04-22  Darin Adler  <darin at apple.com>
 
 	* Plugins.subproj/IFPluginView.mm:
diff --git a/WebKit/ChangeLog-2002-12-03 b/WebKit/ChangeLog-2002-12-03
index b07b3d7..1f53267 100644
--- a/WebKit/ChangeLog-2002-12-03
+++ b/WebKit/ChangeLog-2002-12-03
@@ -1,3 +1,40 @@
+2002-04-22  Chris Blumenberg  <cblu at apple.com>
+
+	* MIME.subproj/IFMIMEHandler.h:
+	* MIME.subproj/IFMIMEHandler.m:
+	(+[IFMIMEHandler showableMIMETypes]):
+	(+[IFMIMEHandler saveFileWithPath:andData:]):
+	(+[IFMIMEHandler saveAndOpenFileWithPath:andData:]):
+
+	Added the above factory methods.
+
+	* WebView.subproj/IFBaseWebController.mm:
+	(-[IFBaseWebController haveContentPolicy:andPath:forLocationChangeHandler:]):
+	
+	Save the content policy and download path on the datasource.
+
+	* WebView.subproj/IFMainURLHandleClient.mm:
+	(-[IFMainURLHandleClient IFURLHandleResourceDidCancelLoading:]):
+	(-[IFMainURLHandleClient IFURLHandleResourceDidFinishLoading:data:]):
+	(-[IFMainURLHandleClient IFURLHandle:resourceDataDidBecomeAvailable:]):
+	(-[IFMainURLHandleClient IFURLHandle:resourceDidFailLoadingWithResult:]):
+	
+	Made IFMainURLHandleClient use our new content policy API rather than
+	IFDownloadHandler.
+	
+	* WebView.subproj/IFWebController.h:
+
+	Removed some deprecated methods.
+
+	* WebView.subproj/IFWebDataSourcePrivate.h:
+	* WebView.subproj/IFWebDataSourcePrivate.mm:
+	(-[IFWebDataSource _downloadPath]):
+	(-[IFWebDataSource _setDownloadPath:]):
+	(-[IFWebDataSource _contentPolicy]):
+	(-[IFWebDataSource _setContentPolicy:]):
+
+	Added the above methods.
+
 2002-04-22  Darin Adler  <darin at apple.com>
 
 	* Plugins.subproj/IFPluginView.mm:
diff --git a/WebKit/MIME.subproj/IFMIMEHandler.h b/WebKit/MIME.subproj/IFMIMEHandler.h
index 1e37f93..158407b 100644
--- a/WebKit/MIME.subproj/IFMIMEHandler.h
+++ b/WebKit/MIME.subproj/IFMIMEHandler.h
@@ -32,6 +32,10 @@ typedef enum {
 initWithMIMEType gets called by [IFMIMEDatabase sharedMIMEDatabase] for at least every mime type that WebKit handles. We, at some point, might want to store IFMIMEHandler's for types that other application handle. I hope not though.
 */
 
++ (void) saveFileWithPath:(NSString *)path andData:(NSData *)data;
++ (void) saveAndOpenFileWithPath:(NSString *)path andData:(NSData *)data;
++ (NSArray *)showableMIMETypes;
+
 - initWithMIMEType:(NSString *)MIME handlerType:(IFMIMEHandlerType)hType handlerName:(NSString *)handler;
 
 // Accessor methods
@@ -39,4 +43,5 @@ initWithMIMEType gets called by [IFMIMEDatabase sharedMIMEDatabase] for at least
 - (NSString *)handlerName;
 - (IFMIMEHandlerType)handlerType;
 
+
 @end
diff --git a/WebKit/MIME.subproj/IFMIMEHandler.m b/WebKit/MIME.subproj/IFMIMEHandler.m
index 597402a..03427b1 100644
--- a/WebKit/MIME.subproj/IFMIMEHandler.m
+++ b/WebKit/MIME.subproj/IFMIMEHandler.m
@@ -6,11 +6,39 @@
 //  Copyright (c) 2002 Apple Computer Inc.. All rights reserved.
 //
 
-#import "IFMIMEHandler.h"
+#import <WebKit/IFMIMEHandler.h>
+#import <WebKit/WebKitDebug.h>
+#import <WCPluginDatabase.h>
 
+static NSArray *MIMETypes = nil;
 
 @implementation IFMIMEHandler
 
++ (NSArray *)showableMIMETypes
+{
+    if(!MIMETypes){
+        MIMETypes = [[NSArray arrayWithObjects:
+        @"text/plain",
+        @"text/html",
+    
+        //@"image/pict",
+        //@"application/postscript",
+        //@"image/x-quicktime",
+        //@"image/x-targa",
+        //@"image/x-sgi",
+        //@"image/x-rgb",
+        //@"image/x-macpaint",
+        //@"image/x-bmp",
+        //@"image/tiff",
+        //@"image/x-tiff",
+        @"image/png",
+        @"image/gif",
+        @"image/jpg",
+        @"image/jpeg", nil] arrayByAddingObjectsFromArray:[[WCPluginDatabase installedPlugins] allHandledMIMETypes]];
+        [MIMETypes retain];
+    }
+    return MIMETypes;
+}
 
 - initWithMIMEType:(NSString *)MIME handlerType:(IFMIMEHandlerType)hType handlerName:(NSString *)handler
 {
@@ -22,6 +50,32 @@
 }
 
 
++ (void) saveFileWithPath:(NSString *)path andData:(NSData *)data
+{
+    NSFileManager *fileManager;
+    
+    // FIXME: Should probably not replace existing file
+    // FIXME: Should report error if there is one
+    fileManager = [NSFileManager defaultManager];
+    [fileManager createFileAtPath:path contents:data attributes:nil];
+    WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD, "Download complete. Saved to: %s", [path cString]);
+    
+    // Send Finder notification
+    WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD, "Notifying Finder");
+    FNNotifyByPath([[path stringByDeletingLastPathComponent] cString], kFNDirectoryModifiedMessage, kNilOptions);
+}
+
++ (void) saveAndOpenFileWithPath:(NSString *)path andData:(NSData *)data
+{
+    CFURLRef pathURL;
+    
+    [IFMIMEHandler saveFileWithPath:path andData:data];
+    pathURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, (CFStringRef)path, kCFURLPOSIXPathStyle, FALSE);
+    WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD,"Opening: %s", [path cString]);
+    LSOpenCFURLRef(pathURL, NULL);
+    CFRelease(pathURL);
+}
+
 // Accessor methods
 - (NSString *)MIMEType
 {
diff --git a/WebKit/WebView.subproj/IFBaseWebController.mm b/WebKit/WebView.subproj/IFBaseWebController.mm
index eec8548..ff1af3c 100644
--- a/WebKit/WebView.subproj/IFBaseWebController.mm
+++ b/WebKit/WebView.subproj/IFBaseWebController.mm
@@ -239,21 +239,6 @@
     // Do nothing.  Subclasses typically override this method.
 }
 
-- (void) startedDownloadWithHandler:(IFDownloadHandler *)downloadHandler
-{
-    // Do nothing.  Subclasses typically override this method.
-}
-
-- (void) receivedProgress:(IFLoadProgress *)progress forDownloadHandler:(IFDownloadHandler *)downloadHandler
-{
-    // Do nothing.  Subclasses typically override this method.
-}
-
-- (void) receivedError:(IFError *)error forDownloadHandler:(IFDownloadHandler *)downloadHandler partialProgress: (IFLoadProgress *)progress
-{
-    // Do nothing.  Subclasses typically override this method.
-}
-
 - (id <IFLocationChangeHandler>)provideLocationChangeHandlerForFrame: (IFWebFrame *)frame andURL: (NSURL *)url
 {
     return nil;
@@ -271,6 +256,13 @@
 
 - (void)haveContentPolicy: (IFContentPolicy)policy andPath: (NSString *)path forLocationChangeHandler: (id <IFLocationChangeHandler>)handler
 {
+    IFWebDataSource *dataSource;
+    
+    dataSource = [_private->mainFrame provisionalDataSource];
+    if([dataSource _locationChangeHandler] == handler){
+        [dataSource _setContentPolicy:policy];
+        [dataSource _setDownloadPath:path];
+    }
 }
 
 @end
diff --git a/WebKit/WebView.subproj/IFMainURLHandleClient.mm b/WebKit/WebView.subproj/IFMainURLHandleClient.mm
index 68dee92..35c884f 100644
--- a/WebKit/WebView.subproj/IFMainURLHandleClient.mm
+++ b/WebKit/WebView.subproj/IFMainURLHandleClient.mm
@@ -62,12 +62,8 @@
     IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
     loadProgress->totalToLoad = -1;
     loadProgress->bytesSoFar = -1;
-    if(handlerType == IFMIMEHANDLERTYPE_APPLICATION){
-        [[dataSource controller] receivedProgress:loadProgress forDownloadHandler:downloadHandler];
-    }else{
-        [(IFBaseWebController *)[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress 
-            forResource: [[sender url] absoluteString] fromDataSource: dataSource];
-    }
+    [(IFBaseWebController *)[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress 
+        forResource: [[sender url] absoluteString] fromDataSource: dataSource];
     [loadProgress release];
 }
 
@@ -78,25 +74,28 @@
     IFContentHandler *contentHandler;
 
     WEBKITDEBUGLEVEL (WEBKIT_LOG_LOADING, "url = %s\n", [[[sender url] absoluteString] cString]);
-
-    if(handlerType == IFMIMEHANDLERTYPE_TEXT) {
-        contentHandler = [[IFContentHandler alloc] initWithMIMEHandler:mimeHandler URL:[sender url]];
-        fakeHTMLDocument = [contentHandler textHTMLDocumentBottom];
-        fakeHTMLDocumentBytes = [fakeHTMLDocument cString];
-        part->slotData(sender, (const char *)fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes));
-        [contentHandler release];
+    
+    if([dataSource _contentPolicy] == IFContentPolicyShow){
+        if(handlerType == IFMIMEHANDLERTYPE_TEXT) {
+            contentHandler = [[IFContentHandler alloc] initWithMIMEHandler:mimeHandler URL:[sender url]];
+            fakeHTMLDocument = [contentHandler textHTMLDocumentBottom];
+            fakeHTMLDocumentBytes = [fakeHTMLDocument cString];
+            part->slotData(sender, (const char *)fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes));
+            [contentHandler release];
+        }
     }
+    
+    else if([dataSource _contentPolicy] == IFContentPolicySave) 
+        [IFMIMEHandler saveFileWithPath:[dataSource _downloadPath] andData:[sender resourceData]];
+               
+    else if([dataSource _contentPolicy] == IFContentPolicyOpenExternally)
+        [IFMIMEHandler saveAndOpenFileWithPath:[dataSource _downloadPath] andData:[sender resourceData]];
 
     IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
     loadProgress->totalToLoad = [data length];
     loadProgress->bytesSoFar = [data length];
-    if(handlerType == IFMIMEHANDLERTYPE_APPLICATION){
-        [[dataSource controller] receivedProgress:loadProgress forDownloadHandler:downloadHandler];
-        [downloadHandler _finishedDownload];
-    }else{
-        [(IFBaseWebController *)[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress 
-            forResource: [[sender url] absoluteString] fromDataSource: dataSource];
-    }
+    [(IFBaseWebController *)[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress 
+        forResource: [[sender url] absoluteString] fromDataSource: dataSource];
     [loadProgress release];
 }
 
@@ -104,7 +103,6 @@
 {
     NSString *fakeHTMLDocument;
     const char *fakeHTMLDocumentBytes;
-    IFMIMEDatabase *mimeDatabase;
     IFContentHandler *contentHandler;
     
     WEBKITDEBUGLEVEL(WEBKIT_LOG_LOADING, "url = %s, data = %p, length %d\n", [[[sender url] absoluteString] cString], data, [data length]);
@@ -112,59 +110,56 @@
     // check the mime type
     if(!typeChecked){
         WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD, "Main URL's contentType: %s", [[sender contentType] cString]);
-        mimeDatabase = [IFMIMEDatabase sharedMIMEDatabase];
-        mimeHandler = [[mimeDatabase MIMEHandlerForMIMEType:[sender contentType]] retain];
+        [[dataSource _locationChangeHandler] requestContentPolicyForMIMEType:[sender contentType]];
+        mimeHandler = [[[IFMIMEDatabase sharedMIMEDatabase] MIMEHandlerForMIMEType:[sender contentType]] retain];
         handlerType = [mimeHandler handlerType];
         typeChecked = YES;
     }
     
-    // if it's html, send the data to the part
-    // FIXME: [sender contentType] still returns nil if from cache
-    if(handlerType == IFMIMEHANDLERTYPE_NIL || handlerType == IFMIMEHANDLERTYPE_HTML) {
-        part->slotData(sender, (const char *)[data bytes], [data length]);
-    }
-    
-    // for non-html documents, create html doc that embeds them
-    else if(handlerType == IFMIMEHANDLERTYPE_IMAGE  || 
-            handlerType == IFMIMEHANDLERTYPE_PLUGIN || 
-            handlerType == IFMIMEHANDLERTYPE_TEXT) {
-        if (!sentFakeDocForNonHTMLContentType) {
-            contentHandler = [[IFContentHandler alloc] initWithMIMEHandler:mimeHandler URL:[sender url]];
-            fakeHTMLDocument = [contentHandler HTMLDocument];
-            fakeHTMLDocumentBytes = [fakeHTMLDocument cString];
-            part->slotData(sender, (const char *)fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes));
-            [contentHandler release];
-            sentFakeDocForNonHTMLContentType = YES;
+    if([dataSource _contentPolicy] == IFContentPolicyShow){
+        // if it's html, send the data to the part
+        // FIXME: [sender contentType] still returns nil if from cache
+        if(handlerType == IFMIMEHANDLERTYPE_NIL || handlerType == IFMIMEHANDLERTYPE_HTML) {
+            part->slotData(sender, (const char *)[data bytes], [data length]);
         }
         
-        // for text documents, the incoming data is part of the main page
-        if(handlerType == IFMIMEHANDLERTYPE_TEXT){
-            part->slotData(sender, (const char *)[data bytes], [data length]);
+        // for non-html documents, create html doc that embeds them
+        else if(handlerType == IFMIMEHANDLERTYPE_IMAGE  || 
+                handlerType == IFMIMEHANDLERTYPE_PLUGIN || 
+                handlerType == IFMIMEHANDLERTYPE_TEXT) {
+            if (!sentFakeDocForNonHTMLContentType) {
+                contentHandler = [[IFContentHandler alloc] initWithMIMEHandler:mimeHandler URL:[sender url]];
+                fakeHTMLDocument = [contentHandler HTMLDocument];
+                fakeHTMLDocumentBytes = [fakeHTMLDocument cString];
+                part->slotData(sender, (const char *)fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes));
+                [contentHandler release];
+                sentFakeDocForNonHTMLContentType = YES;
+            }
+            
+            // for text documents, the incoming data is part of the main page
+            if(handlerType == IFMIMEHANDLERTYPE_TEXT){
+                part->slotData(sender, (const char *)[data bytes], [data length]);
+            }
         }
-    }
-
-    // downloaded file
-    else if(handlerType == IFMIMEHANDLERTYPE_APPLICATION){
-        if(!downloadStarted){
-            downloadHandler = [[IFDownloadHandler alloc] _initWithURLHandle:sender mimeHandler:mimeHandler];
-            [[dataSource _locationChangeHandler] downloadingWithHandler:downloadHandler];
-            downloadStarted = YES;
+    
+        else if(handlerType == IFMIMEHANDLERTYPE_APPLICATION){
+            // can't show a type that we don't handle
+            [[dataSource _locationChangeHandler] unableToImplementContentPolicy:0];
         }
-        [downloadHandler _receivedData:data];
     }
-
+    
+    else if([dataSource _contentPolicy] == IFContentPolicySave || 
+            [dataSource _contentPolicy] == IFContentPolicyOpenExternally){
+        
+    }
+    
     // update progress
 
     IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
     loadProgress->totalToLoad = [sender contentLength];
     loadProgress->bytesSoFar = [sender contentLengthReceived];
-    if(handlerType == IFMIMEHANDLERTYPE_APPLICATION){
-        [[dataSource controller] receivedProgress:loadProgress forDownloadHandler:downloadHandler];
-        WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD, "Download progress: %d of %d", loadProgress->bytesSoFar, loadProgress->totalToLoad);
-    }else{
-        [(IFBaseWebController *)[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress 
-            forResource: [[sender url] absoluteString] fromDataSource: dataSource];
-    }
+    [(IFBaseWebController *)[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress 
+        forResource: [[sender url] absoluteString] fromDataSource: dataSource];
     [loadProgress release];
 }
 
@@ -176,13 +171,7 @@
     loadProgress->totalToLoad = [sender contentLength];
     loadProgress->bytesSoFar = [sender contentLengthReceived];
 
-    if(handlerType == IFMIMEHANDLERTYPE_APPLICATION){
-        [[dataSource controller] receivedError: result forDownloadHandler:downloadHandler 
-            partialProgress: loadProgress];
-    }else{
-        [(IFBaseWebController *)[dataSource controller] _mainReceivedError: result forResource: [[sender url] absoluteString] 
-            partialProgress: loadProgress fromDataSource: dataSource];
-    }
+    [(IFBaseWebController *)[dataSource controller] _mainReceivedError: result forResource: [[sender url] absoluteString] 	partialProgress: loadProgress fromDataSource: dataSource];
 }
 
 - (void)IFURLHandle:(IFURLHandle *)sender didRedirectToURL:(NSURL *)url
diff --git a/WebKit/WebView.subproj/IFWebController.h b/WebKit/WebView.subproj/IFWebController.h
index bcced61..8ddbf13 100644
--- a/WebKit/WebView.subproj/IFWebController.h
+++ b/WebKit/WebView.subproj/IFWebController.h
@@ -60,16 +60,6 @@
 
 @end
 
- at protocol IFDownloadProgressHandler
-
-// Called when progress of a download has been made
-- (void) receivedProgress:(IFLoadProgress *)progress forDownloadHandler:(IFDownloadHandler *)downloadHandler;
-
-// Called when the download has had an error
-- (void) receivedError:(IFError *)error forDownloadHandler:(IFDownloadHandler *)downloadHandler partialProgress: (IFLoadProgress *)progress;
-
- at end
-
 /*
    ============================================================================= 
 
@@ -107,7 +97,7 @@ typedef enum {
     IFURLPolicyIgnore
 } IFURLPolicy;
 
- at protocol IFWebController <IFResourceProgressHandler, IFDownloadProgressHandler, IFScriptContextHandler>
+ at protocol IFWebController <IFResourceProgressHandler, IFScriptContextHandler>
 
 // Called when a data source needs to create a frame.  This method encapsulates the
 // specifics of creating and initializaing a view of the appropriate class.
diff --git a/WebKit/WebView.subproj/IFWebDataSourcePrivate.h b/WebKit/WebView.subproj/IFWebDataSourcePrivate.h
index 2a918ec..4ac09fe 100644
--- a/WebKit/WebView.subproj/IFWebDataSourcePrivate.h
+++ b/WebKit/WebView.subproj/IFWebDataSourcePrivate.h
@@ -7,6 +7,7 @@
 */
 
 #import <WebKit/IFWebDataSource.h>
+#import <WebKit/IFLocationChangeHandler.h>
 
 class KHTMLPart;
 
@@ -50,11 +51,13 @@ class KHTMLPart;
     
     BOOL stopping;
     
-    NSString *pageTitle;
+    NSString *pageTitle, *downloadPath;
     
     // The location change handler for this data source.
     id <IFLocationChangeHandler>locationChangeHandler;
 
+    IFContentPolicy contentPolicy;
+
     BOOL loading; // self and controller are retained while loading
 }
 
@@ -81,4 +84,8 @@ class KHTMLPart;
 
 - (id <IFLocationChangeHandler>)_locationChangeHandler;
 - (void)_setLocationChangeHandler: (id <IFLocationChangeHandler>)l;
+- (NSString *)_downloadPath;
+- (void) _setDownloadPath:(NSString *)path;
+- (IFContentPolicy) _contentPolicy;
+- (void) _setContentPolicy:(IFContentPolicy)policy;
 @end
diff --git a/WebKit/WebView.subproj/IFWebDataSourcePrivate.mm b/WebKit/WebView.subproj/IFWebDataSourcePrivate.mm
index 23de289..dbf1f60 100644
--- a/WebKit/WebView.subproj/IFWebDataSourcePrivate.mm
+++ b/WebKit/WebView.subproj/IFWebDataSourcePrivate.mm
@@ -266,4 +266,25 @@
     _private->locationChangeHandler = l;
 }
 
+- (NSString *)_downloadPath
+{
+    return _private->downloadPath;
+}
+
+- (void) _setDownloadPath:(NSString *)path
+{
+    [_private->downloadPath release];
+    _private->downloadPath = [path retain];
+}
+
+- (IFContentPolicy) _contentPolicy
+{
+    return _private->contentPolicy;
+}
+
+- (void) _setContentPolicy:(IFContentPolicy)policy
+{
+    _private->contentPolicy = policy;
+}
+
 @end
diff --git a/WebKit/WebView.subproj/WebController.h b/WebKit/WebView.subproj/WebController.h
index bcced61..8ddbf13 100644
--- a/WebKit/WebView.subproj/WebController.h
+++ b/WebKit/WebView.subproj/WebController.h
@@ -60,16 +60,6 @@
 
 @end
 
- at protocol IFDownloadProgressHandler
-
-// Called when progress of a download has been made
-- (void) receivedProgress:(IFLoadProgress *)progress forDownloadHandler:(IFDownloadHandler *)downloadHandler;
-
-// Called when the download has had an error
-- (void) receivedError:(IFError *)error forDownloadHandler:(IFDownloadHandler *)downloadHandler partialProgress: (IFLoadProgress *)progress;
-
- at end
-
 /*
    ============================================================================= 
 
@@ -107,7 +97,7 @@ typedef enum {
     IFURLPolicyIgnore
 } IFURLPolicy;
 
- at protocol IFWebController <IFResourceProgressHandler, IFDownloadProgressHandler, IFScriptContextHandler>
+ at protocol IFWebController <IFResourceProgressHandler, IFScriptContextHandler>
 
 // Called when a data source needs to create a frame.  This method encapsulates the
 // specifics of creating and initializaing a view of the appropriate class.
diff --git a/WebKit/WebView.subproj/WebDataSourcePrivate.h b/WebKit/WebView.subproj/WebDataSourcePrivate.h
index 2a918ec..4ac09fe 100644
--- a/WebKit/WebView.subproj/WebDataSourcePrivate.h
+++ b/WebKit/WebView.subproj/WebDataSourcePrivate.h
@@ -7,6 +7,7 @@
 */
 
 #import <WebKit/IFWebDataSource.h>
+#import <WebKit/IFLocationChangeHandler.h>
 
 class KHTMLPart;
 
@@ -50,11 +51,13 @@ class KHTMLPart;
     
     BOOL stopping;
     
-    NSString *pageTitle;
+    NSString *pageTitle, *downloadPath;
     
     // The location change handler for this data source.
     id <IFLocationChangeHandler>locationChangeHandler;
 
+    IFContentPolicy contentPolicy;
+
     BOOL loading; // self and controller are retained while loading
 }
 
@@ -81,4 +84,8 @@ class KHTMLPart;
 
 - (id <IFLocationChangeHandler>)_locationChangeHandler;
 - (void)_setLocationChangeHandler: (id <IFLocationChangeHandler>)l;
+- (NSString *)_downloadPath;
+- (void) _setDownloadPath:(NSString *)path;
+- (IFContentPolicy) _contentPolicy;
+- (void) _setContentPolicy:(IFContentPolicy)policy;
 @end
diff --git a/WebKit/WebView.subproj/WebDataSourcePrivate.m b/WebKit/WebView.subproj/WebDataSourcePrivate.m
index 23de289..dbf1f60 100644
--- a/WebKit/WebView.subproj/WebDataSourcePrivate.m
+++ b/WebKit/WebView.subproj/WebDataSourcePrivate.m
@@ -266,4 +266,25 @@
     _private->locationChangeHandler = l;
 }
 
+- (NSString *)_downloadPath
+{
+    return _private->downloadPath;
+}
+
+- (void) _setDownloadPath:(NSString *)path
+{
+    [_private->downloadPath release];
+    _private->downloadPath = [path retain];
+}
+
+- (IFContentPolicy) _contentPolicy
+{
+    return _private->contentPolicy;
+}
+
+- (void) _setContentPolicy:(IFContentPolicy)policy
+{
+    _private->contentPolicy = policy;
+}
+
 @end
diff --git a/WebKit/WebView.subproj/WebMainResourceClient.m b/WebKit/WebView.subproj/WebMainResourceClient.m
index 68dee92..35c884f 100644
--- a/WebKit/WebView.subproj/WebMainResourceClient.m
+++ b/WebKit/WebView.subproj/WebMainResourceClient.m
@@ -62,12 +62,8 @@
     IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
     loadProgress->totalToLoad = -1;
     loadProgress->bytesSoFar = -1;
-    if(handlerType == IFMIMEHANDLERTYPE_APPLICATION){
-        [[dataSource controller] receivedProgress:loadProgress forDownloadHandler:downloadHandler];
-    }else{
-        [(IFBaseWebController *)[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress 
-            forResource: [[sender url] absoluteString] fromDataSource: dataSource];
-    }
+    [(IFBaseWebController *)[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress 
+        forResource: [[sender url] absoluteString] fromDataSource: dataSource];
     [loadProgress release];
 }
 
@@ -78,25 +74,28 @@
     IFContentHandler *contentHandler;
 
     WEBKITDEBUGLEVEL (WEBKIT_LOG_LOADING, "url = %s\n", [[[sender url] absoluteString] cString]);
-
-    if(handlerType == IFMIMEHANDLERTYPE_TEXT) {
-        contentHandler = [[IFContentHandler alloc] initWithMIMEHandler:mimeHandler URL:[sender url]];
-        fakeHTMLDocument = [contentHandler textHTMLDocumentBottom];
-        fakeHTMLDocumentBytes = [fakeHTMLDocument cString];
-        part->slotData(sender, (const char *)fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes));
-        [contentHandler release];
+    
+    if([dataSource _contentPolicy] == IFContentPolicyShow){
+        if(handlerType == IFMIMEHANDLERTYPE_TEXT) {
+            contentHandler = [[IFContentHandler alloc] initWithMIMEHandler:mimeHandler URL:[sender url]];
+            fakeHTMLDocument = [contentHandler textHTMLDocumentBottom];
+            fakeHTMLDocumentBytes = [fakeHTMLDocument cString];
+            part->slotData(sender, (const char *)fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes));
+            [contentHandler release];
+        }
     }
+    
+    else if([dataSource _contentPolicy] == IFContentPolicySave) 
+        [IFMIMEHandler saveFileWithPath:[dataSource _downloadPath] andData:[sender resourceData]];
+               
+    else if([dataSource _contentPolicy] == IFContentPolicyOpenExternally)
+        [IFMIMEHandler saveAndOpenFileWithPath:[dataSource _downloadPath] andData:[sender resourceData]];
 
     IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
     loadProgress->totalToLoad = [data length];
     loadProgress->bytesSoFar = [data length];
-    if(handlerType == IFMIMEHANDLERTYPE_APPLICATION){
-        [[dataSource controller] receivedProgress:loadProgress forDownloadHandler:downloadHandler];
-        [downloadHandler _finishedDownload];
-    }else{
-        [(IFBaseWebController *)[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress 
-            forResource: [[sender url] absoluteString] fromDataSource: dataSource];
-    }
+    [(IFBaseWebController *)[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress 
+        forResource: [[sender url] absoluteString] fromDataSource: dataSource];
     [loadProgress release];
 }
 
@@ -104,7 +103,6 @@
 {
     NSString *fakeHTMLDocument;
     const char *fakeHTMLDocumentBytes;
-    IFMIMEDatabase *mimeDatabase;
     IFContentHandler *contentHandler;
     
     WEBKITDEBUGLEVEL(WEBKIT_LOG_LOADING, "url = %s, data = %p, length %d\n", [[[sender url] absoluteString] cString], data, [data length]);
@@ -112,59 +110,56 @@
     // check the mime type
     if(!typeChecked){
         WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD, "Main URL's contentType: %s", [[sender contentType] cString]);
-        mimeDatabase = [IFMIMEDatabase sharedMIMEDatabase];
-        mimeHandler = [[mimeDatabase MIMEHandlerForMIMEType:[sender contentType]] retain];
+        [[dataSource _locationChangeHandler] requestContentPolicyForMIMEType:[sender contentType]];
+        mimeHandler = [[[IFMIMEDatabase sharedMIMEDatabase] MIMEHandlerForMIMEType:[sender contentType]] retain];
         handlerType = [mimeHandler handlerType];
         typeChecked = YES;
     }
     
-    // if it's html, send the data to the part
-    // FIXME: [sender contentType] still returns nil if from cache
-    if(handlerType == IFMIMEHANDLERTYPE_NIL || handlerType == IFMIMEHANDLERTYPE_HTML) {
-        part->slotData(sender, (const char *)[data bytes], [data length]);
-    }
-    
-    // for non-html documents, create html doc that embeds them
-    else if(handlerType == IFMIMEHANDLERTYPE_IMAGE  || 
-            handlerType == IFMIMEHANDLERTYPE_PLUGIN || 
-            handlerType == IFMIMEHANDLERTYPE_TEXT) {
-        if (!sentFakeDocForNonHTMLContentType) {
-            contentHandler = [[IFContentHandler alloc] initWithMIMEHandler:mimeHandler URL:[sender url]];
-            fakeHTMLDocument = [contentHandler HTMLDocument];
-            fakeHTMLDocumentBytes = [fakeHTMLDocument cString];
-            part->slotData(sender, (const char *)fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes));
-            [contentHandler release];
-            sentFakeDocForNonHTMLContentType = YES;
+    if([dataSource _contentPolicy] == IFContentPolicyShow){
+        // if it's html, send the data to the part
+        // FIXME: [sender contentType] still returns nil if from cache
+        if(handlerType == IFMIMEHANDLERTYPE_NIL || handlerType == IFMIMEHANDLERTYPE_HTML) {
+            part->slotData(sender, (const char *)[data bytes], [data length]);
         }
         
-        // for text documents, the incoming data is part of the main page
-        if(handlerType == IFMIMEHANDLERTYPE_TEXT){
-            part->slotData(sender, (const char *)[data bytes], [data length]);
+        // for non-html documents, create html doc that embeds them
+        else if(handlerType == IFMIMEHANDLERTYPE_IMAGE  || 
+                handlerType == IFMIMEHANDLERTYPE_PLUGIN || 
+                handlerType == IFMIMEHANDLERTYPE_TEXT) {
+            if (!sentFakeDocForNonHTMLContentType) {
+                contentHandler = [[IFContentHandler alloc] initWithMIMEHandler:mimeHandler URL:[sender url]];
+                fakeHTMLDocument = [contentHandler HTMLDocument];
+                fakeHTMLDocumentBytes = [fakeHTMLDocument cString];
+                part->slotData(sender, (const char *)fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes));
+                [contentHandler release];
+                sentFakeDocForNonHTMLContentType = YES;
+            }
+            
+            // for text documents, the incoming data is part of the main page
+            if(handlerType == IFMIMEHANDLERTYPE_TEXT){
+                part->slotData(sender, (const char *)[data bytes], [data length]);
+            }
         }
-    }
-
-    // downloaded file
-    else if(handlerType == IFMIMEHANDLERTYPE_APPLICATION){
-        if(!downloadStarted){
-            downloadHandler = [[IFDownloadHandler alloc] _initWithURLHandle:sender mimeHandler:mimeHandler];
-            [[dataSource _locationChangeHandler] downloadingWithHandler:downloadHandler];
-            downloadStarted = YES;
+    
+        else if(handlerType == IFMIMEHANDLERTYPE_APPLICATION){
+            // can't show a type that we don't handle
+            [[dataSource _locationChangeHandler] unableToImplementContentPolicy:0];
         }
-        [downloadHandler _receivedData:data];
     }
-
+    
+    else if([dataSource _contentPolicy] == IFContentPolicySave || 
+            [dataSource _contentPolicy] == IFContentPolicyOpenExternally){
+        
+    }
+    
     // update progress
 
     IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
     loadProgress->totalToLoad = [sender contentLength];
     loadProgress->bytesSoFar = [sender contentLengthReceived];
-    if(handlerType == IFMIMEHANDLERTYPE_APPLICATION){
-        [[dataSource controller] receivedProgress:loadProgress forDownloadHandler:downloadHandler];
-        WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD, "Download progress: %d of %d", loadProgress->bytesSoFar, loadProgress->totalToLoad);
-    }else{
-        [(IFBaseWebController *)[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress 
-            forResource: [[sender url] absoluteString] fromDataSource: dataSource];
-    }
+    [(IFBaseWebController *)[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress 
+        forResource: [[sender url] absoluteString] fromDataSource: dataSource];
     [loadProgress release];
 }
 
@@ -176,13 +171,7 @@
     loadProgress->totalToLoad = [sender contentLength];
     loadProgress->bytesSoFar = [sender contentLengthReceived];
 
-    if(handlerType == IFMIMEHANDLERTYPE_APPLICATION){
-        [[dataSource controller] receivedError: result forDownloadHandler:downloadHandler 
-            partialProgress: loadProgress];
-    }else{
-        [(IFBaseWebController *)[dataSource controller] _mainReceivedError: result forResource: [[sender url] absoluteString] 
-            partialProgress: loadProgress fromDataSource: dataSource];
-    }
+    [(IFBaseWebController *)[dataSource controller] _mainReceivedError: result forResource: [[sender url] absoluteString] 	partialProgress: loadProgress fromDataSource: dataSource];
 }
 
 - (void)IFURLHandle:(IFURLHandle *)sender didRedirectToURL:(NSURL *)url
diff --git a/WebKit/WebView.subproj/WebMainResourceLoader.m b/WebKit/WebView.subproj/WebMainResourceLoader.m
index 68dee92..35c884f 100644
--- a/WebKit/WebView.subproj/WebMainResourceLoader.m
+++ b/WebKit/WebView.subproj/WebMainResourceLoader.m
@@ -62,12 +62,8 @@
     IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
     loadProgress->totalToLoad = -1;
     loadProgress->bytesSoFar = -1;
-    if(handlerType == IFMIMEHANDLERTYPE_APPLICATION){
-        [[dataSource controller] receivedProgress:loadProgress forDownloadHandler:downloadHandler];
-    }else{
-        [(IFBaseWebController *)[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress 
-            forResource: [[sender url] absoluteString] fromDataSource: dataSource];
-    }
+    [(IFBaseWebController *)[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress 
+        forResource: [[sender url] absoluteString] fromDataSource: dataSource];
     [loadProgress release];
 }
 
@@ -78,25 +74,28 @@
     IFContentHandler *contentHandler;
 
     WEBKITDEBUGLEVEL (WEBKIT_LOG_LOADING, "url = %s\n", [[[sender url] absoluteString] cString]);
-
-    if(handlerType == IFMIMEHANDLERTYPE_TEXT) {
-        contentHandler = [[IFContentHandler alloc] initWithMIMEHandler:mimeHandler URL:[sender url]];
-        fakeHTMLDocument = [contentHandler textHTMLDocumentBottom];
-        fakeHTMLDocumentBytes = [fakeHTMLDocument cString];
-        part->slotData(sender, (const char *)fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes));
-        [contentHandler release];
+    
+    if([dataSource _contentPolicy] == IFContentPolicyShow){
+        if(handlerType == IFMIMEHANDLERTYPE_TEXT) {
+            contentHandler = [[IFContentHandler alloc] initWithMIMEHandler:mimeHandler URL:[sender url]];
+            fakeHTMLDocument = [contentHandler textHTMLDocumentBottom];
+            fakeHTMLDocumentBytes = [fakeHTMLDocument cString];
+            part->slotData(sender, (const char *)fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes));
+            [contentHandler release];
+        }
     }
+    
+    else if([dataSource _contentPolicy] == IFContentPolicySave) 
+        [IFMIMEHandler saveFileWithPath:[dataSource _downloadPath] andData:[sender resourceData]];
+               
+    else if([dataSource _contentPolicy] == IFContentPolicyOpenExternally)
+        [IFMIMEHandler saveAndOpenFileWithPath:[dataSource _downloadPath] andData:[sender resourceData]];
 
     IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
     loadProgress->totalToLoad = [data length];
     loadProgress->bytesSoFar = [data length];
-    if(handlerType == IFMIMEHANDLERTYPE_APPLICATION){
-        [[dataSource controller] receivedProgress:loadProgress forDownloadHandler:downloadHandler];
-        [downloadHandler _finishedDownload];
-    }else{
-        [(IFBaseWebController *)[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress 
-            forResource: [[sender url] absoluteString] fromDataSource: dataSource];
-    }
+    [(IFBaseWebController *)[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress 
+        forResource: [[sender url] absoluteString] fromDataSource: dataSource];
     [loadProgress release];
 }
 
@@ -104,7 +103,6 @@
 {
     NSString *fakeHTMLDocument;
     const char *fakeHTMLDocumentBytes;
-    IFMIMEDatabase *mimeDatabase;
     IFContentHandler *contentHandler;
     
     WEBKITDEBUGLEVEL(WEBKIT_LOG_LOADING, "url = %s, data = %p, length %d\n", [[[sender url] absoluteString] cString], data, [data length]);
@@ -112,59 +110,56 @@
     // check the mime type
     if(!typeChecked){
         WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD, "Main URL's contentType: %s", [[sender contentType] cString]);
-        mimeDatabase = [IFMIMEDatabase sharedMIMEDatabase];
-        mimeHandler = [[mimeDatabase MIMEHandlerForMIMEType:[sender contentType]] retain];
+        [[dataSource _locationChangeHandler] requestContentPolicyForMIMEType:[sender contentType]];
+        mimeHandler = [[[IFMIMEDatabase sharedMIMEDatabase] MIMEHandlerForMIMEType:[sender contentType]] retain];
         handlerType = [mimeHandler handlerType];
         typeChecked = YES;
     }
     
-    // if it's html, send the data to the part
-    // FIXME: [sender contentType] still returns nil if from cache
-    if(handlerType == IFMIMEHANDLERTYPE_NIL || handlerType == IFMIMEHANDLERTYPE_HTML) {
-        part->slotData(sender, (const char *)[data bytes], [data length]);
-    }
-    
-    // for non-html documents, create html doc that embeds them
-    else if(handlerType == IFMIMEHANDLERTYPE_IMAGE  || 
-            handlerType == IFMIMEHANDLERTYPE_PLUGIN || 
-            handlerType == IFMIMEHANDLERTYPE_TEXT) {
-        if (!sentFakeDocForNonHTMLContentType) {
-            contentHandler = [[IFContentHandler alloc] initWithMIMEHandler:mimeHandler URL:[sender url]];
-            fakeHTMLDocument = [contentHandler HTMLDocument];
-            fakeHTMLDocumentBytes = [fakeHTMLDocument cString];
-            part->slotData(sender, (const char *)fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes));
-            [contentHandler release];
-            sentFakeDocForNonHTMLContentType = YES;
+    if([dataSource _contentPolicy] == IFContentPolicyShow){
+        // if it's html, send the data to the part
+        // FIXME: [sender contentType] still returns nil if from cache
+        if(handlerType == IFMIMEHANDLERTYPE_NIL || handlerType == IFMIMEHANDLERTYPE_HTML) {
+            part->slotData(sender, (const char *)[data bytes], [data length]);
         }
         
-        // for text documents, the incoming data is part of the main page
-        if(handlerType == IFMIMEHANDLERTYPE_TEXT){
-            part->slotData(sender, (const char *)[data bytes], [data length]);
+        // for non-html documents, create html doc that embeds them
+        else if(handlerType == IFMIMEHANDLERTYPE_IMAGE  || 
+                handlerType == IFMIMEHANDLERTYPE_PLUGIN || 
+                handlerType == IFMIMEHANDLERTYPE_TEXT) {
+            if (!sentFakeDocForNonHTMLContentType) {
+                contentHandler = [[IFContentHandler alloc] initWithMIMEHandler:mimeHandler URL:[sender url]];
+                fakeHTMLDocument = [contentHandler HTMLDocument];
+                fakeHTMLDocumentBytes = [fakeHTMLDocument cString];
+                part->slotData(sender, (const char *)fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes));
+                [contentHandler release];
+                sentFakeDocForNonHTMLContentType = YES;
+            }
+            
+            // for text documents, the incoming data is part of the main page
+            if(handlerType == IFMIMEHANDLERTYPE_TEXT){
+                part->slotData(sender, (const char *)[data bytes], [data length]);
+            }
         }
-    }
-
-    // downloaded file
-    else if(handlerType == IFMIMEHANDLERTYPE_APPLICATION){
-        if(!downloadStarted){
-            downloadHandler = [[IFDownloadHandler alloc] _initWithURLHandle:sender mimeHandler:mimeHandler];
-            [[dataSource _locationChangeHandler] downloadingWithHandler:downloadHandler];
-            downloadStarted = YES;
+    
+        else if(handlerType == IFMIMEHANDLERTYPE_APPLICATION){
+            // can't show a type that we don't handle
+            [[dataSource _locationChangeHandler] unableToImplementContentPolicy:0];
         }
-        [downloadHandler _receivedData:data];
     }
-
+    
+    else if([dataSource _contentPolicy] == IFContentPolicySave || 
+            [dataSource _contentPolicy] == IFContentPolicyOpenExternally){
+        
+    }
+    
     // update progress
 
     IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
     loadProgress->totalToLoad = [sender contentLength];
     loadProgress->bytesSoFar = [sender contentLengthReceived];
-    if(handlerType == IFMIMEHANDLERTYPE_APPLICATION){
-        [[dataSource controller] receivedProgress:loadProgress forDownloadHandler:downloadHandler];
-        WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD, "Download progress: %d of %d", loadProgress->bytesSoFar, loadProgress->totalToLoad);
-    }else{
-        [(IFBaseWebController *)[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress 
-            forResource: [[sender url] absoluteString] fromDataSource: dataSource];
-    }
+    [(IFBaseWebController *)[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress 
+        forResource: [[sender url] absoluteString] fromDataSource: dataSource];
     [loadProgress release];
 }
 
@@ -176,13 +171,7 @@
     loadProgress->totalToLoad = [sender contentLength];
     loadProgress->bytesSoFar = [sender contentLengthReceived];
 
-    if(handlerType == IFMIMEHANDLERTYPE_APPLICATION){
-        [[dataSource controller] receivedError: result forDownloadHandler:downloadHandler 
-            partialProgress: loadProgress];
-    }else{
-        [(IFBaseWebController *)[dataSource controller] _mainReceivedError: result forResource: [[sender url] absoluteString] 
-            partialProgress: loadProgress fromDataSource: dataSource];
-    }
+    [(IFBaseWebController *)[dataSource controller] _mainReceivedError: result forResource: [[sender url] absoluteString] 	partialProgress: loadProgress fromDataSource: dataSource];
 }
 
 - (void)IFURLHandle:(IFURLHandle *)sender didRedirectToURL:(NSURL *)url
diff --git a/WebKit/WebView.subproj/WebView.h b/WebKit/WebView.subproj/WebView.h
index bcced61..8ddbf13 100644
--- a/WebKit/WebView.subproj/WebView.h
+++ b/WebKit/WebView.subproj/WebView.h
@@ -60,16 +60,6 @@
 
 @end
 
- at protocol IFDownloadProgressHandler
-
-// Called when progress of a download has been made
-- (void) receivedProgress:(IFLoadProgress *)progress forDownloadHandler:(IFDownloadHandler *)downloadHandler;
-
-// Called when the download has had an error
-- (void) receivedError:(IFError *)error forDownloadHandler:(IFDownloadHandler *)downloadHandler partialProgress: (IFLoadProgress *)progress;
-
- at end
-
 /*
    ============================================================================= 
 
@@ -107,7 +97,7 @@ typedef enum {
     IFURLPolicyIgnore
 } IFURLPolicy;
 
- at protocol IFWebController <IFResourceProgressHandler, IFDownloadProgressHandler, IFScriptContextHandler>
+ at protocol IFWebController <IFResourceProgressHandler, IFScriptContextHandler>
 
 // Called when a data source needs to create a frame.  This method encapsulates the
 // specifics of creating and initializaing a view of the appropriate class.

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list