[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:04:48 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit e20fd05538eeb34133728d4fd19ed013eb21082e
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Apr 11 21:28:08 2002 +0000
Added support for non-html content. Non-html content is embedded in a
contrived HTML document.
* English.lproj/IFError.strings:
* MIME.subproj/IFContentHandler.h: Added.
* MIME.subproj/IFContentHandler.m: Added.
(-[IFContentHandler initWithMIMEHandler:URL:]), (-[IFContentHandler
HTMLDocument]), (-[IFContentHandler dealloc]):
* MIME.subproj/IFMIMEDatabase.h:
* MIME.subproj/IFMIMEDatabase.m: (-[IFMIMEDatabase MIMEHandlerForMIMEType:]),
(setMimeHandlers):
* MIME.subproj/IFMIMEHandler.h:
* MIME.subproj/IFMIMEHandler.m: (-[IFMIMEHandler
initWithMIMEType:handlerType:handlerName:]), (-[IFMIMEHandler description]):
* Misc.subproj/IFError.h:
* Misc.subproj/IFError.m: (+[IFError initialize]):
* Plugins.subproj/IFPluginView.mm: (-[IFPluginView
initWithFrame:plugin:url:mime:arguments:mode:]), (-[IFPluginView dealloc]),
(-[IFPluginView stop]):
* Resources/plugin_document_template.html: Added.
* Resources/text_document_template.html: Added.
* WebKit.pbproj/project.pbxproj:
* WebView.subproj/IFMainURLHandleClient.h:
* WebView.subproj/IFMainURLHandleClient.mm: (-[IFMainURLHandleClient
initWithDataSource:part:]), (-[IFMainURLHandleClient dealloc]),
(-[IFMainURLHandleClient IFURLHandleResourceDidFinishLoading:data:]),
(-[IFMainURLHandleClient IFURLHandle:resourceDataDidBecomeAvailable:]):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1002 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index eefa3c9..3c25ecc 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,9 @@
+2002-04-11 Chris Blumenberg <set EMAIL_ADDRESS environment variable>
+
+ Added a symbol for WCPluginDatabase.
+
+ * src/libwebcore.exp:
+
2002-04-08 Maciej Stachowiak <mjs at apple.com>
Fix Radar 2896001 (crashes in KURL):
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index eefa3c9..3c25ecc 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,9 @@
+2002-04-11 Chris Blumenberg <set EMAIL_ADDRESS environment variable>
+
+ Added a symbol for WCPluginDatabase.
+
+ * src/libwebcore.exp:
+
2002-04-08 Maciej Stachowiak <mjs at apple.com>
Fix Radar 2896001 (crashes in KURL):
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index eefa3c9..3c25ecc 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,9 @@
+2002-04-11 Chris Blumenberg <set EMAIL_ADDRESS environment variable>
+
+ Added a symbol for WCPluginDatabase.
+
+ * src/libwebcore.exp:
+
2002-04-08 Maciej Stachowiak <mjs at apple.com>
Fix Radar 2896001 (crashes in KURL):
diff --git a/WebCore/libwebcore.exp b/WebCore/libwebcore.exp
index 289b400..a265e5a 100644
--- a/WebCore/libwebcore.exp
+++ b/WebCore/libwebcore.exp
@@ -38,3 +38,4 @@ _string__CQ23DOM9DOMString
_widget__CQ25khtml12RenderWidget
_xmlDocImpl__C9KHTMLPart
_WCSetIFNullPluginMakeFunc__FPFG7_NSRectP8NSStringP12NSDictionary_PB2
+.objc_class_name_WCPluginDatabase
diff --git a/WebCore/src/libwebcore.exp b/WebCore/src/libwebcore.exp
index 289b400..a265e5a 100644
--- a/WebCore/src/libwebcore.exp
+++ b/WebCore/src/libwebcore.exp
@@ -38,3 +38,4 @@ _string__CQ23DOM9DOMString
_widget__CQ25khtml12RenderWidget
_xmlDocImpl__C9KHTMLPart
_WCSetIFNullPluginMakeFunc__FPFG7_NSRectP8NSStringP12NSDictionary_PB2
+.objc_class_name_WCPluginDatabase
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 1505626..788f8f4 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,33 @@
+2002-04-11 Chris Blumenberg <set EMAIL_ADDRESS environment variable>
+
+ Added support for non-html content. Non-html content is embedded in a
+ contrived HTML document.
+
+ * English.lproj/IFError.strings:
+ * MIME.subproj/IFContentHandler.h: Added.
+ * MIME.subproj/IFContentHandler.m: Added.
+ (-[IFContentHandler initWithMIMEHandler:URL:]), (-[IFContentHandler
+ HTMLDocument]), (-[IFContentHandler dealloc]):
+ * MIME.subproj/IFMIMEDatabase.h:
+ * MIME.subproj/IFMIMEDatabase.m: (-[IFMIMEDatabase MIMEHandlerForMIMEType:]),
+ (setMimeHandlers):
+ * MIME.subproj/IFMIMEHandler.h:
+ * MIME.subproj/IFMIMEHandler.m: (-[IFMIMEHandler
+ initWithMIMEType:handlerType:handlerName:]), (-[IFMIMEHandler description]):
+ * Misc.subproj/IFError.h:
+ * Misc.subproj/IFError.m: (+[IFError initialize]):
+ * Plugins.subproj/IFPluginView.mm: (-[IFPluginView
+ initWithFrame:plugin:url:mime:arguments:mode:]), (-[IFPluginView dealloc]),
+ (-[IFPluginView stop]):
+ * Resources/plugin_document_template.html: Added.
+ * Resources/text_document_template.html: Added.
+ * WebKit.pbproj/project.pbxproj:
+ * WebView.subproj/IFMainURLHandleClient.h:
+ * WebView.subproj/IFMainURLHandleClient.mm: (-[IFMainURLHandleClient
+ initWithDataSource:part:]), (-[IFMainURLHandleClient dealloc]),
+ (-[IFMainURLHandleClient IFURLHandleResourceDidFinishLoading:data:]),
+ (-[IFMainURLHandleClient IFURLHandle:resourceDataDidBecomeAvailable:]):
+
2002-04-10 Chris Blumenberg <set EMAIL_ADDRESS environment variable>
Cleaned up stream deallocations.
diff --git a/WebKit/ChangeLog-2002-12-03 b/WebKit/ChangeLog-2002-12-03
index 1505626..788f8f4 100644
--- a/WebKit/ChangeLog-2002-12-03
+++ b/WebKit/ChangeLog-2002-12-03
@@ -1,3 +1,33 @@
+2002-04-11 Chris Blumenberg <set EMAIL_ADDRESS environment variable>
+
+ Added support for non-html content. Non-html content is embedded in a
+ contrived HTML document.
+
+ * English.lproj/IFError.strings:
+ * MIME.subproj/IFContentHandler.h: Added.
+ * MIME.subproj/IFContentHandler.m: Added.
+ (-[IFContentHandler initWithMIMEHandler:URL:]), (-[IFContentHandler
+ HTMLDocument]), (-[IFContentHandler dealloc]):
+ * MIME.subproj/IFMIMEDatabase.h:
+ * MIME.subproj/IFMIMEDatabase.m: (-[IFMIMEDatabase MIMEHandlerForMIMEType:]),
+ (setMimeHandlers):
+ * MIME.subproj/IFMIMEHandler.h:
+ * MIME.subproj/IFMIMEHandler.m: (-[IFMIMEHandler
+ initWithMIMEType:handlerType:handlerName:]), (-[IFMIMEHandler description]):
+ * Misc.subproj/IFError.h:
+ * Misc.subproj/IFError.m: (+[IFError initialize]):
+ * Plugins.subproj/IFPluginView.mm: (-[IFPluginView
+ initWithFrame:plugin:url:mime:arguments:mode:]), (-[IFPluginView dealloc]),
+ (-[IFPluginView stop]):
+ * Resources/plugin_document_template.html: Added.
+ * Resources/text_document_template.html: Added.
+ * WebKit.pbproj/project.pbxproj:
+ * WebView.subproj/IFMainURLHandleClient.h:
+ * WebView.subproj/IFMainURLHandleClient.mm: (-[IFMainURLHandleClient
+ initWithDataSource:part:]), (-[IFMainURLHandleClient dealloc]),
+ (-[IFMainURLHandleClient IFURLHandleResourceDidFinishLoading:data:]),
+ (-[IFMainURLHandleClient IFURLHandle:resourceDataDidBecomeAvailable:]):
+
2002-04-10 Chris Blumenberg <set EMAIL_ADDRESS environment variable>
Cleaned up stream deallocations.
diff --git a/WebKit/English.lproj/IFError.strings b/WebKit/English.lproj/IFError.strings
index ba6a065..5bf105d 100644
Binary files a/WebKit/English.lproj/IFError.strings and b/WebKit/English.lproj/IFError.strings differ
diff --git a/WebKit/English.lproj/WebError.strings b/WebKit/English.lproj/WebError.strings
index ba6a065..5bf105d 100644
Binary files a/WebKit/English.lproj/WebError.strings and b/WebKit/English.lproj/WebError.strings differ
diff --git a/WebKit/MIME.subproj/IFContentHandler.h b/WebKit/MIME.subproj/IFContentHandler.h
new file mode 100644
index 0000000..1811903
--- /dev/null
+++ b/WebKit/MIME.subproj/IFContentHandler.h
@@ -0,0 +1,19 @@
+/*
+ IFContentHandler.h
+ Copyright 2002, Apple, Inc. All rights reserved.
+*/
+
+#import <Foundation/Foundation.h>
+#import <IFMIMEHandler.h>
+
+ at interface IFContentHandler : NSObject {
+ IFMIMEHandlerType handlerType;
+ NSString *MIMEType, *URLString;
+}
+
+- initWithMIMEHandler:(IFMIMEHandler *)mimeHandler URL:(NSURL *)URL;
+- (NSString *) HTMLDocument;
+- (NSString *) textHTMLDocumentBottom;
+
+
+ at end
diff --git a/WebKit/MIME.subproj/IFContentHandler.m b/WebKit/MIME.subproj/IFContentHandler.m
new file mode 100644
index 0000000..9295023
--- /dev/null
+++ b/WebKit/MIME.subproj/IFContentHandler.m
@@ -0,0 +1,87 @@
+/*
+ IFContentHandler.m
+ Copyright 2002, Apple, Inc. All rights reserved.
+*/
+
+#import "IFContentHandler.h"
+
+static NSString *imageDocumentTemplate = nil;
+static NSString *pluginDocumentTemplate = nil;
+static NSString *textDocumentTemplate = nil;
+
+static BOOL imageDocumentLoaded = NO;
+static BOOL pluginDocumentLoaded = NO;
+static BOOL textDocumentLoaded = NO;
+
+ at implementation IFContentHandler
+
+- initWithMIMEHandler:(IFMIMEHandler *)mimeHandler URL:(NSURL *)URL
+{
+ handlerType = [mimeHandler handlerType];
+ MIMEType = [[mimeHandler MIMEType] retain];
+ URLString = [[URL absoluteString] retain];
+
+ return self;
+}
+
+- (NSString *) HTMLDocument
+{
+ NSString *path;
+ NSBundle *bundle;
+ NSData *data;
+
+ if(handlerType == IFMIMEHANDLERTYPE_IMAGE){
+ if(!imageDocumentLoaded){
+ bundle = [NSBundle bundleForClass:[IFContentHandler class]];
+ if ((path = [bundle pathForResource:@"image_document_template" ofType:@"html"])) {
+ data = [[NSData alloc] initWithContentsOfFile:path];
+ if (data) {
+ imageDocumentTemplate = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
+ [data release];
+ }
+ }
+ }
+ return [NSString stringWithFormat:imageDocumentTemplate, URLString, URLString];
+ }
+
+ else if(handlerType == IFMIMEHANDLERTYPE_PLUGIN){
+ if(!pluginDocumentLoaded){
+ bundle = [NSBundle bundleForClass:[IFContentHandler class]];
+ if ((path = [bundle pathForResource:@"plugin_document_template" ofType:@"html"])) {
+ data = [[NSData alloc] initWithContentsOfFile:path];
+ if (data) {
+ pluginDocumentTemplate = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
+ [data release];
+ }
+ }
+ }
+ return [NSString stringWithFormat:pluginDocumentTemplate, URLString, URLString, MIMEType];
+ }
+
+ else if(handlerType == IFMIMEHANDLERTYPE_TEXT){
+ if(!textDocumentLoaded){
+ bundle = [NSBundle bundleForClass:[IFContentHandler class]];
+ if ((path = [bundle pathForResource:@"text_document_template" ofType:@"html"])) {
+ data = [[NSData alloc] initWithContentsOfFile:path];
+ if (data) {
+ textDocumentTemplate = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
+ [data release];
+ }
+ }
+ }
+ return [NSString stringWithFormat:textDocumentTemplate, URLString];
+ }
+ return nil;
+}
+
+- (NSString *) textHTMLDocumentBottom;
+{
+ return @"</pre></body></html>";
+}
+
+-(void)dealloc
+{
+ [MIMEType release];
+ [URLString release];
+}
+ at end
diff --git a/WebKit/MIME.subproj/IFMIMEDatabase.h b/WebKit/MIME.subproj/IFMIMEDatabase.h
index a2474d2..53248b9 100644
--- a/WebKit/MIME.subproj/IFMIMEDatabase.h
+++ b/WebKit/MIME.subproj/IFMIMEDatabase.h
@@ -18,13 +18,11 @@ IFMIMEDatabase creates a dictionary of MIME type keys and IFMIMEHandlers objects
At some point, IFMIMEDatabase might interact with the defaults to provide for customization.
-Types that WebKit can/will handle internally (thanks to AppKit):
+Types that WebKit can handle internally:
Text types:
text/html
text/plain
-text/richtext
-application/rtf
Image types (taken from [NSImage imageFileTypes]):
image/pict
@@ -60,11 +58,4 @@ MIMEHandlerForMIMEType does a simple dictionary lookup. If none is found IFMIMEH
- (IFMIMEHandler *)MIMEHandlerForMIMEType:(NSString *)mimeType;
-
-/*
-If a mime type is not available, MIMEHandlerForURL determines a IFMIMEHandler based on the URL's extension. This may require interaction with Launch Services.
-*/
-
-- (IFMIMEHandler *)MIMEHandlerForURL:(NSURL *)url;
-
@end
diff --git a/WebKit/MIME.subproj/IFMIMEDatabase.m b/WebKit/MIME.subproj/IFMIMEDatabase.m
index e411d8f..2cafc91 100644
--- a/WebKit/MIME.subproj/IFMIMEDatabase.m
+++ b/WebKit/MIME.subproj/IFMIMEDatabase.m
@@ -7,6 +7,8 @@
//
#import "IFMIMEDatabase.h"
+#import <WCPluginDatabase.h>
+#import <WCPlugin.h>
NSMutableDictionary *setMimeHandlers(void);
@@ -28,57 +30,62 @@ static IFMIMEDatabase *sharedMIMEDatabase = nil;
- (IFMIMEHandler *)MIMEHandlerForMIMEType:(NSString *)mimeType
{
IFMIMEHandler *tempHandler;
+ WCPluginDatabase *pluginDatabase;
+ WCPlugin *plugin;
+
+ if(!mimeType)
+ return [[[IFMIMEHandler alloc] initWithMIMEType:mimeType handlerType:IFMIMEHANDLERTYPE_NIL handlerName:nil] autorelease];
+
tempHandler = [mimeHandlers objectForKey:mimeType];
- if(tempHandler)
+ if(tempHandler){
return tempHandler;
- else
- return [[IFMIMEHandler alloc] initWithMIMEType:mimeType handlerType:IFMIMEHANDLERTYPE_APPLICATION handlerName:@""];
-}
-
-
-- (IFMIMEHandler *)MIMEHandlerForURL:(NSURL *)url
-{
- return nil;
+ }else{
+ pluginDatabase = [WCPluginDatabase installedPlugins];
+ plugin = [pluginDatabase getPluginForMimeType:mimeType];
+ if(plugin){
+ return [[[IFMIMEHandler alloc] initWithMIMEType:mimeType handlerType:IFMIMEHANDLERTYPE_PLUGIN handlerName:[plugin name]] autorelease];
+ }
+ else{
+ return [[[IFMIMEHandler alloc] initWithMIMEType:mimeType handlerType:IFMIMEHANDLERTYPE_APPLICATION handlerName:nil] autorelease];
+ }
+ }
}
@end
NSMutableDictionary *setMimeHandlers(void)
{
- NSArray *textTypes, *imageTypes;
+ NSArray *imageTypes;
NSMutableDictionary *handledTypes;
IFMIMEHandler *tempHandler;
NSString *tempMime = nil;
uint i;
handledTypes = [NSMutableDictionary dictionaryWithCapacity:20];
- textTypes = [NSArray arrayWithObjects:@"text/plain", @"text/richtext", @"application/rtf", nil];
imageTypes = [NSArray arrayWithObjects:
- @"image/pict",
- @"application/postscript",
- @"image/tiff",
- @"image/x-quicktime",
- @"image/x-targa",
- @"image/x-sgi",
- @"image/x-rgb",
- @"image/x-macpaint",
+ //@"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/x-bmp",
- @"image/tiff",
- @"image/x-tiff", nil];
+ @"image/jpeg", nil];
- for(i=0; i<[textTypes count]; i++){
- tempMime = [textTypes objectAtIndex:i];
- tempHandler = [[IFMIMEHandler alloc] initWithMIMEType:tempMime handlerType:IFMIMEHANDLERTYPE_TEXT handlerName:@"WebKit"];
- [handledTypes setObject:tempHandler forKey:tempMime];
- }
for(i=0; i<[imageTypes count]; i++){
tempMime = [imageTypes objectAtIndex:i];
tempHandler = [[IFMIMEHandler alloc] initWithMIMEType:tempMime handlerType:IFMIMEHANDLERTYPE_IMAGE handlerName:@"WebKit"];
[handledTypes setObject:tempHandler forKey:tempMime];
}
+ tempHandler = [[IFMIMEHandler alloc] initWithMIMEType:@"text/plain" handlerType:IFMIMEHANDLERTYPE_TEXT handlerName:@"WebKit"];
+ [handledTypes setObject:tempHandler forKey:@"text/plain"];
+
tempHandler = [[IFMIMEHandler alloc] initWithMIMEType:@"text/html" handlerType:IFMIMEHANDLERTYPE_HTML handlerName:@"WebKit"];
[handledTypes setObject:tempHandler forKey:@"text/html"];
diff --git a/WebKit/MIME.subproj/IFMIMEHandler.h b/WebKit/MIME.subproj/IFMIMEHandler.h
index 593fb32..1e37f93 100644
--- a/WebKit/MIME.subproj/IFMIMEHandler.h
+++ b/WebKit/MIME.subproj/IFMIMEHandler.h
@@ -14,16 +14,17 @@ IFMIMEHandler is a simple data type object holding the MIME type, the type of ha
typedef enum {
+ IFMIMEHANDLERTYPE_NIL = 0,
IFMIMEHANDLERTYPE_HTML = 1, //WebKit handled html
IFMIMEHANDLERTYPE_IMAGE = 2, //WebKit handled image
IFMIMEHANDLERTYPE_TEXT = 3, //WebKit handled text
- IFMIMEHANDLERTYPE_PLUG_IN = 4, //Plug-in handled file
+ IFMIMEHANDLERTYPE_PLUGIN = 4, //Plug-in handled file
IFMIMEHANDLERTYPE_APPLICATION = 5, //Application handled file
} IFMIMEHandlerType;
@interface IFMIMEHandler : NSObject {
- NSString *MIMEType, *MIMESupertype, *MIMESubtype, *handlerName;
+ NSString *MIMEType, *handlerName;
IFMIMEHandlerType handlerType;
}
@@ -35,8 +36,6 @@ initWithMIMEType gets called by [IFMIMEDatabase sharedMIMEDatabase] for at least
// Accessor methods
- (NSString *)MIMEType;
-- (NSString *)MIMESupertype;
-- (NSString *)MIMESubtype;
- (NSString *)handlerName;
- (IFMIMEHandlerType)handlerType;
diff --git a/WebKit/MIME.subproj/IFMIMEHandler.m b/WebKit/MIME.subproj/IFMIMEHandler.m
index 2bee382..597402a 100644
--- a/WebKit/MIME.subproj/IFMIMEHandler.m
+++ b/WebKit/MIME.subproj/IFMIMEHandler.m
@@ -14,15 +14,9 @@
- initWithMIMEType:(NSString *)MIME handlerType:(IFMIMEHandlerType)hType handlerName:(NSString *)handler
{
- NSRange r;
-
- MIMEType = MIME;
- handlerType = hType;
- handlerName = handler;
-
- r = [MIMEType rangeOfString:@"/"];
- MIMESupertype = [MIMEType substringToIndex:r.location];
- MIMESubtype = [MIMEType substringFromIndex:r.location];
+ MIMEType = [MIME retain];
+ handlerName = [handler retain];
+ handlerType = hType;
return self;
}
@@ -34,25 +28,11 @@
return MIMEType;
}
-
-- (NSString *)MIMESupertype
-{
- return MIMESupertype;
-}
-
-
-- (NSString *)MIMESubtype
-{
- return MIMESubtype;
-}
-
-
- (NSString *)handlerName
{
return handlerName;
}
-
- (IFMIMEHandlerType)handlerType
{
return handlerType;
@@ -67,11 +47,12 @@
handlerTypeString = @"IFMIMEHANDLERTYPE_IMAGE";
else if(handlerType == IFMIMEHANDLERTYPE_TEXT)
handlerTypeString = @"IFMIMEHANDLERTYPE_TEXT";
- else if(handlerType == IFMIMEHANDLERTYPE_PLUG_IN)
- handlerTypeString = @"IFMIMEHANDLERTYPE_PLUG_IN";
+ else if(handlerType == IFMIMEHANDLERTYPE_PLUGIN)
+ handlerTypeString = @"IFMIMEHANDLERTYPE_PLUGIN";
else if(handlerType == IFMIMEHANDLERTYPE_APPLICATION)
handlerTypeString = @"IFMIMEHANDLERTYPE_APPLICATION";
- return [NSString stringWithFormat:@"MIME TYPE: %@, HANDLER TYPE: %@, HANDLER NAME: %@", MIMEType, handlerTypeString, handlerName];
+ return [NSString stringWithFormat:@"MIME TYPE: %@, HANDLER TYPE: %@, HANDLER NAME: %@",
+ MIMEType, handlerTypeString, handlerName];
}
@end
diff --git a/WebKit/Misc.subproj/IFError.h b/WebKit/Misc.subproj/IFError.h
index bbc0147..fe62751 100644
--- a/WebKit/Misc.subproj/IFError.h
+++ b/WebKit/Misc.subproj/IFError.h
@@ -11,7 +11,8 @@
// WebKit error codes >= 10000
typedef enum {
- IFNonHTMLContentNotSupportedError = 10000
+ IFNonHTMLContentNotSupportedError = 10000,
+ IFFileDownloadNotSupportedError = 10001
} IFErrorCode;
@interface IFError : NSObject
diff --git a/WebKit/Misc.subproj/IFError.m b/WebKit/Misc.subproj/IFError.m
index 4e5d4f4..615b202 100644
--- a/WebKit/Misc.subproj/IFError.m
+++ b/WebKit/Misc.subproj/IFError.m
@@ -111,6 +111,8 @@ static id IFErrorMake(int code)
NSLocalizedStringFromTable (@"non-HTML content not currently supported", @"IFError", @"IFNonHTMLContentNotSupportedError description"),
[NSNumber numberWithInt: IFNonHTMLContentNotSupportedError],
+ NSLocalizedStringFromTable (@"file download not currently supported", @"IFError", @"IFFileDownloadNotSupportedError description"),
+ [NSNumber numberWithInt: IFFileDownloadNotSupportedError],
nil];
if (descriptions == nil) {
diff --git a/WebKit/Plugins.subproj/IFPluginView.mm b/WebKit/Plugins.subproj/IFPluginView.mm
index 9147f6f..b265a1d 100644
--- a/WebKit/Plugins.subproj/IFPluginView.mm
+++ b/WebKit/Plugins.subproj/IFPluginView.mm
@@ -66,25 +66,26 @@ extern "C" {
cMime = malloc([mime length]+1);
[mime getCString:cMime];
-
- if(arguments){
-
- baseURLString = [arguments objectForKey:@"WebKitBaseURL"];
- if(baseURLString)
- baseURL = [[NSURL URLWithString:baseURLString] retain];
+
+ // get base URL which was added in the args in the part
+ baseURLString = [arguments objectForKey:@"WebKitBaseURL"];
+ if(baseURLString)
+ baseURL = [[NSURL URLWithString:baseURLString] retain];
- attributes = [arguments allKeys];
- values = [arguments allValues];
+ attributes = [arguments allKeys];
+ values = [arguments allValues];
+
+ if([attributes containsObject:@"hidden"])
+ hidden = TRUE;
+ else
+ hidden = FALSE;
+
+ if(![attributes containsObject:@"wkfullmode"]){
+ // convert arugments dictionary to 2 string arrays
+
cAttributes = malloc(sizeof(char *) * [arguments count]);
cValues = malloc(sizeof(char *) * [arguments count]);
- if([attributes containsObject:@"HIDDEN"]){
- hidden = TRUE;
- }else{
- hidden = FALSE;
- }
-
- // convert arugments dictionary to 2 string arrays
for(i=0; i<[arguments count]; i++){
attributeString = [attributes objectAtIndex:i];
s = malloc([attributeString length]+1);
@@ -96,10 +97,11 @@ extern "C" {
[attributeString getCString:s];
cValues[i] = s;
}
- npErr = NPP_New(cMime, instance, mode, [arguments count], cAttributes, cValues, &saved);
+ npErr = NPP_New(cMime, instance, NP_EMBED, [arguments count], cAttributes, cValues, &saved);
}else{
- npErr = NPP_New(cMime, instance, mode, 0, NULL, NULL, &saved);
+ npErr = NPP_New(cMime, instance, NP_FULL, 0, NULL, NULL, &saved);
}
+
WEBKITDEBUG("NPP_New: %d\n", npErr);
free(cMime);
@@ -116,6 +118,28 @@ extern "C" {
return self;
}
+-(void)dealloc
+{
+ unsigned i;
+ NSFileManager *fileManager;
+
+ [self stop];
+
+ // remove downloaded files
+ fileManager = [NSFileManager defaultManager];
+ for(i=0; i<[filesToErase count]; i++){
+ [fileManager removeFileAtPath:[filesToErase objectAtIndex:i] handler:nil];
+ }
+
+ [filesToErase release];
+ [activeURLHandles release];
+ [mime release];
+ [URL release];
+ [plugin release];
+ free(cAttributes);
+ free(cValues);
+ [super dealloc];
+}
- (void) setWindow
{
@@ -216,29 +240,6 @@ extern "C" {
}
}
--(void)dealloc
-{
- unsigned i;
- NSFileManager *fileManager;
-
- [self stop];
-
- // remove downloaded files
- fileManager = [NSFileManager defaultManager];
- for(i=0; i<[filesToErase count]; i++){
- [fileManager removeFileAtPath:[filesToErase objectAtIndex:i] handler:nil];
- }
-
- [filesToErase release];
- [activeURLHandles release];
- [mime release];
- [URL release];
- [plugin release];
- free(cAttributes);
- free(cValues);
- [super dealloc];
-}
-
- (NSView *) findSuperview:(NSString *)viewName
{
NSView *view;
diff --git a/WebKit/Plugins.subproj/WebPluginView.m b/WebKit/Plugins.subproj/WebPluginView.m
index 9147f6f..b265a1d 100644
--- a/WebKit/Plugins.subproj/WebPluginView.m
+++ b/WebKit/Plugins.subproj/WebPluginView.m
@@ -66,25 +66,26 @@ extern "C" {
cMime = malloc([mime length]+1);
[mime getCString:cMime];
-
- if(arguments){
-
- baseURLString = [arguments objectForKey:@"WebKitBaseURL"];
- if(baseURLString)
- baseURL = [[NSURL URLWithString:baseURLString] retain];
+
+ // get base URL which was added in the args in the part
+ baseURLString = [arguments objectForKey:@"WebKitBaseURL"];
+ if(baseURLString)
+ baseURL = [[NSURL URLWithString:baseURLString] retain];
- attributes = [arguments allKeys];
- values = [arguments allValues];
+ attributes = [arguments allKeys];
+ values = [arguments allValues];
+
+ if([attributes containsObject:@"hidden"])
+ hidden = TRUE;
+ else
+ hidden = FALSE;
+
+ if(![attributes containsObject:@"wkfullmode"]){
+ // convert arugments dictionary to 2 string arrays
+
cAttributes = malloc(sizeof(char *) * [arguments count]);
cValues = malloc(sizeof(char *) * [arguments count]);
- if([attributes containsObject:@"HIDDEN"]){
- hidden = TRUE;
- }else{
- hidden = FALSE;
- }
-
- // convert arugments dictionary to 2 string arrays
for(i=0; i<[arguments count]; i++){
attributeString = [attributes objectAtIndex:i];
s = malloc([attributeString length]+1);
@@ -96,10 +97,11 @@ extern "C" {
[attributeString getCString:s];
cValues[i] = s;
}
- npErr = NPP_New(cMime, instance, mode, [arguments count], cAttributes, cValues, &saved);
+ npErr = NPP_New(cMime, instance, NP_EMBED, [arguments count], cAttributes, cValues, &saved);
}else{
- npErr = NPP_New(cMime, instance, mode, 0, NULL, NULL, &saved);
+ npErr = NPP_New(cMime, instance, NP_FULL, 0, NULL, NULL, &saved);
}
+
WEBKITDEBUG("NPP_New: %d\n", npErr);
free(cMime);
@@ -116,6 +118,28 @@ extern "C" {
return self;
}
+-(void)dealloc
+{
+ unsigned i;
+ NSFileManager *fileManager;
+
+ [self stop];
+
+ // remove downloaded files
+ fileManager = [NSFileManager defaultManager];
+ for(i=0; i<[filesToErase count]; i++){
+ [fileManager removeFileAtPath:[filesToErase objectAtIndex:i] handler:nil];
+ }
+
+ [filesToErase release];
+ [activeURLHandles release];
+ [mime release];
+ [URL release];
+ [plugin release];
+ free(cAttributes);
+ free(cValues);
+ [super dealloc];
+}
- (void) setWindow
{
@@ -216,29 +240,6 @@ extern "C" {
}
}
--(void)dealloc
-{
- unsigned i;
- NSFileManager *fileManager;
-
- [self stop];
-
- // remove downloaded files
- fileManager = [NSFileManager defaultManager];
- for(i=0; i<[filesToErase count]; i++){
- [fileManager removeFileAtPath:[filesToErase objectAtIndex:i] handler:nil];
- }
-
- [filesToErase release];
- [activeURLHandles release];
- [mime release];
- [URL release];
- [plugin release];
- free(cAttributes);
- free(cValues);
- [super dealloc];
-}
-
- (NSView *) findSuperview:(NSString *)viewName
{
NSView *view;
diff --git a/WebKit/Resources/image_document_template.html b/WebKit/Resources/plugin_document_template.html
similarity index 64%
copy from WebKit/Resources/image_document_template.html
copy to WebKit/Resources/plugin_document_template.html
index e0a4099..d21d289 100644
--- a/WebKit/Resources/image_document_template.html
+++ b/WebKit/Resources/plugin_document_template.html
@@ -16,5 +16,9 @@
</style>
<title>%@</title>
</head>
-<body><img src="%@"></body>
+<body>
+<br>
+<br>
+<center><embed src="%@" type="%@" width=600 height=400 wkfullmode></center>
+</body>
</html>
\ No newline at end of file
diff --git a/WebKit/Resources/text_document_template.html b/WebKit/Resources/text_document_template.html
new file mode 100644
index 0000000..7db088e
--- /dev/null
+++ b/WebKit/Resources/text_document_template.html
@@ -0,0 +1,6 @@
+<html>
+<head>
+<title>%@</title>
+</head>
+<body>
+<pre>
\ No newline at end of file
diff --git a/WebKit/WebKit.pbproj/project.pbxproj b/WebKit/WebKit.pbproj/project.pbxproj
index 412379a..f58fd9c 100644
--- a/WebKit/WebKit.pbproj/project.pbxproj
+++ b/WebKit/WebKit.pbproj/project.pbxproj
@@ -216,6 +216,7 @@
F5883BE2025E5E9D01000102,
F5A672BB0263866E01000102,
F5A672BD0263866E01000102,
+ F5A357540265E57A01000102,
);
isa = PBXHeadersBuildPhase;
};
@@ -229,6 +230,8 @@
F5B67131023EDF8901C1A525,
25B2A7C5025D0A880ECA149E,
F5883BDF025E5C6A01000102,
+ F5E638640265FC0D01000102,
+ F5E638650265FC0D01000102,
);
isa = PBXResourcesBuildPhase;
};
@@ -262,6 +265,7 @@
F5883BE3025E5E9D01000102,
F5A672BC0263866E01000102,
F5A672BE0263866E01000102,
+ F5A357530265E57A01000102,
);
isa = PBXSourcesBuildPhase;
};
@@ -293,6 +297,8 @@
F5B67130023EDF8901C1A525,
F5883BDE025E5C6A01000102,
25B2A7C4025D0A880ECA149E,
+ F5E638620265FC0D01000102,
+ F5E638630265FC0D01000102,
);
isa = PBXGroup;
name = Resources;
@@ -1227,6 +1233,30 @@
settings = {
};
};
+ F5A357510265E57A01000102 = {
+ isa = PBXFileReference;
+ name = IFContentHandler.m;
+ path = MIME.subproj/IFContentHandler.m;
+ refType = 4;
+ };
+ F5A357520265E57A01000102 = {
+ isa = PBXFileReference;
+ name = IFContentHandler.h;
+ path = MIME.subproj/IFContentHandler.h;
+ refType = 4;
+ };
+ F5A357530265E57A01000102 = {
+ fileRef = F5A357510265E57A01000102;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+ F5A357540265E57A01000102 = {
+ fileRef = F5A357520265E57A01000102;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
F5A672B70263866E01000102 = {
isa = PBXFileReference;
name = IFPluginNullEventSender.h;
@@ -1372,6 +1402,30 @@
settings = {
};
};
+ F5E638620265FC0D01000102 = {
+ isa = PBXFileReference;
+ name = plugin_document_template.html;
+ path = Resources/plugin_document_template.html;
+ refType = 4;
+ };
+ F5E638630265FC0D01000102 = {
+ isa = PBXFileReference;
+ name = text_document_template.html;
+ path = Resources/text_document_template.html;
+ refType = 4;
+ };
+ F5E638640265FC0D01000102 = {
+ fileRef = F5E638620265FC0D01000102;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+ F5E638650265FC0D01000102 = {
+ fileRef = F5E638630265FC0D01000102;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
F5EBC45202134BB601CA1520 = {
children = (
F5EBC45502134BC301CA1520,
@@ -1429,6 +1483,8 @@
F5F084BA024BDC8E01CA1520,
F5F084BD024BDCA701CA1520,
F5F084BE024BDCA701CA1520,
+ F5A357510265E57A01000102,
+ F5A357520265E57A01000102,
);
isa = PBXGroup;
name = MIME;
diff --git a/WebKit/WebView.subproj/IFMainURLHandleClient.h b/WebKit/WebView.subproj/IFMainURLHandleClient.h
index 597b78c..b3bfefb 100644
--- a/WebKit/WebView.subproj/IFMainURLHandleClient.h
+++ b/WebKit/WebView.subproj/IFMainURLHandleClient.h
@@ -11,12 +11,14 @@
#import <WebFoundation/WebFoundation.h>
#import <WebKit/IFWebDataSourcePrivate.h>
+#import <WebKit/IFMIMEHandler.h>
@interface IFMainURLHandleClient : NSObject <IFURLHandleClient>
{
id dataSource;
KHTMLPart *part;
- BOOL sentFakeDocForNonHTMLContentType;
+ BOOL sentFakeDocForNonHTMLContentType, typeChecked;
+ IFMIMEHandler *mimeHandler;
}
- initWithDataSource: (IFWebDataSource *)ds part: (KHTMLPart *)p;
@end
diff --git a/WebKit/WebView.subproj/IFMainURLHandleClient.mm b/WebKit/WebView.subproj/IFMainURLHandleClient.mm
index 2d61d80..1042146 100644
--- a/WebKit/WebView.subproj/IFMainURLHandleClient.mm
+++ b/WebKit/WebView.subproj/IFMainURLHandleClient.mm
@@ -8,30 +8,12 @@
#import <WebKit/IFError.h>
#import <WebKit/IFBaseWebControllerPrivate.h>
#import <WebKit/IFMainURLHandleClient.h>
-
+#import <WebKit/IFMIMEDatabase.h>
#import <WebKit/WebKitDebug.h>
+#import <WebKit/IFContentHandler.h>
#include <khtmlview.h>
-static NSString *imageDocumentTemplate = NULL;
-static pthread_once_t imageDocumentTemplateControl = PTHREAD_ONCE_INIT;
-
-static void loadImageDocumentTemplate()
-{
- NSString *path;
- NSBundle *bundle;
- NSData *data;
-
- bundle = [NSBundle bundleForClass:[IFMainURLHandleClient class]];
- if ((path = [bundle pathForResource:@"image_document_template" ofType:@"html"])) {
- data = [[NSData alloc] initWithContentsOfFile:path];
- if (data) {
- imageDocumentTemplate = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
- [data release];
- }
- }
-}
-
@implementation IFMainURLHandleClient
- initWithDataSource: (IFWebDataSource *)ds part:(KHTMLPart *)p
@@ -41,6 +23,7 @@ static void loadImageDocumentTemplate()
part = p;
part->ref();
sentFakeDocForNonHTMLContentType = NO;
+ typeChecked = NO;
return self;
}
@@ -51,6 +34,7 @@ static void loadImageDocumentTemplate()
{
part->deref();
[dataSource release];
+ [mimeHandler release];
[super dealloc];
}
@@ -73,8 +57,20 @@ static void loadImageDocumentTemplate()
- (void)IFURLHandleResourceDidFinishLoading:(IFURLHandle *)sender data: (NSData *)data
{
+ NSString *fakeHTMLDocument;
+ const char *fakeHTMLDocumentBytes;
+ IFContentHandler *contentHandler;
+
WEBKITDEBUGLEVEL (WEBKIT_LOG_LOADING, "url = %s\n", [[[sender url] absoluteString] cString]);
+ if([mimeHandler 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];
+ }
+
IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
loadProgress->totalToLoad = [data length];
loadProgress->bytesSoFar = [data length];
@@ -84,57 +80,62 @@ static void loadImageDocumentTemplate()
- (void)IFURLHandle:(IFURLHandle *)sender resourceDataDidBecomeAvailable:(NSData *)data
{
- BOOL handled;
-
NSString *fakeHTMLDocument;
const char *fakeHTMLDocumentBytes;
- NSString *urlString;
-
+ IFMIMEDatabase *mimeDatabase;
+ IFContentHandler *contentHandler;
+
WEBKITDEBUGLEVEL (WEBKIT_LOG_LOADING, "url = %s, data = %p, length %d\n", [[[sender url] absoluteString] cString], data, [data length]);
-
- // did we handle this content type?
- handled = NO;
- //FIXME: This is a temporary hack to make sure we don't load non-html content.
- //Since the cache returns nil for contentType when the URL is in the cache (2892912),
- //I assume the contentType is text/html for that case.
- NSString *contentType = [sender contentType];
- if(contentType == nil || [contentType isEqualToString:@"text/html"]) {
+ // check the mime type
+ if(!typeChecked){
+ mimeDatabase = [IFMIMEDatabase sharedMIMEDatabase];
+ mimeHandler = [[mimeDatabase MIMEHandlerForMIMEType:[sender contentType]] retain];
+ typeChecked = YES;
+ }
+
+ // if it's html, send the data to the part
+ // FIXME: [sender contentType] still returns nil if from cache
+ if([mimeHandler handlerType] == IFMIMEHANDLERTYPE_NIL || [mimeHandler handlerType] == IFMIMEHANDLERTYPE_HTML) {
part->slotData(sender, (const char *)[data bytes], [data length]);
- handled = YES;
}
- // handle images
- else if ([contentType isEqualToString:@"image/gif"] || [contentType isEqualToString:@"image/jpeg"] || [contentType isEqualToString:@"image/png"]) {
+
+ // for non-html documents, create html doc that embeds them
+ else if([mimeHandler handlerType] == IFMIMEHANDLERTYPE_IMAGE ||
+ [mimeHandler handlerType] == IFMIMEHANDLERTYPE_PLUGIN ||
+ [mimeHandler handlerType] == IFMIMEHANDLERTYPE_TEXT) {
if (!sentFakeDocForNonHTMLContentType) {
- pthread_once(&imageDocumentTemplateControl, loadImageDocumentTemplate);
- if (imageDocumentTemplate) {
- urlString = [[sender url] absoluteString];
- fakeHTMLDocument = [NSString stringWithFormat:imageDocumentTemplate, urlString, urlString];
- fakeHTMLDocumentBytes = [fakeHTMLDocument cString];
- part->slotData(sender, (const char *)fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes));
- }
+ contentHandler = [[IFContentHandler alloc] initWithMIMEHandler:mimeHandler URL:[sender url]];
+ fakeHTMLDocument = [contentHandler HTMLDocument];
+ fakeHTMLDocumentBytes = [fakeHTMLDocument cString];
+ part->slotData(sender, (const char *)fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes));
+ sentFakeDocForNonHTMLContentType = YES;
+ [contentHandler release];
+ }
+
+ // for text documents, the incoming data is part of the main page
+ if([mimeHandler handlerType] == IFMIMEHANDLERTYPE_TEXT){
+ part->slotData(sender, (const char *)[data bytes], [data length]);
}
- handled = YES;
- sentFakeDocForNonHTMLContentType = YES;
- }
-
- if (handled) {
- // update progress
- IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
- loadProgress->totalToLoad = [sender contentLength];
- loadProgress->bytesSoFar = [sender contentLengthReceived];
- [[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress forResource: [[sender url] absoluteString] fromDataSource: dataSource];
- [loadProgress release];
}
- else {
- // we do not handle this content type
- // cancel load
+
+ // FIXME: download code goes here, stop reporting error
+ else{
[sender cancelLoadInBackground];
- IFError *error = [[IFError alloc] initWithErrorCode: IFNonHTMLContentNotSupportedError failingURL: [sender url]];
- [[dataSource controller] _mainReceivedError: error forResource: [[sender url] absoluteString] partialProgress:nil fromDataSource: dataSource];
+ IFError *error = [[IFError alloc] initWithErrorCode: IFFileDownloadNotSupportedError failingURL: [sender url]];
+ [[dataSource controller] _mainReceivedError: error
+ forResource: [[sender url] absoluteString] partialProgress:nil fromDataSource: dataSource];
[error release];
+ return;
}
+ // update progress
+ IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
+ loadProgress->totalToLoad = [sender contentLength];
+ loadProgress->bytesSoFar = [sender contentLengthReceived];
+ [[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress
+ forResource: [[sender url] absoluteString] fromDataSource: dataSource];
+ [loadProgress release];
}
- (void)IFURLHandle:(IFURLHandle *)sender resourceDidFailLoadingWithResult:(int)result
@@ -160,4 +161,5 @@ static void loadImageDocumentTemplate()
[[dataSource controller] serverRedirectTo: url forDataSource: dataSource];
}
+
@end
diff --git a/WebKit/WebView.subproj/WebMainResourceClient.h b/WebKit/WebView.subproj/WebMainResourceClient.h
index 597b78c..b3bfefb 100644
--- a/WebKit/WebView.subproj/WebMainResourceClient.h
+++ b/WebKit/WebView.subproj/WebMainResourceClient.h
@@ -11,12 +11,14 @@
#import <WebFoundation/WebFoundation.h>
#import <WebKit/IFWebDataSourcePrivate.h>
+#import <WebKit/IFMIMEHandler.h>
@interface IFMainURLHandleClient : NSObject <IFURLHandleClient>
{
id dataSource;
KHTMLPart *part;
- BOOL sentFakeDocForNonHTMLContentType;
+ BOOL sentFakeDocForNonHTMLContentType, typeChecked;
+ IFMIMEHandler *mimeHandler;
}
- initWithDataSource: (IFWebDataSource *)ds part: (KHTMLPart *)p;
@end
diff --git a/WebKit/WebView.subproj/WebMainResourceClient.m b/WebKit/WebView.subproj/WebMainResourceClient.m
index 2d61d80..1042146 100644
--- a/WebKit/WebView.subproj/WebMainResourceClient.m
+++ b/WebKit/WebView.subproj/WebMainResourceClient.m
@@ -8,30 +8,12 @@
#import <WebKit/IFError.h>
#import <WebKit/IFBaseWebControllerPrivate.h>
#import <WebKit/IFMainURLHandleClient.h>
-
+#import <WebKit/IFMIMEDatabase.h>
#import <WebKit/WebKitDebug.h>
+#import <WebKit/IFContentHandler.h>
#include <khtmlview.h>
-static NSString *imageDocumentTemplate = NULL;
-static pthread_once_t imageDocumentTemplateControl = PTHREAD_ONCE_INIT;
-
-static void loadImageDocumentTemplate()
-{
- NSString *path;
- NSBundle *bundle;
- NSData *data;
-
- bundle = [NSBundle bundleForClass:[IFMainURLHandleClient class]];
- if ((path = [bundle pathForResource:@"image_document_template" ofType:@"html"])) {
- data = [[NSData alloc] initWithContentsOfFile:path];
- if (data) {
- imageDocumentTemplate = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
- [data release];
- }
- }
-}
-
@implementation IFMainURLHandleClient
- initWithDataSource: (IFWebDataSource *)ds part:(KHTMLPart *)p
@@ -41,6 +23,7 @@ static void loadImageDocumentTemplate()
part = p;
part->ref();
sentFakeDocForNonHTMLContentType = NO;
+ typeChecked = NO;
return self;
}
@@ -51,6 +34,7 @@ static void loadImageDocumentTemplate()
{
part->deref();
[dataSource release];
+ [mimeHandler release];
[super dealloc];
}
@@ -73,8 +57,20 @@ static void loadImageDocumentTemplate()
- (void)IFURLHandleResourceDidFinishLoading:(IFURLHandle *)sender data: (NSData *)data
{
+ NSString *fakeHTMLDocument;
+ const char *fakeHTMLDocumentBytes;
+ IFContentHandler *contentHandler;
+
WEBKITDEBUGLEVEL (WEBKIT_LOG_LOADING, "url = %s\n", [[[sender url] absoluteString] cString]);
+ if([mimeHandler 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];
+ }
+
IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
loadProgress->totalToLoad = [data length];
loadProgress->bytesSoFar = [data length];
@@ -84,57 +80,62 @@ static void loadImageDocumentTemplate()
- (void)IFURLHandle:(IFURLHandle *)sender resourceDataDidBecomeAvailable:(NSData *)data
{
- BOOL handled;
-
NSString *fakeHTMLDocument;
const char *fakeHTMLDocumentBytes;
- NSString *urlString;
-
+ IFMIMEDatabase *mimeDatabase;
+ IFContentHandler *contentHandler;
+
WEBKITDEBUGLEVEL (WEBKIT_LOG_LOADING, "url = %s, data = %p, length %d\n", [[[sender url] absoluteString] cString], data, [data length]);
-
- // did we handle this content type?
- handled = NO;
- //FIXME: This is a temporary hack to make sure we don't load non-html content.
- //Since the cache returns nil for contentType when the URL is in the cache (2892912),
- //I assume the contentType is text/html for that case.
- NSString *contentType = [sender contentType];
- if(contentType == nil || [contentType isEqualToString:@"text/html"]) {
+ // check the mime type
+ if(!typeChecked){
+ mimeDatabase = [IFMIMEDatabase sharedMIMEDatabase];
+ mimeHandler = [[mimeDatabase MIMEHandlerForMIMEType:[sender contentType]] retain];
+ typeChecked = YES;
+ }
+
+ // if it's html, send the data to the part
+ // FIXME: [sender contentType] still returns nil if from cache
+ if([mimeHandler handlerType] == IFMIMEHANDLERTYPE_NIL || [mimeHandler handlerType] == IFMIMEHANDLERTYPE_HTML) {
part->slotData(sender, (const char *)[data bytes], [data length]);
- handled = YES;
}
- // handle images
- else if ([contentType isEqualToString:@"image/gif"] || [contentType isEqualToString:@"image/jpeg"] || [contentType isEqualToString:@"image/png"]) {
+
+ // for non-html documents, create html doc that embeds them
+ else if([mimeHandler handlerType] == IFMIMEHANDLERTYPE_IMAGE ||
+ [mimeHandler handlerType] == IFMIMEHANDLERTYPE_PLUGIN ||
+ [mimeHandler handlerType] == IFMIMEHANDLERTYPE_TEXT) {
if (!sentFakeDocForNonHTMLContentType) {
- pthread_once(&imageDocumentTemplateControl, loadImageDocumentTemplate);
- if (imageDocumentTemplate) {
- urlString = [[sender url] absoluteString];
- fakeHTMLDocument = [NSString stringWithFormat:imageDocumentTemplate, urlString, urlString];
- fakeHTMLDocumentBytes = [fakeHTMLDocument cString];
- part->slotData(sender, (const char *)fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes));
- }
+ contentHandler = [[IFContentHandler alloc] initWithMIMEHandler:mimeHandler URL:[sender url]];
+ fakeHTMLDocument = [contentHandler HTMLDocument];
+ fakeHTMLDocumentBytes = [fakeHTMLDocument cString];
+ part->slotData(sender, (const char *)fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes));
+ sentFakeDocForNonHTMLContentType = YES;
+ [contentHandler release];
+ }
+
+ // for text documents, the incoming data is part of the main page
+ if([mimeHandler handlerType] == IFMIMEHANDLERTYPE_TEXT){
+ part->slotData(sender, (const char *)[data bytes], [data length]);
}
- handled = YES;
- sentFakeDocForNonHTMLContentType = YES;
- }
-
- if (handled) {
- // update progress
- IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
- loadProgress->totalToLoad = [sender contentLength];
- loadProgress->bytesSoFar = [sender contentLengthReceived];
- [[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress forResource: [[sender url] absoluteString] fromDataSource: dataSource];
- [loadProgress release];
}
- else {
- // we do not handle this content type
- // cancel load
+
+ // FIXME: download code goes here, stop reporting error
+ else{
[sender cancelLoadInBackground];
- IFError *error = [[IFError alloc] initWithErrorCode: IFNonHTMLContentNotSupportedError failingURL: [sender url]];
- [[dataSource controller] _mainReceivedError: error forResource: [[sender url] absoluteString] partialProgress:nil fromDataSource: dataSource];
+ IFError *error = [[IFError alloc] initWithErrorCode: IFFileDownloadNotSupportedError failingURL: [sender url]];
+ [[dataSource controller] _mainReceivedError: error
+ forResource: [[sender url] absoluteString] partialProgress:nil fromDataSource: dataSource];
[error release];
+ return;
}
+ // update progress
+ IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
+ loadProgress->totalToLoad = [sender contentLength];
+ loadProgress->bytesSoFar = [sender contentLengthReceived];
+ [[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress
+ forResource: [[sender url] absoluteString] fromDataSource: dataSource];
+ [loadProgress release];
}
- (void)IFURLHandle:(IFURLHandle *)sender resourceDidFailLoadingWithResult:(int)result
@@ -160,4 +161,5 @@ static void loadImageDocumentTemplate()
[[dataSource controller] serverRedirectTo: url forDataSource: dataSource];
}
+
@end
diff --git a/WebKit/WebView.subproj/WebMainResourceLoader.h b/WebKit/WebView.subproj/WebMainResourceLoader.h
index 597b78c..b3bfefb 100644
--- a/WebKit/WebView.subproj/WebMainResourceLoader.h
+++ b/WebKit/WebView.subproj/WebMainResourceLoader.h
@@ -11,12 +11,14 @@
#import <WebFoundation/WebFoundation.h>
#import <WebKit/IFWebDataSourcePrivate.h>
+#import <WebKit/IFMIMEHandler.h>
@interface IFMainURLHandleClient : NSObject <IFURLHandleClient>
{
id dataSource;
KHTMLPart *part;
- BOOL sentFakeDocForNonHTMLContentType;
+ BOOL sentFakeDocForNonHTMLContentType, typeChecked;
+ IFMIMEHandler *mimeHandler;
}
- initWithDataSource: (IFWebDataSource *)ds part: (KHTMLPart *)p;
@end
diff --git a/WebKit/WebView.subproj/WebMainResourceLoader.m b/WebKit/WebView.subproj/WebMainResourceLoader.m
index 2d61d80..1042146 100644
--- a/WebKit/WebView.subproj/WebMainResourceLoader.m
+++ b/WebKit/WebView.subproj/WebMainResourceLoader.m
@@ -8,30 +8,12 @@
#import <WebKit/IFError.h>
#import <WebKit/IFBaseWebControllerPrivate.h>
#import <WebKit/IFMainURLHandleClient.h>
-
+#import <WebKit/IFMIMEDatabase.h>
#import <WebKit/WebKitDebug.h>
+#import <WebKit/IFContentHandler.h>
#include <khtmlview.h>
-static NSString *imageDocumentTemplate = NULL;
-static pthread_once_t imageDocumentTemplateControl = PTHREAD_ONCE_INIT;
-
-static void loadImageDocumentTemplate()
-{
- NSString *path;
- NSBundle *bundle;
- NSData *data;
-
- bundle = [NSBundle bundleForClass:[IFMainURLHandleClient class]];
- if ((path = [bundle pathForResource:@"image_document_template" ofType:@"html"])) {
- data = [[NSData alloc] initWithContentsOfFile:path];
- if (data) {
- imageDocumentTemplate = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
- [data release];
- }
- }
-}
-
@implementation IFMainURLHandleClient
- initWithDataSource: (IFWebDataSource *)ds part:(KHTMLPart *)p
@@ -41,6 +23,7 @@ static void loadImageDocumentTemplate()
part = p;
part->ref();
sentFakeDocForNonHTMLContentType = NO;
+ typeChecked = NO;
return self;
}
@@ -51,6 +34,7 @@ static void loadImageDocumentTemplate()
{
part->deref();
[dataSource release];
+ [mimeHandler release];
[super dealloc];
}
@@ -73,8 +57,20 @@ static void loadImageDocumentTemplate()
- (void)IFURLHandleResourceDidFinishLoading:(IFURLHandle *)sender data: (NSData *)data
{
+ NSString *fakeHTMLDocument;
+ const char *fakeHTMLDocumentBytes;
+ IFContentHandler *contentHandler;
+
WEBKITDEBUGLEVEL (WEBKIT_LOG_LOADING, "url = %s\n", [[[sender url] absoluteString] cString]);
+ if([mimeHandler 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];
+ }
+
IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
loadProgress->totalToLoad = [data length];
loadProgress->bytesSoFar = [data length];
@@ -84,57 +80,62 @@ static void loadImageDocumentTemplate()
- (void)IFURLHandle:(IFURLHandle *)sender resourceDataDidBecomeAvailable:(NSData *)data
{
- BOOL handled;
-
NSString *fakeHTMLDocument;
const char *fakeHTMLDocumentBytes;
- NSString *urlString;
-
+ IFMIMEDatabase *mimeDatabase;
+ IFContentHandler *contentHandler;
+
WEBKITDEBUGLEVEL (WEBKIT_LOG_LOADING, "url = %s, data = %p, length %d\n", [[[sender url] absoluteString] cString], data, [data length]);
-
- // did we handle this content type?
- handled = NO;
- //FIXME: This is a temporary hack to make sure we don't load non-html content.
- //Since the cache returns nil for contentType when the URL is in the cache (2892912),
- //I assume the contentType is text/html for that case.
- NSString *contentType = [sender contentType];
- if(contentType == nil || [contentType isEqualToString:@"text/html"]) {
+ // check the mime type
+ if(!typeChecked){
+ mimeDatabase = [IFMIMEDatabase sharedMIMEDatabase];
+ mimeHandler = [[mimeDatabase MIMEHandlerForMIMEType:[sender contentType]] retain];
+ typeChecked = YES;
+ }
+
+ // if it's html, send the data to the part
+ // FIXME: [sender contentType] still returns nil if from cache
+ if([mimeHandler handlerType] == IFMIMEHANDLERTYPE_NIL || [mimeHandler handlerType] == IFMIMEHANDLERTYPE_HTML) {
part->slotData(sender, (const char *)[data bytes], [data length]);
- handled = YES;
}
- // handle images
- else if ([contentType isEqualToString:@"image/gif"] || [contentType isEqualToString:@"image/jpeg"] || [contentType isEqualToString:@"image/png"]) {
+
+ // for non-html documents, create html doc that embeds them
+ else if([mimeHandler handlerType] == IFMIMEHANDLERTYPE_IMAGE ||
+ [mimeHandler handlerType] == IFMIMEHANDLERTYPE_PLUGIN ||
+ [mimeHandler handlerType] == IFMIMEHANDLERTYPE_TEXT) {
if (!sentFakeDocForNonHTMLContentType) {
- pthread_once(&imageDocumentTemplateControl, loadImageDocumentTemplate);
- if (imageDocumentTemplate) {
- urlString = [[sender url] absoluteString];
- fakeHTMLDocument = [NSString stringWithFormat:imageDocumentTemplate, urlString, urlString];
- fakeHTMLDocumentBytes = [fakeHTMLDocument cString];
- part->slotData(sender, (const char *)fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes));
- }
+ contentHandler = [[IFContentHandler alloc] initWithMIMEHandler:mimeHandler URL:[sender url]];
+ fakeHTMLDocument = [contentHandler HTMLDocument];
+ fakeHTMLDocumentBytes = [fakeHTMLDocument cString];
+ part->slotData(sender, (const char *)fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes));
+ sentFakeDocForNonHTMLContentType = YES;
+ [contentHandler release];
+ }
+
+ // for text documents, the incoming data is part of the main page
+ if([mimeHandler handlerType] == IFMIMEHANDLERTYPE_TEXT){
+ part->slotData(sender, (const char *)[data bytes], [data length]);
}
- handled = YES;
- sentFakeDocForNonHTMLContentType = YES;
- }
-
- if (handled) {
- // update progress
- IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
- loadProgress->totalToLoad = [sender contentLength];
- loadProgress->bytesSoFar = [sender contentLengthReceived];
- [[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress forResource: [[sender url] absoluteString] fromDataSource: dataSource];
- [loadProgress release];
}
- else {
- // we do not handle this content type
- // cancel load
+
+ // FIXME: download code goes here, stop reporting error
+ else{
[sender cancelLoadInBackground];
- IFError *error = [[IFError alloc] initWithErrorCode: IFNonHTMLContentNotSupportedError failingURL: [sender url]];
- [[dataSource controller] _mainReceivedError: error forResource: [[sender url] absoluteString] partialProgress:nil fromDataSource: dataSource];
+ IFError *error = [[IFError alloc] initWithErrorCode: IFFileDownloadNotSupportedError failingURL: [sender url]];
+ [[dataSource controller] _mainReceivedError: error
+ forResource: [[sender url] absoluteString] partialProgress:nil fromDataSource: dataSource];
[error release];
+ return;
}
+ // update progress
+ IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
+ loadProgress->totalToLoad = [sender contentLength];
+ loadProgress->bytesSoFar = [sender contentLengthReceived];
+ [[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress
+ forResource: [[sender url] absoluteString] fromDataSource: dataSource];
+ [loadProgress release];
}
- (void)IFURLHandle:(IFURLHandle *)sender resourceDidFailLoadingWithResult:(int)result
@@ -160,4 +161,5 @@ static void loadImageDocumentTemplate()
[[dataSource controller] serverRedirectTo: url forDataSource: dataSource];
}
+
@end
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list