From 59b76c88ef6719b3f24ec65cdbd7603243db3fb6 Mon Sep 17 00:00:00 2001 From: "seawood%netscape.com" Date: Tue, 19 Nov 2002 05:16:50 +0000 Subject: [PATCH] Add native app support for OSX mach-o builds. Fixes the 'Quit from dock not working' problem. Allows certain files to be dragged to the dock icon. Thanks to Mike Pinkerton for the original patch. Bug #111797 r=ccarlen sr=sfraser git-svn-id: svn://10.0.0.236/trunk@134083 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpfe/Makefile.in | 4 + mozilla/xpfe/appshell/public/Makefile.in | 4 + mozilla/xpfe/appshell/src/Makefile.in | 14 ++- .../appshell/src/nsCommandLineService.cpp | 8 ++ .../appshell/src/nsCommandLineServiceMac.cpp | 79 +++++++++++----- mozilla/xpfe/bootstrap/Makefile.in | 4 + .../xpfe/bootstrap/appleevents/Makefile.in | 94 +++++++++++++++++++ .../bootstrap/appleevents/PatriciaTree.cpp | 2 +- .../xpfe/bootstrap/appleevents/nsMacUtils.cpp | 2 +- mozilla/xpfe/bootstrap/nsAppRunner.cpp | 2 +- .../xpfe/bootstrap/nsNativeAppSupportMac.cpp | 2 +- .../startup/src/nsCommandLineService.cpp | 8 ++ .../startup/src/nsCommandLineServiceMac.cpp | 79 +++++++++++----- 13 files changed, 255 insertions(+), 47 deletions(-) create mode 100644 mozilla/xpfe/bootstrap/appleevents/Makefile.in diff --git a/mozilla/xpfe/Makefile.in b/mozilla/xpfe/Makefile.in index a592465cfad..58f08eb5f45 100644 --- a/mozilla/xpfe/Makefile.in +++ b/mozilla/xpfe/Makefile.in @@ -28,5 +28,9 @@ include $(DEPTH)/config/autoconf.mk DIRS = appshell browser components communicator global +ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT))) +DIRS := bootstrap/appleevents $(DIRS) +endif + include $(topsrcdir)/config/rules.mk diff --git a/mozilla/xpfe/appshell/public/Makefile.in b/mozilla/xpfe/appshell/public/Makefile.in index 3f75cdbfb9b..3679f9f90ad 100644 --- a/mozilla/xpfe/appshell/public/Makefile.in +++ b/mozilla/xpfe/appshell/public/Makefile.in @@ -51,6 +51,10 @@ XPIDLSRCS = \ ifeq ($(MOZ_WIDGET_TOOLKIT),windows) XPIDLSRCS += nsINativeAppSupportWin.idl endif +ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT))) +EXPORTS += nsAppleEvents.h +XPIDLSRCS += nsICloseAllWindows.idl +endif include $(topsrcdir)/config/rules.mk diff --git a/mozilla/xpfe/appshell/src/Makefile.in b/mozilla/xpfe/appshell/src/Makefile.in index 7018ba20e25..e6a0aa90eea 100644 --- a/mozilla/xpfe/appshell/src/Makefile.in +++ b/mozilla/xpfe/appshell/src/Makefile.in @@ -56,6 +56,7 @@ REQUIRES = xpcom \ profile \ unicharutil \ embed_base \ + exthandler \ $(NULL) CPPSRCS = \ @@ -78,9 +79,18 @@ else ifeq ($(OS_ARCH),WINNT) CPPSRCS += nsUserInfoWin.cpp else +ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT))) +CPPSRCS += \ + nsUserInfoMac.cpp \ + nsCommandLineServiceMac.cpp \ + $(NULL) +OS_CXXFLAGS += -fexceptions +EXTRA_COMPONENTS += nsCloseAllWindows.js +else CPPSRCS += nsUserInfoUnix.cpp endif endif +endif ifeq ($(OS_ARCH),WINNT) EXTRA_DSO_LIBS = gkgfx @@ -95,7 +105,9 @@ EXTRA_DSO_LDOPTS = \ $(NULL) ifeq (,$(filter-out mac cocoa,$(MOZ_WIDGET_TOOLKIT))) -EXTRA_DSO_LDOPTS += $(TK_LIBS) +SHARED_LIBRARY_LIBS = $(DIST)/lib/$(LIB_PREFIX)appleevents_s.$(LIB_SUFFIX) +EXTRA_DSO_LDOPTS += $(TK_LIBS) +LOCAL_INCLUDES = -I$(srcdir)/../../bootstrap/appleevents endif include $(topsrcdir)/config/rules.mk diff --git a/mozilla/xpfe/appshell/src/nsCommandLineService.cpp b/mozilla/xpfe/appshell/src/nsCommandLineService.cpp index de10af070f0..38ffd39e11f 100644 --- a/mozilla/xpfe/appshell/src/nsCommandLineService.cpp +++ b/mozilla/xpfe/appshell/src/nsCommandLineService.cpp @@ -43,6 +43,9 @@ #include "nsString.h" #include "plstr.h" #include "nsNetUtil.h" +#ifdef XP_MACOSX +#include "nsCommandLineServiceMac.h" +#endif nsCmdLineService::nsCmdLineService() : mArgCount(0), mArgc(0), mArgv(0) @@ -95,6 +98,11 @@ nsCmdLineService::Initialize(int aArgc, char ** aArgv) PRInt32 i=0; nsresult rv = nsnull; +#ifdef XP_MACOSX + rv = InitializeMacCommandLine(aArgc, aArgv); + NS_ASSERTION(NS_SUCCEEDED(rv), "Initializing AppleEvents failed"); +#endif + // Save aArgc and argv mArgc = aArgc; mArgv = new char*[ aArgc ]; diff --git a/mozilla/xpfe/appshell/src/nsCommandLineServiceMac.cpp b/mozilla/xpfe/appshell/src/nsCommandLineServiceMac.cpp index cedfacfd233..3ee47c75bdc 100644 --- a/mozilla/xpfe/appshell/src/nsCommandLineServiceMac.cpp +++ b/mozilla/xpfe/appshell/src/nsCommandLineServiceMac.cpp @@ -42,6 +42,8 @@ #include "nsCommandLineServiceMac.h" // Mozilla +#include "nsDebug.h" +#include "nsILocalFileMac.h" #include "nsFileSpec.h" #include "nsFileStream.h" #include "nsDebug.h" @@ -69,7 +71,9 @@ #include "prmem.h" #include "plstr.h" #include "prenv.h" +#ifdef XP_MAC #include "pprio.h" // PR_Init_Log +#endif #include "nsAppShellCIDs.h" static NS_DEFINE_IID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID); @@ -77,6 +81,33 @@ static NS_DEFINE_IID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID); // the static instance nsMacCommandLine nsMacCommandLine::sMacCommandLine; +/* + * ReadLine -- + * + * Read in a line of text, terminated by CR or LF, from inStream into buf. + * The terminating CR or LF is not included. The text in buf is terminated + * by a null byte. + * Returns the number of bytes in buf. If EOF and zero bytes were read, returns -1. + */ + +static PRInt32 ReadLine(FILE* inStream, char* buf, PRInt32 bufSize) +{ + PRInt32 charsRead = 0; + int c; + + if (bufSize < 2) + return -1; + + while (charsRead < (bufSize-1)) { + c = getc(inStream); + if (c == EOF || c == '\n' || c == '\r') + break; + buf[charsRead++] = c; + } + buf[charsRead] = '\0'; + + return (c == EOF && !charsRead) ? -1 : charsRead; +} //---------------------------------------------------------------------------------------- nsMacCommandLine::nsMacCommandLine() @@ -105,11 +136,19 @@ nsresult nsMacCommandLine::Initialize(int& argc, char**& argv) typedef char* charP; mArgs = new charP[kMaxTokens]; mArgs[0] = nsnull; - argc = 0; - argv = mArgs; - + +#if defined(XP_MACOSX) + // Here, we may actually get useful args. + // Copy them before we reset argc & argv. + for (int arg = 0; arg < argc; arg++) + AddToCommandLine(argv[arg]); +#else // init the args buffer with the program name mTempArgsString.Assign("mozilla"); +#endif + + argc = 0; + argv = mArgs; // Set up AppleEvent handling. OSErr err = CreateAEHandlerClasses(false); @@ -223,23 +262,28 @@ nsresult nsMacCommandLine::AddToEnvironmentVars(const char* inArgText) OSErr nsMacCommandLine::HandleOpenOneDoc(const FSSpec& inFileSpec, OSType inFileType) //---------------------------------------------------------------------------------------- { + nsCOMPtr inFile; + nsresult rv = NS_NewLocalFileWithFSSpec(&inFileSpec, PR_TRUE, getter_AddRefs(inFile)); + if (NS_FAILED(rv)) + return errAEEventNotHandled; + if (!mStartedUp) { // Is it the right type to be a command-line file? if (inFileType == 'TEXT' || inFileType == 'CMDL') { // Can we open the file? - nsInputFileStream s(inFileSpec); - if (s.is_open()) + FILE *fp = 0; + rv = inFile->OpenANSIFileDesc("r", &fp); + if (NS_SUCCEEDED(rv)) { Boolean foundArgs = false; Boolean foundEnv = false; char chars[1024]; static const char kCommandLinePrefix[] = "ARGS:"; static const char kEnvVarLinePrefix[] = "ENV:"; - s.readline(chars, sizeof(chars)); - do + while (ReadLine(fp, chars, sizeof(chars)) != -1) { // See if there are any command line or environment var settings if (PL_strstr(chars, kCommandLinePrefix) == chars) { @@ -251,17 +295,15 @@ OSErr nsMacCommandLine::HandleOpenOneDoc(const FSSpec& inFileSpec, OSType inFile (void)AddToEnvironmentVars(chars + sizeof(kEnvVarLinePrefix) - 1); foundEnv = true; } + } - // Clear the buffer and get the next line from the command line file - chars[0] = '\0'; - s.readline(chars, sizeof(chars)); - } while (chars && (chars[0] != '\0')); - + fclose(fp); +#ifndef XP_MACOSX // If we found any environment vars we need to re-init NSPR's logging // so that it knows what the new vars are if (foundEnv) PR_Init_Log(); - +#endif // If we found a command line or environment vars we want to return now // raather than trying to open the file as a URL if (foundArgs || foundEnv) @@ -274,13 +316,8 @@ OSErr nsMacCommandLine::HandleOpenOneDoc(const FSSpec& inFileSpec, OSType inFile // way as if they had been typed on the command line in Unix or DOS. return AddToCommandLine("-url", inFileSpec); } + // Final case: we're not just starting up. How do we handle this? - nsresult rv; - FSSpec nonConstSpec = inFileSpec; - nsCOMPtr inFile; - rv = NS_NewLocalFileWithFSSpec(&nonConstSpec, PR_TRUE, getter_AddRefs(inFile)); - if (NS_FAILED(rv)) - return errAEEventNotHandled; nsCAutoString specBuf; rv = NS_GetURLSpecFromFile(inFile, specBuf); if (NS_FAILED(rv)) @@ -337,13 +374,13 @@ nsresult nsMacCommandLine::OpenWindow(const char *chrome, const PRUnichar *url) OSErr nsMacCommandLine::DispatchURLToNewBrowser(const char* url) //---------------------------------------------------------------------------------------- { - OSErr err; + OSErr err = errAEEventNotHandled; if (mStartedUp) { nsresult rv; rv = OpenWindow("chrome://navigator/content", NS_ConvertASCIItoUCS2(url).get()); if (NS_FAILED(rv)) - return errAEEventNotHandled; + return err; } else err = AddToCommandLine(url); diff --git a/mozilla/xpfe/bootstrap/Makefile.in b/mozilla/xpfe/bootstrap/Makefile.in index 20588332b4e..62e8b6a0bd0 100644 --- a/mozilla/xpfe/bootstrap/Makefile.in +++ b/mozilla/xpfe/bootstrap/Makefile.in @@ -160,6 +160,8 @@ RESFILE = splashos2.res endif ifeq ($(MOZ_WIDGET_TOOLKIT),mac) +CPPSRCS += nsNativeAppSupportMac.cpp +CPPSRCS += nsNativeAppSupportBase.cpp LIBS += $(TK_LIBS) endif @@ -344,6 +346,8 @@ endif ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT))) +INCLUDES += -I$(srcdir)/../appshell/src -I$(srcdir)/appleevents + ifdef MOZ_DEBUG APP_NAME = MozillaDebug else diff --git a/mozilla/xpfe/bootstrap/appleevents/Makefile.in b/mozilla/xpfe/bootstrap/appleevents/Makefile.in new file mode 100644 index 00000000000..54458cdb987 --- /dev/null +++ b/mozilla/xpfe/bootstrap/appleevents/Makefile.in @@ -0,0 +1,94 @@ +# +# The contents of this file are subject to the Netscape Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/NPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1998 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): +# + +DEPTH = ../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +MODULE = appleevents +LIBRARY_NAME = appleevents_s +REQUIRES = xpcom \ + string \ + dom \ + content \ + gfx \ + widget \ + locale \ + view \ + necko \ + webshell \ + pref \ + docshell \ + plugin \ + xuldoc \ + imglib2 \ + gfx2 \ + webbrwsr \ + appshell \ + layout \ + caps \ + uriloader \ + $(NULL) + +# PatriciaTree.cpp \ +# nsAppleEventsService.cpp \ + +CSRCS = \ + patricia.c \ + $(NULL) + +CPPSRCS = \ + nsAEApplicationClass.cpp \ + nsAEClassDispatcher.cpp \ + nsAEClassIterator.cpp \ + nsAECoercionHandlers.cpp \ + nsAECompare.cpp \ + nsAECoreClass.cpp \ + nsAEDocumentClass.cpp \ + nsAEEventHandling.cpp \ + nsAEGenericClass.cpp \ + nsAEGetURLSuiteHandler.cpp \ + nsAEMozillaSuiteHandler.cpp \ + nsAESpyglassSuiteHandler.cpp \ + nsAETokens.cpp \ + nsAEUtils.cpp \ + nsAEWindowClass.cpp \ + nsMacUtils.cpp \ + nsWindowUtils.cpp \ + ../nsDocLoadObserver.cpp \ + $(NULL) + + +# we don't want the shared lib, but we want to force the creation of a static lib. +FORCE_STATIC_LIB = 1 + +LOCAL_INCLUDES = \ + -I$(srcdir) \ + -I$(srcdir)/.. \ + -I$(srcdir)/../../appshell/src/ \ + $(NULL) + +include $(topsrcdir)/config/rules.mk + +OS_CXXFLAGS += -fexceptions diff --git a/mozilla/xpfe/bootstrap/appleevents/PatriciaTree.cpp b/mozilla/xpfe/bootstrap/appleevents/PatriciaTree.cpp index d354d94a047..d8e904298fb 100644 --- a/mozilla/xpfe/bootstrap/appleevents/PatriciaTree.cpp +++ b/mozilla/xpfe/bootstrap/appleevents/PatriciaTree.cpp @@ -37,7 +37,7 @@ * ***** END LICENSE BLOCK ***** */ -#include "AEUtils.h" +#include #include "PatriciaTree.h" diff --git a/mozilla/xpfe/bootstrap/appleevents/nsMacUtils.cpp b/mozilla/xpfe/bootstrap/appleevents/nsMacUtils.cpp index 4a3eb93bc3a..52bff1a1fd8 100644 --- a/mozilla/xpfe/bootstrap/appleevents/nsMacUtils.cpp +++ b/mozilla/xpfe/bootstrap/appleevents/nsMacUtils.cpp @@ -181,7 +181,7 @@ OSErr GetShortVersionString(short rID, StringPtr version) error = noErr; } else - CopyPascalString(version, "\p"); + CopyPascalString(version, (StringPtr)"\p"); return error; } diff --git a/mozilla/xpfe/bootstrap/nsAppRunner.cpp b/mozilla/xpfe/bootstrap/nsAppRunner.cpp index 9d23bb4fecf..1e5940dde63 100644 --- a/mozilla/xpfe/bootstrap/nsAppRunner.cpp +++ b/mozilla/xpfe/bootstrap/nsAppRunner.cpp @@ -380,7 +380,7 @@ PRBool NS_CanRun() // nsISplashScreen will be removed. // -#if !defined( XP_PC ) && !defined(MOZ_WIDGET_GTK) && !defined(XP_MAC) +#if !defined( XP_PC ) && !defined(MOZ_WIDGET_GTK) && !defined(XP_MAC) && !defined(XP_MACOSX) nsresult NS_CreateNativeAppSupport(nsINativeAppSupport **aResult) { diff --git a/mozilla/xpfe/bootstrap/nsNativeAppSupportMac.cpp b/mozilla/xpfe/bootstrap/nsNativeAppSupportMac.cpp index 959dc6c7195..4d421057bd8 100644 --- a/mozilla/xpfe/bootstrap/nsNativeAppSupportMac.cpp +++ b/mozilla/xpfe/bootstrap/nsNativeAppSupportMac.cpp @@ -468,7 +468,7 @@ nsNativeAppSupportMac::ReOpen() nsCOMPtr appShell(do_GetService(kAppShellServiceCID, &rv)); if (!rv) { - PRBool openedAWindow; + //PRBool openedAWindow; // uncomment when bug 109811 is fixed //appShell->DoCommandLines(cmdLineArgs, true, &openedAWindow); } diff --git a/mozilla/xpfe/components/startup/src/nsCommandLineService.cpp b/mozilla/xpfe/components/startup/src/nsCommandLineService.cpp index de10af070f0..38ffd39e11f 100644 --- a/mozilla/xpfe/components/startup/src/nsCommandLineService.cpp +++ b/mozilla/xpfe/components/startup/src/nsCommandLineService.cpp @@ -43,6 +43,9 @@ #include "nsString.h" #include "plstr.h" #include "nsNetUtil.h" +#ifdef XP_MACOSX +#include "nsCommandLineServiceMac.h" +#endif nsCmdLineService::nsCmdLineService() : mArgCount(0), mArgc(0), mArgv(0) @@ -95,6 +98,11 @@ nsCmdLineService::Initialize(int aArgc, char ** aArgv) PRInt32 i=0; nsresult rv = nsnull; +#ifdef XP_MACOSX + rv = InitializeMacCommandLine(aArgc, aArgv); + NS_ASSERTION(NS_SUCCEEDED(rv), "Initializing AppleEvents failed"); +#endif + // Save aArgc and argv mArgc = aArgc; mArgv = new char*[ aArgc ]; diff --git a/mozilla/xpfe/components/startup/src/nsCommandLineServiceMac.cpp b/mozilla/xpfe/components/startup/src/nsCommandLineServiceMac.cpp index cedfacfd233..3ee47c75bdc 100644 --- a/mozilla/xpfe/components/startup/src/nsCommandLineServiceMac.cpp +++ b/mozilla/xpfe/components/startup/src/nsCommandLineServiceMac.cpp @@ -42,6 +42,8 @@ #include "nsCommandLineServiceMac.h" // Mozilla +#include "nsDebug.h" +#include "nsILocalFileMac.h" #include "nsFileSpec.h" #include "nsFileStream.h" #include "nsDebug.h" @@ -69,7 +71,9 @@ #include "prmem.h" #include "plstr.h" #include "prenv.h" +#ifdef XP_MAC #include "pprio.h" // PR_Init_Log +#endif #include "nsAppShellCIDs.h" static NS_DEFINE_IID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID); @@ -77,6 +81,33 @@ static NS_DEFINE_IID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID); // the static instance nsMacCommandLine nsMacCommandLine::sMacCommandLine; +/* + * ReadLine -- + * + * Read in a line of text, terminated by CR or LF, from inStream into buf. + * The terminating CR or LF is not included. The text in buf is terminated + * by a null byte. + * Returns the number of bytes in buf. If EOF and zero bytes were read, returns -1. + */ + +static PRInt32 ReadLine(FILE* inStream, char* buf, PRInt32 bufSize) +{ + PRInt32 charsRead = 0; + int c; + + if (bufSize < 2) + return -1; + + while (charsRead < (bufSize-1)) { + c = getc(inStream); + if (c == EOF || c == '\n' || c == '\r') + break; + buf[charsRead++] = c; + } + buf[charsRead] = '\0'; + + return (c == EOF && !charsRead) ? -1 : charsRead; +} //---------------------------------------------------------------------------------------- nsMacCommandLine::nsMacCommandLine() @@ -105,11 +136,19 @@ nsresult nsMacCommandLine::Initialize(int& argc, char**& argv) typedef char* charP; mArgs = new charP[kMaxTokens]; mArgs[0] = nsnull; - argc = 0; - argv = mArgs; - + +#if defined(XP_MACOSX) + // Here, we may actually get useful args. + // Copy them before we reset argc & argv. + for (int arg = 0; arg < argc; arg++) + AddToCommandLine(argv[arg]); +#else // init the args buffer with the program name mTempArgsString.Assign("mozilla"); +#endif + + argc = 0; + argv = mArgs; // Set up AppleEvent handling. OSErr err = CreateAEHandlerClasses(false); @@ -223,23 +262,28 @@ nsresult nsMacCommandLine::AddToEnvironmentVars(const char* inArgText) OSErr nsMacCommandLine::HandleOpenOneDoc(const FSSpec& inFileSpec, OSType inFileType) //---------------------------------------------------------------------------------------- { + nsCOMPtr inFile; + nsresult rv = NS_NewLocalFileWithFSSpec(&inFileSpec, PR_TRUE, getter_AddRefs(inFile)); + if (NS_FAILED(rv)) + return errAEEventNotHandled; + if (!mStartedUp) { // Is it the right type to be a command-line file? if (inFileType == 'TEXT' || inFileType == 'CMDL') { // Can we open the file? - nsInputFileStream s(inFileSpec); - if (s.is_open()) + FILE *fp = 0; + rv = inFile->OpenANSIFileDesc("r", &fp); + if (NS_SUCCEEDED(rv)) { Boolean foundArgs = false; Boolean foundEnv = false; char chars[1024]; static const char kCommandLinePrefix[] = "ARGS:"; static const char kEnvVarLinePrefix[] = "ENV:"; - s.readline(chars, sizeof(chars)); - do + while (ReadLine(fp, chars, sizeof(chars)) != -1) { // See if there are any command line or environment var settings if (PL_strstr(chars, kCommandLinePrefix) == chars) { @@ -251,17 +295,15 @@ OSErr nsMacCommandLine::HandleOpenOneDoc(const FSSpec& inFileSpec, OSType inFile (void)AddToEnvironmentVars(chars + sizeof(kEnvVarLinePrefix) - 1); foundEnv = true; } + } - // Clear the buffer and get the next line from the command line file - chars[0] = '\0'; - s.readline(chars, sizeof(chars)); - } while (chars && (chars[0] != '\0')); - + fclose(fp); +#ifndef XP_MACOSX // If we found any environment vars we need to re-init NSPR's logging // so that it knows what the new vars are if (foundEnv) PR_Init_Log(); - +#endif // If we found a command line or environment vars we want to return now // raather than trying to open the file as a URL if (foundArgs || foundEnv) @@ -274,13 +316,8 @@ OSErr nsMacCommandLine::HandleOpenOneDoc(const FSSpec& inFileSpec, OSType inFile // way as if they had been typed on the command line in Unix or DOS. return AddToCommandLine("-url", inFileSpec); } + // Final case: we're not just starting up. How do we handle this? - nsresult rv; - FSSpec nonConstSpec = inFileSpec; - nsCOMPtr inFile; - rv = NS_NewLocalFileWithFSSpec(&nonConstSpec, PR_TRUE, getter_AddRefs(inFile)); - if (NS_FAILED(rv)) - return errAEEventNotHandled; nsCAutoString specBuf; rv = NS_GetURLSpecFromFile(inFile, specBuf); if (NS_FAILED(rv)) @@ -337,13 +374,13 @@ nsresult nsMacCommandLine::OpenWindow(const char *chrome, const PRUnichar *url) OSErr nsMacCommandLine::DispatchURLToNewBrowser(const char* url) //---------------------------------------------------------------------------------------- { - OSErr err; + OSErr err = errAEEventNotHandled; if (mStartedUp) { nsresult rv; rv = OpenWindow("chrome://navigator/content", NS_ConvertASCIItoUCS2(url).get()); if (NS_FAILED(rv)) - return errAEEventNotHandled; + return err; } else err = AddToCommandLine(url);