Bug 301281 - Remove 10.1 code from nsInternetConfigService. r=jhpedemonte, sr=smfr, a=bsmedberg.

This commit is contained in:
mozilla.mano%sent.com 2005-07-20 19:44:54 +00:00
parent f3ae3ea672
commit 4b7eb569d7
2 changed files with 41 additions and 122 deletions

View File

@ -79,10 +79,6 @@ static void ConvertCharStringToStr255(const char* inString, Str255& outString)
nsInternetConfigService::nsInternetConfigService()
{
long version;
OSErr err;
mRunningOSX = ((err = ::Gestalt(gestaltSystemVersion, &version)) == noErr && version >= 0x00001000);
mRunningJaguar = (err == noErr && version >= 0x00001020);
}
nsInternetConfigService::~nsInternetConfigService()
@ -102,9 +98,6 @@ NS_IMETHODIMP nsInternetConfigService::LaunchURL(const char *url)
{
nsresult rv = NS_ERROR_FAILURE;
#if TARGET_CARBON
if (mRunningOSX && ((UInt32)LSOpenCFURLRef != (UInt32)kUnresolvedCFragSymbolAddress))
{
CFURLRef myURLRef = ::CFURLCreateWithBytes(
kCFAllocatorDefault,
(const UInt8*)url,
@ -115,20 +108,7 @@ NS_IMETHODIMP nsInternetConfigService::LaunchURL(const char *url)
rv = ::LSOpenCFURLRef(myURLRef, NULL);
::CFRelease(myURLRef);
}
}
else
#endif
{
size_t len = strlen(url);
long selStart = 0, selEnd = len;
ICInstance inst = nsInternetConfig::GetInstance();
if (inst)
{
if (::ICLaunchURL(inst, "\p", (Ptr)url, (long)len, &selStart, &selEnd) == noErr)
rv = NS_OK;
}
}
return rv;
}
@ -153,17 +133,10 @@ NS_IMETHODIMP nsInternetConfigService::HasProtocolHandler(const char *protocol,
*_retval = PR_FALSE; // Presume failure
nsresult rv = NS_ERROR_FAILURE; // Ditto
#if TARGET_CARBON
// Use LaunchServices directly when we're running under OS X to avoid the problem of some protocols
// apparently not being reflected into the IC mappings (webcal for one). Even better it seems
// LaunchServices under 10.1.x will often fail to find an app when using LSGetApplicationForURL
// so we only use it for 10.2 or later.
// Since protocol comes in with _just_ the protocol we have to add a ':' to the end of it or
// LaunchServices will be very unhappy with the CFURLRef created from it (crashes trying to look
// up a handler for it with LSGetApplicationForURL, at least under 10.2.1)
if (mRunningJaguar)
{
// Since protocol comes in with _just_ the protocol we have to add a ':' to
// the end of it or LaunchServices will be very unhappy with the CFURLRef
// created from it (crashes trying to look up a handler for it with
// LSGetApplicationForURL, at least under 10.2.1)
nsCAutoString scheme(protocol);
scheme += ":";
CFURLRef myURLRef = ::CFURLCreateWithBytes(
@ -197,58 +170,7 @@ NS_IMETHODIMP nsInternetConfigService::HasProtocolHandler(const char *protocol,
}
::CFRelease(myURLRef);
}
}
else
#endif
{
// look for IC pref "\pHelper¥<protocol>"
Str255 pref = kICHelper;
if (nsCRT::strlen(protocol) > 248)
rv = NS_ERROR_OUT_OF_MEMORY;
else
{
memcpy(pref + pref[0] + 1, protocol, nsCRT::strlen(protocol));
pref[0] = pref[0] + nsCRT::strlen(protocol);
ICInstance instance = nsInternetConfig::GetInstance();
if (instance)
{
OSStatus err;
ICAttr junk;
ICAppSpec spec;
long ioSize = sizeof(ICAppSpec);
err = ::ICGetPref(instance, pref, &junk, (void *)&spec, &ioSize);
if (err == noErr)
{
// check if registered protocol helper is us
// if so, return PR_FALSE because we'll go into infinite recursion
// continually launching back into ourselves
ProcessSerialNumber psn;
OSErr oserr = ::GetCurrentProcess(&psn);
if (oserr == noErr)
{
ProcessInfoRec info;
info.processInfoLength = sizeof(ProcessInfoRec);
info.processName = nsnull;
info.processAppSpec = nsnull;
err = ::GetProcessInformation(&psn, &info);
if (err == noErr)
{
if (info.processSignature != spec.fCreator)
{
*_retval = PR_TRUE;
rv = NS_OK;
}
else
rv = NS_ERROR_NOT_AVAILABLE;
}
}
}
}
}
}
return rv;
}

View File

@ -61,9 +61,6 @@ protected:
nsresult GetICKeyPascalString(PRUint32 inIndex, const unsigned char*& outICKey);
nsresult GetICPreference(PRUint32 inKey, void *outData, long *ioSize);
PRBool mRunningOSX;
PRBool mRunningJaguar;
};
#endif