зеркало из https://github.com/mozilla/pjs.git
Camino only - Bug 409538: Correctly handle .url and .webloc files opened via AppleEvents. r/sr=mento.
This commit is contained in:
Родитель
34a6a3cb6e
Коммит
e96a2aa083
|
@ -42,6 +42,7 @@
|
|||
#import <AppKit/AppKit.h>
|
||||
|
||||
#import "MainController.h"
|
||||
#import "NSURL+Utils.h"
|
||||
|
||||
static NSString* const kMainControllerIsInitializedKey = @"initialized";
|
||||
|
||||
|
@ -54,7 +55,11 @@ static NSString* const kMainControllerIsInitializedKey = @"initialized";
|
|||
// We can get here before the application is fully initialized and the previous
|
||||
// session is restored. We want to avoid opening URLs before that happens.
|
||||
if ([mainController isInitialized]) {
|
||||
[mainController showURL:[self directParameter]];
|
||||
NSString* urlString = [self directParameter];
|
||||
NSURL* url = [NSURL URLWithString:urlString];
|
||||
if ([url isFileURL])
|
||||
urlString = [[NSURL decodeLocalFileURL:url] absoluteString];
|
||||
[mainController showURL:urlString];
|
||||
}
|
||||
else {
|
||||
[self suspendExecution];
|
||||
|
|
|
@ -125,7 +125,6 @@ NSString* const kPreviousSessionTerminatedNormallyKey = @"PreviousSessionTermina
|
|||
- (void)openPanelDidEnd:(NSOpenPanel*)inOpenPanel returnCode:(int)inReturnCode contextInfo:(void*)inContextInfo;
|
||||
- (void)loadApplicationPage:(NSString*)pageURL;
|
||||
- (NSArray*)browserWindows;
|
||||
+ (NSURL*)decodeLocalFileURL:(NSURL*)url;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -756,7 +755,7 @@ NSString* const kPreviousSessionTerminatedNormallyKey = @"PreviousSessionTermina
|
|||
// session is restored. We want to avoid opening URLs before that happens.
|
||||
[self ensureInitializationCompleted];
|
||||
|
||||
NSURL* urlToOpen = [MainController decodeLocalFileURL:[NSURL fileURLWithPath:filename]];
|
||||
NSURL* urlToOpen = [NSURL decodeLocalFileURL:[NSURL fileURLWithPath:filename]];
|
||||
[self showURL:[urlToOpen absoluteString]];
|
||||
return YES;
|
||||
}
|
||||
|
@ -870,27 +869,6 @@ NSString* const kPreviousSessionTerminatedNormallyKey = @"PreviousSessionTermina
|
|||
}
|
||||
}
|
||||
|
||||
//
|
||||
// This takes an NSURL to a local file, and if that file is a file that contains
|
||||
// a URL we want and isn't the content itself, we return the URL it contains.
|
||||
// Otherwise, we return the URL we originally got. Right now this supports .url,
|
||||
// .webloc and .ftploc files.
|
||||
//
|
||||
+ (NSURL*)decodeLocalFileURL:(NSURL*)url
|
||||
{
|
||||
NSString* urlPathString = [url path];
|
||||
NSString* ext = [[urlPathString pathExtension] lowercaseString];
|
||||
OSType fileType = NSHFSTypeCodeFromFileType(NSHFSTypeOfFile(urlPathString));
|
||||
|
||||
if ([ext isEqualToString:@"url"] || fileType == 'LINK')
|
||||
url = [NSURL URLFromIEURLFile:urlPathString];
|
||||
else if ([ext isEqualToString:@"webloc"] || [ext isEqualToString:@"ftploc"] ||
|
||||
fileType == 'ilht' || fileType == 'ilft')
|
||||
url = [NSURL URLFromInetloc:urlPathString];
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Delegate/Notification
|
||||
|
||||
|
@ -1153,7 +1131,7 @@ NSString* const kPreviousSessionTerminatedNormallyKey = @"PreviousSessionTermina
|
|||
NSURL* curURL;
|
||||
while ((curURL = [urlsEnum nextObject])) {
|
||||
[[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:curURL];
|
||||
curURL = [MainController decodeLocalFileURL:curURL];
|
||||
curURL = [NSURL decodeLocalFileURL:curURL];
|
||||
[urlStringsArray addObject:[curURL absoluteString]];
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,11 @@
|
|||
|
||||
@interface NSURL (CaminoExtensions)
|
||||
|
||||
// This takes an NSURL to a local file, and if that file is a file that
|
||||
// represents a URL, returns the URL it contains. Otherwise, returns the
|
||||
// passed URL. Supports .url, .webloc and .ftploc files.
|
||||
+ (NSURL*)decodeLocalFileURL:(NSURL*)url;
|
||||
|
||||
+(NSURL*)URLFromInetloc:(NSString*)inFile;
|
||||
+(NSURL*)URLFromIEURLFile:(NSString*)inFile;
|
||||
|
||||
|
|
|
@ -40,6 +40,24 @@
|
|||
|
||||
@implementation NSURL (CaminoExtensions)
|
||||
|
||||
+ (NSURL*)decodeLocalFileURL:(NSURL*)url
|
||||
{
|
||||
NSString* urlPathString = [url path];
|
||||
NSString* ext = [[urlPathString pathExtension] lowercaseString];
|
||||
OSType fileType = NSHFSTypeCodeFromFileType(NSHFSTypeOfFile(urlPathString));
|
||||
|
||||
if ([ext isEqualToString:@"url"] || fileType == 'LINK') {
|
||||
url = [NSURL URLFromIEURLFile:urlPathString];
|
||||
}
|
||||
else if ([ext isEqualToString:@"webloc"] || [ext isEqualToString:@"ftploc"] ||
|
||||
fileType == 'ilht' || fileType == 'ilft')
|
||||
{
|
||||
url = [NSURL URLFromInetloc:urlPathString];
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
//
|
||||
// Reads the URL from a .webloc/.ftploc file.
|
||||
// Returns the URL, or nil on failure.
|
||||
|
|
Загрузка…
Ссылка в новой задаче