Bug 389969 - There is no protocol handling dialog. r=cbiesinger, sr=dmose, a=schrep

This commit is contained in:
sdwilsh@shawnwilsher.com 2007-07-30 16:33:16 -07:00
Родитель 7b04768028
Коммит 09e384652c
12 изменённых файлов: 63 добавлений и 24 удалений

Просмотреть файл

@ -105,6 +105,10 @@ interface nsIHandlerInfo : nsISupports {
attribute nsHandlerInfoAction preferredAction;
const long saveToDisk = 0;
/**
* Used to indicate that we know nothing about what to do with this. You
* could consider this to be not initialized.
*/
const long alwaysAsk = 1;
const long useHelperApp = 2;
const long handleInternally = 3;

Просмотреть файл

@ -233,14 +233,14 @@ nsOSHelperAppService::GetMIMEInfoFromOS(const nsACString& aMIMEType, const nsACS
}
already_AddRefed<nsIHandlerInfo>
nsOSHelperAppService::GetProtocolInfoFromOS(const nsACString &aScheme)
nsOSHelperAppService::GetProtocolInfoFromOS(const nsACString &aScheme,
PRBool *found)
{
NS_ASSERTION(!aScheme.IsEmpty(), "No scheme was specified!");
PRBool exists;
nsresult rv = OSProtocolHandlerExists(nsPromiseFlatCString(aScheme).get(),
&exists);
if (NS_FAILED(rv) || !exists)
found);
if (NS_FAILED(rv))
return nsnull;
nsMIMEInfoBeOS *handlerInfo =
@ -248,6 +248,12 @@ nsOSHelperAppService::GetProtocolInfoFromOS(const nsACString &aScheme)
NS_ENSURE_TRUE(handlerInfo, nsnull);
NS_ADDREF(handlerInfo);
if (!*found) {
// Code that calls this requires an object regardless if the OS has
// something for us, so we return the empty object.
return handlerInfo;
}
nsAutoString desc;
GetApplicationDescription(aScheme, desc);
handlerInfo->SetDefaultDescription(desc);

Просмотреть файл

@ -54,7 +54,8 @@ public:
virtual ~nsOSHelperAppService();
already_AddRefed<nsIMIMEInfo> GetMIMEInfoFromOS(const nsACString& aMIMEType, const nsACString& aFileExt, PRBool *aFound);
already_AddRefed<nsIHandlerInfo> GetProtocolInfoFromOS(const nsACString &aScheme);
already_AddRefed<nsIHandlerInfo> GetProtocolInfoFromOS(const nsACString &aScheme,
PRBool *found);
// override nsIExternalProtocolService methods
nsresult OSProtocolHandlerExists(const char * aProtocolScheme, PRBool * aHandlerExists);

Просмотреть файл

@ -316,14 +316,14 @@ nsOSHelperAppService::GetMIMEInfoFromOS(const nsACString& aMIMEType,
}
already_AddRefed<nsIHandlerInfo>
nsOSHelperAppService::GetProtocolInfoFromOS(const nsACString &aScheme)
nsOSHelperAppService::GetProtocolInfoFromOS(const nsACString &aScheme,
PRBool *found)
{
NS_ASSERTION(!aScheme.IsEmpty(), "No scheme was specified!");
PRBool exists;
nsresult rv = OSProtocolHandlerExists(nsPromiseFlatCString(aScheme).get(),
&exists);
if (NS_FAILED(rv) || !exists)
found);
if (NS_FAILED(rv))
return nsnull;
nsMIMEInfoMac *handlerInfo =
@ -331,6 +331,12 @@ nsOSHelperAppService::GetProtocolInfoFromOS(const nsACString &aScheme)
NS_ENSURE_TRUE(handlerInfo, nsnull);
NS_ADDREF(handlerInfo);
if (!*found) {
// Code that calls this requires an object regardless if the OS has
// something for us, so we return the empty object.
return handlerInfo;
}
nsAutoString desc;
GetApplicationDescription(aScheme, desc);
handlerInfo->SetDefaultDescription(desc);

Просмотреть файл

@ -61,7 +61,8 @@ public:
// method overrides --> used to hook the mime service into internet config....
NS_IMETHOD GetFromTypeAndExtension(const nsACString& aType, const nsACString& aFileExt, nsIMIMEInfo ** aMIMEInfo);
already_AddRefed<nsIMIMEInfo> GetMIMEInfoFromOS(const nsACString& aMIMEType, const nsACString& aFileExt, PRBool * aFound);
already_AddRefed<nsIHandlerInfo> GetProtocolInfoFromOS(const nsACString &aScheme);
already_AddRefed<nsIHandlerInfo> GetProtocolInfoFromOS(const nsACString &aScheme,
PRBool *found);
// GetFileTokenForPath must be implemented by each platform.
// platformAppPath --> a platform specific path to an application that we got out of the

Просмотреть файл

@ -1337,7 +1337,8 @@ nsExternalHelperAppService::GetProtocolHandlerInfo(const nsACString &aScheme,
// and subclasses have lots of good platform specific-knowledge of local
// applications which we might need later. For now, just use nsMIMEInfoImpl
// instead of implementating a separate nsIHandlerInfo object.
*aHandlerInfo = GetProtocolInfoFromOS(aScheme).get();
PRBool exists;
*aHandlerInfo = GetProtocolInfoFromOS(aScheme, &exists).get();
if (!(*aHandlerInfo)) {
// Either it knows nothing, or we ran out of memory
return NS_ERROR_FAILURE;
@ -1350,8 +1351,13 @@ nsExternalHelperAppService::GetProtocolHandlerInfo(const nsACString &aScheme,
// the user, so these defaults are OK.
// XXX this is a bit different than the MIME system, so we may want to look
// into this more in the future.
(*aHandlerInfo)->SetPreferredAction(nsIHandlerInfo::useSystemDefault);
(*aHandlerInfo)->SetAlwaysAskBeforeHandling(PR_TRUE);
// If no OS default existed, we set the preferred action to alwaysAsk. This
// really means not initialized to all the code...
if (exists)
(*aHandlerInfo)->SetPreferredAction(nsIHandlerInfo::useSystemDefault);
else
(*aHandlerInfo)->SetPreferredAction(nsIHandlerInfo::alwaysAsk);
} else if (NS_FAILED(rv)) {
NS_RELEASE(*aHandlerInfo);
return rv;

Просмотреть файл

@ -204,7 +204,8 @@ public:
* @param aScheme The protocol scheme we are looking for.
* @return An nsIHanderInfo for the protocol.
*/
virtual already_AddRefed<nsIHandlerInfo> GetProtocolInfoFromOS(const nsACString &aScheme) = 0;
virtual already_AddRefed<nsIHandlerInfo> GetProtocolInfoFromOS(const nsACString &aScheme,
PRBool *found) = 0;
/**
* Given a string identifying an application, create an nsIFile representing

Просмотреть файл

@ -449,7 +449,7 @@ nsMIMEInfoImpl::GetDefaultDescription(nsAString& aDefaultDescription)
NS_IMETHODIMP
nsMIMEInfoImpl::GetHasDefaultHandler(PRBool * _retval)
{
*_retval = PR_FALSE;
*_retval = !mDefaultAppDescription.IsEmpty();
if (mDefaultApplication) {
PRBool exists;
*_retval = NS_SUCCEEDED(mDefaultApplication->Exists(&exists)) && exists;

Просмотреть файл

@ -1635,17 +1635,17 @@ nsOSHelperAppService::GetMIMEInfoFromOS(const nsACString& aType,
}
already_AddRefed<nsIHandlerInfo>
nsOSHelperAppService::GetProtocolInfoFromOS(const nsACString &aScheme)
nsOSHelperAppService::GetProtocolInfoFromOS(const nsACString &aScheme,
PRBool *found)
{
NS_ASSERTION(!aScheme.IsEmpty(), "No scheme was specified!");
// We must check that a registered handler exists so that gnome_url_show
// doesn't fallback to gnomevfs.
// See nsGNOMERegistry::LoadURL and bug 389632.
PRBool exists;
nsresult rv = OSProtocolHandlerExists(nsPromiseFlatCString(aScheme).get(),
&exists);
if (NS_FAILED(rv) || !exists)
found);
if (NS_FAILED(rv))
return nsnull;
nsMIMEInfoUnix *handlerInfo =
@ -1653,6 +1653,12 @@ nsOSHelperAppService::GetProtocolInfoFromOS(const nsACString &aScheme)
NS_ENSURE_TRUE(handlerInfo, nsnull);
NS_ADDREF(handlerInfo);
if (!*found) {
// Code that calls this requires an object regardless if the OS has
// something for us, so we return the empty object.
return handlerInfo;
}
nsAutoString desc;
GetApplicationDescription(aScheme, desc);
handlerInfo->SetDefaultDescription(desc);

Просмотреть файл

@ -61,7 +61,8 @@ public:
already_AddRefed<nsIMIMEInfo> GetMIMEInfoFromOS(const nsACString& aMimeType,
const nsACString& aFileExt,
PRBool *aFound);
already_AddRefed<nsIHandlerInfo> GetProtocolInfoFromOS(const nsACString &aScheme);
already_AddRefed<nsIHandlerInfo> GetProtocolInfoFromOS(const nsACString &aScheme,
PRBool *found);
// override nsIExternalProtocolService methods
nsresult OSProtocolHandlerExists(const char * aProtocolScheme, PRBool * aHandlerExists);

Просмотреть файл

@ -554,14 +554,14 @@ already_AddRefed<nsIMIMEInfo> nsOSHelperAppService::GetMIMEInfoFromOS(const nsAC
}
already_AddRefed<nsIHandlerInfo>
nsOSHelperAppService::GetProtocolInfoFromOS(const nsACString &aScheme)
nsOSHelperAppService::GetProtocolInfoFromOS(const nsACString &aScheme,
PRBool *found)
{
NS_ASSERTION(!aScheme.IsEmpty(), "No scheme was specified!");
PRBool exists;
nsresult rv = OSProtocolHandlerExists(nsPromiseFlatCString(aScheme).get(),
&exists);
if (NS_FAILED(rv) || !exists)
found);
if (NS_FAILED(rv))
return nsnull;
nsMIMEInfoWin *handlerInfo =
@ -569,6 +569,12 @@ nsOSHelperAppService::GetProtocolInfoFromOS(const nsACString &aScheme)
NS_ENSURE_TRUE(handlerInfo, nsnull);
NS_ADDREF(handlerInfo);
if (!*found) {
// Code that calls this requires an object regardless if the OS has
// something for us, so we return the empty object.
return handlerInfo;
}
nsAutoString desc;
GetApplicationDescription(aScheme, desc);
handlerInfo->SetDefaultDescription(desc);

Просмотреть файл

@ -63,7 +63,8 @@ public:
// method overrides for windows registry look up steps....
already_AddRefed<nsIMIMEInfo> GetMIMEInfoFromOS(const nsACString& aMIMEType, const nsACString& aFileExt, PRBool *aFound);
already_AddRefed<nsIHandlerInfo> GetProtocolInfoFromOS(const nsACString &aScheme);
already_AddRefed<nsIHandlerInfo> GetProtocolInfoFromOS(const nsACString &aScheme,
PRBool *found);
/** Get the string value of a registry value and store it in result.
* @return PR_TRUE on success, PR_FALSE on failure