Commit 61d1c337 authored by mjs's avatar mjs
Browse files

WebKit:

	Combined file URL policy with content policy. We don't actually
	bother to ask earlier for file URLs yet, since that will make
	things more complicated.

        * Misc.subproj/WebKitErrors.h:
        * WebView.subproj/WebControllerPolicyDelegate.h:
        * WebView.subproj/WebDefaultPolicyDelegate.m:
        * WebView.subproj/WebFramePrivate.h:
        * WebView.subproj/WebFramePrivate.m:
        (-[WebFrame _handleUnimplementablePolicy:errorCode:forURL:]):
        (-[WebFrame _continueAfterNavigationPolicyForRequest:dataSource:]):
        * WebView.subproj/WebMainResourceClient.h:
        * WebView.subproj/WebMainResourceClient.m:
        (-[WebMainResourceClient stopLoadingAfterContentPolicy]):
        (-[WebMainResourceClient handle:didReceiveResponse:]):
        * WebView.subproj/WebView.m:
        (+[WebView initialize]):

WebBrowser:

	Combined file URL policy with content policy. Also adjusted error
	handling to continue to handle file errors well.

        * BrowserWebController.m:
        (-[BrowserWebController unableToImplementPolicy:error:forURL:inFrame:]):
        (-[BrowserWebController contentPolicyForMIMEType:andRequest:inFrame:]):
        * LocationChangeError.m:
        (-[LocationChangeHandler specializedTitleForError:]):
        (-[LocationChangeHandler specializedMessageForError:]):
        * LocationChangeHandler.m:
        (-[LocationChangeHandler locationChangeDone:forDataSource:]):
        * WebBrowser.pbproj/project.pbxproj:


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