58557 r=bzbarsky sr=jag Mozilla allows you to override internal MIME types to no effect.

This checkin makes it so that a warning message is displayed if the user tries to create a helper app for an internally handled type.
This commit is contained in:
cbiesinger%web.de 2003-07-14 21:30:27 +00:00
parent 17603e534e
commit b5f774cdd4
2 changed files with 34 additions and 1 deletions

View File

@ -37,6 +37,7 @@
<stringbundle id="bundle_prefApplications"
src="chrome://communicator/locale/pref/pref-applications.properties"/>
<stringbundle id="bundle_Brand" src="chrome://global/locale/brand.properties"/>
<script type="application/x-javascript" src="chrome://global/content/dialogOverlay.js"/>
<script type="application/x-javascript" src="chrome://communicator/content/pref/overrideHandler.js"/>
@ -295,6 +296,35 @@
}
getDS();
gMIMEField.value = gMIMEField.value.toLowerCase();
// Get the promptservice, we will need it
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
// Check if Mozilla can handle this type internally, in which case
// an entry would have no effect
try {
var categoryManager = Components.classes["@mozilla.org/categorymanager;1"]
.getService(Components.interfaces.nsICategoryManager);
if (categoryManager.getCategoryEntry("Gecko-Content-Viewers", gMIMEField.value)) {
var brandBundle = document.getElementById("bundle_Brand");
var text = gPrefApplicationsBundle.getString("canHandleInternally");
text = text.replace(/%brand%/g, brandBundle.getString("brandShortName"));
if (promptService.confirmEx(
window,
gPrefApplicationsBundle.getString("canHandleInternallyTitle"),
text,
(Components.interfaces.nsIPromptService.BUTTON_POS_1 *
Components.interfaces.nsIPromptService.BUTTON_TITLE_IS_STRING) |
(Components.interfaces.nsIPromptService.BUTTON_POS_0 *
Components.interfaces.nsIPromptService.BUTTON_TITLE_CANCEL),
null,
gPrefApplicationsBundle.getString("canHandleInternallyContinue"),
null,
null,
{}
) == 0)
return false;
}
}
catch (ex) {}
// figure out if this mime type already exists.
if (gMIMEField.value != gOldMIME) {
var exists = mimeHandlerExists(gMIMEField.value);
@ -302,7 +332,6 @@
var titleMsg = gPrefApplicationsBundle.getString("handlerExistsTitle");
var dialogMsg = gPrefApplicationsBundle.getString("handlerExists");
dialogMsg = dialogMsg.replace(/%mime%/g, gMIMEField.value);
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
var replace = promptService.confirm(window, titleMsg, dialogMsg);
if (!replace)
window.close();

View File

@ -8,6 +8,10 @@ handleInternally=Display files of this type in the browser
chooseHandler=Choose Helper Application
programsFilter=Programs
canHandleInternallyTitle=Warning
canHandleInternally=%brand% can handle this type internally. For such types, a Helper Application will only be invoked if the server requests external handling.
canHandleInternallyContinue=&Proceed anyway
handlerExists=A helper already exists for the MIME type '%mime%'. Do you want to replace it?
handlerExistsTitle=Helper Application Exists