mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
bug 389969: followup patch that makes the protocol handling dialog work on Mac as well;
r=biesi sr=dmose a=schrep for M7
This commit is contained in:
parent
b503e88c4f
commit
19a8ec0efa
@ -126,12 +126,12 @@ NS_IMETHODIMP nsInternetConfigService::HasMappingForMIMEType(const char *mimetyp
|
||||
}
|
||||
|
||||
/* boolean hasProtocolHandler (in string protocol); */
|
||||
// returns NS_ERROR_NOT_AVAILABLE if the current application is registered for as the
|
||||
// protocol handler for protocol
|
||||
// returns NS_ERROR_NOT_AVAILABLE if the current application is registered
|
||||
// as the protocol handler for the given protocol
|
||||
NS_IMETHODIMP nsInternetConfigService::HasProtocolHandler(const char *protocol, PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_FALSE; // Presume failure
|
||||
nsresult rv = NS_ERROR_FAILURE; // Ditto
|
||||
*_retval = PR_FALSE; // presume the OS doesn't have a handler
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// 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
|
||||
@ -163,7 +163,6 @@ NS_IMETHODIMP nsInternetConfigService::HasProtocolHandler(const char *protocol,
|
||||
else
|
||||
{
|
||||
*_retval = PR_TRUE;
|
||||
rv = NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -79,46 +79,23 @@ nsresult nsOSHelperAppService::OSProtocolHandlerExists(const char * aProtocolSch
|
||||
// look up the protocol scheme in Internet Config....if we find a match then we have a handler for it...
|
||||
*aHandlerExists = PR_FALSE;
|
||||
// ask the internet config service to look it up for us...
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIInternetConfigService> icService (do_GetService(NS_INTERNETCONFIGSERVICE_CONTRACTID));
|
||||
if (icService)
|
||||
{
|
||||
rv = icService->HasProtocolHandler(aProtocolScheme, aHandlerExists);
|
||||
if (rv == NS_ERROR_NOT_AVAILABLE)
|
||||
{
|
||||
// current app is registered to handle the protocol, put up an alert
|
||||
nsCOMPtr<nsIStringBundleService> stringBundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID);
|
||||
if (stringBundleService)
|
||||
{
|
||||
nsCOMPtr<nsIStringBundle> appLauncherBundle;
|
||||
rv = stringBundleService->CreateBundle(HELPERAPPLAUNCHER_BUNDLE_URL, getter_AddRefs(appLauncherBundle));
|
||||
if (rv == NS_OK)
|
||||
{
|
||||
nsCOMPtr<nsIStringBundle> brandBundle;
|
||||
rv = stringBundleService->CreateBundle(BRAND_BUNDLE_URL, getter_AddRefs(brandBundle));
|
||||
if (rv == NS_OK)
|
||||
{
|
||||
nsXPIDLString brandName;
|
||||
rv = brandBundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(), getter_Copies(brandName));
|
||||
if (rv == NS_OK)
|
||||
{
|
||||
nsXPIDLString errorStr;
|
||||
NS_ConvertASCIItoUTF16 proto(aProtocolScheme);
|
||||
const PRUnichar *formatStrings[] = { brandName.get(), proto.get() };
|
||||
rv = appLauncherBundle->FormatStringFromName(NS_LITERAL_STRING("protocolNotHandled").get(),
|
||||
formatStrings,
|
||||
2,
|
||||
getter_Copies(errorStr));
|
||||
if (rv == NS_OK)
|
||||
{
|
||||
nsCOMPtr<nsIPromptService> prompt (do_GetService(NS_PROMPTSERVICE_CONTRACTID));
|
||||
if (prompt)
|
||||
prompt->Alert(nsnull, NS_LITERAL_STRING("Alert").get(), errorStr.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// There is a protocol handler, but it's the current app! We can't let
|
||||
// the current app handle the protocol, as that'll get us into an infinite
|
||||
// loop, so we just pretend there's no protocol handler available.
|
||||
*aHandlerExists = PR_FALSE;
|
||||
rv = NS_OK;
|
||||
|
||||
// FIXME: instead of pretending there's no protocol handler available,
|
||||
// let the caller know about the loop so it can deal with the problem
|
||||
// (i.e. either fix it automatically, if there's some way to do that,
|
||||
// or just provide the user with options for fixing it manually).
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
|
Loading…
Reference in New Issue
Block a user