Bug 282958 - "toolkit/mozapps/downloads/content uses wrong contractid for the MIME service" [p=chpe@gnome.org (Christian Persch) r=biesi a1.9=schrep]

This commit is contained in:
reed@reedloden.com 2007-11-21 12:57:38 -08:00
Родитель f0041bced9
Коммит a988026096
7 изменённых файлов: 20 добавлений и 20 удалений

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

@ -802,7 +802,7 @@ var gApplicationsPane = {
getService(Ci.nsIPrefBranch).
QueryInterface(Ci.nsIPrefBranch2),
_mimeSvc : Cc["@mozilla.org/uriloader/external-helper-app-service;1"].
_mimeSvc : Cc["@mozilla.org/mime;1"].
getService(Ci.nsIMIMEService),
_helperAppSvc : Cc["@mozilla.org/uriloader/external-helper-app-service;1"].

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

@ -183,9 +183,7 @@ function downloadCompleted(aDownload)
// getTypeFromFile fails if it can't find a type for this file.
try {
// Refresh the icon, so that executable icons are shown.
const kExternalHelperAppServContractID =
"@mozilla.org/uriloader/external-helper-app-service;1";
var mimeService = Cc[kExternalHelperAppServContractID].
var mimeService = Cc["@mozilla.org/mime;1"].
getService(Ci.nsIMIMEService);
var contentType = mimeService.getTypeFromFile(aDownload.targetFile);

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

@ -211,10 +211,7 @@ HelperApps.prototype = {
types = types.QueryInterface(Components.interfaces.nsIRDFLiteral);
types = types.Value.split(", ");
// We're using helper app service as our MIME Service here because the helper app service
// talks to OS Specific hooks that on some platforms (MacOS X) are required to get a
// fully populated MIME Info object. Thus it is this object that we return.
mimeSvc = Components.classes["@mozilla.org/uriloader/external-helper-app-service;1"].getService(Components.interfaces.nsIMIMEService);
mimeSvc = Components.classes["@mozilla.org/mime;1"].getService(Components.interfaces.nsIMIMEService);
return mimeSvc.getFromTypeAndExtension(types[0], null);
}

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

@ -454,10 +454,9 @@ nsUnknownContentTypeDialog.prototype = {
// data, rather, a data format that the system probably knows about,
// we don't want to use the content-type provided by this dialog's
// opener, as that's the generic application/octet-stream that the
// uriloader has passed, rather we want to ask the External Helper App
// Service, which will ask the host OS. This is so we don't needlessly
// disable the "autohandle" checkbox.
var mimeService = Components.classes["@mozilla.org/uriloader/external-helper-app-service;1"].getService(Components.interfaces.nsIMIMEService);
// uriloader has passed, rather we want to ask the MIME Service.
// This is so we don't needlessly disable the "autohandle" checkbox.
var mimeService = Components.classes["@mozilla.org/mime;1"].getService(Components.interfaces.nsIMIMEService);
var type = mimeService.getTypeFromURI(this.mLauncher.source);
this.realMIMEInfo = mimeService.getFromTypeAndExtension(type, "");

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

@ -585,12 +585,18 @@ NS_IMETHODIMP nsExternalHelperAppService::DoContent(const nsACString& aMimeConte
LOG(("HelperAppService::DoContent: mime '%s', extension '%s'\n",
PromiseFlatCString(aMimeContentType).get(), fileExtension.get()));
// we get the mime service here even though we're the default implementation of it,
// so it's possible to override only the mime service and not need to reimplement the
// whole external helper app service itself
nsCOMPtr<nsIMIMEService> mimeSvc(do_GetService(NS_MIMESERVICE_CONTRACTID));
NS_ENSURE_TRUE(mimeSvc, NS_ERROR_FAILURE);
// Try to find a mime object by looking at the mime type/extension
nsCOMPtr<nsIMIMEInfo> mimeInfo;
if (aMimeContentType.Equals(APPLICATION_GUESS_FROM_EXT, nsCaseInsensitiveCStringComparator())) {
nsCAutoString mimeType;
if (!fileExtension.IsEmpty()) {
GetFromTypeAndExtension(EmptyCString(), fileExtension, getter_AddRefs(mimeInfo));
mimeSvc->GetFromTypeAndExtension(EmptyCString(), fileExtension, getter_AddRefs(mimeInfo));
if (mimeInfo) {
mimeInfo->GetMIMEType(mimeType);
@ -601,7 +607,7 @@ NS_IMETHODIMP nsExternalHelperAppService::DoContent(const nsACString& aMimeConte
if (fileExtension.IsEmpty() || mimeType.IsEmpty()) {
// Extension lookup gave us no useful match
GetFromTypeAndExtension(NS_LITERAL_CSTRING(APPLICATION_OCTET_STREAM), fileExtension,
mimeSvc->GetFromTypeAndExtension(NS_LITERAL_CSTRING(APPLICATION_OCTET_STREAM), fileExtension,
getter_AddRefs(mimeInfo));
mimeType.AssignLiteral(APPLICATION_OCTET_STREAM);
}
@ -612,7 +618,7 @@ NS_IMETHODIMP nsExternalHelperAppService::DoContent(const nsACString& aMimeConte
reason = nsIHelperAppLauncherDialog::REASON_TYPESNIFFED;
}
else {
GetFromTypeAndExtension(aMimeContentType, fileExtension,
mimeSvc->GetFromTypeAndExtension(aMimeContentType, fileExtension,
getter_AddRefs(mimeInfo));
}
LOG(("Type/Ext lookup found 0x%p\n", mimeInfo.get()));

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

@ -756,7 +756,7 @@ HandlerService.prototype = {
get _mimeSvc() {
if (!this.__mimeSvc)
this.__mimeSvc =
Cc["@mozilla.org/uriloader/external-helper-app-service;1"].
Cc["@mozilla.org/mime;1"].
getService(Ci.nsIMIMEService);
return this.__mimeSvc;
},

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

@ -42,7 +42,7 @@ function run_test() {
const handlerSvc = Cc["@mozilla.org/uriloader/handler-service;1"].
getService(Ci.nsIHandlerService);
const mimeSvc = Cc["@mozilla.org/uriloader/external-helper-app-service;1"].
const mimeSvc = Cc["@mozilla.org/mime;1"].
getService(Ci.nsIMIMEService);
const prefSvc = Cc["@mozilla.org/preferences-service;1"].