diff --git a/suite/common/pref/overrideHandler.js b/suite/common/pref/overrideHandler.js
index 5a33b672cca..a3ddb62484b 100644
--- a/suite/common/pref/overrideHandler.js
+++ b/suite/common/pref/overrideHandler.js
@@ -138,7 +138,31 @@ HandlerOverride.prototype = {
else
changeMIMEStuff(HANDLER_URI(this.mimeType), "saveToDisk", aSavedToDisk);
this.setHandlerProcedure("handleInternal", "false");
+ this.setHandlerProcedure("useSystemDefault", "false");
},
+
+ get useSystemDefault()
+ {
+ return getHandlerInfoForType(this.URI, "useSystemDefault");
+ },
+
+ set useSystemDefault(aUseSystemDefault)
+ {
+ var handlerSource = gRDF.GetResource(HANDLER_URI(this.mimeType));
+ var handlerProperty = gRDF.GetResource(NC_RDF("useSystemDefault"));
+ var trueLiteral = gRDF.GetLiteral("true");
+ var hasUseSystemDefault = gDS.HasAssertion(handlerSource, handlerProperty, trueLiteral, true);
+ if (!hasUseSystemDefault) {
+ var falseLiteral = gRDF.GetLiteral("false");
+ hasUseSystemDefault = gDS.HasAssertion(handlerSource, handlerProperty, falseLiteral, true);
+ }
+ if (!this.mUpdateMode || !hasUseSystemDefault)
+ assertMIMEStuff(HANDLER_URI(this.mimeType), "useSystemDefault", aUseSystemDefault);
+ else
+ changeMIMEStuff(HANDLER_URI(this.mimeType), "useSystemDefault", aUseSystemDefault);
+ this.setHandlerProcedure("handleInternal", "false");
+ this.setHandlerProcedure("saveToDisk", "false");
+ },
get handleInternal()
{
@@ -160,6 +184,7 @@ HandlerOverride.prototype = {
else
changeMIMEStuff(HANDLER_URI(this.mimeType), "handleInternal", aHandledInternally);
this.setHandlerProcedure("saveToDisk", "false");
+ this.setHandlerProcedure("useSystemDefault", "false");
},
setHandlerProcedure: function (aHandlerProcedure, aValue)
@@ -317,7 +342,7 @@ function mimeHandlerExists(aMIMEType)
{
var valueProperty = gRDF.GetResource(NC_RDF("value"));
var mimeSource = gRDF.GetResource(MIME_URI(aMIMEType));
- var mimeLiteral = gRDF.GetLiteral(gMIMEField.value);
+ var mimeLiteral = gRDF.GetLiteral(aMIMEType);
return gDS.HasAssertion(mimeSource, valueProperty, mimeLiteral, true);
}
@@ -349,7 +374,6 @@ function unassertMIMEStuff(aMIMEString, aPropertyString, aValueString)
function removeOverride(aMIMEType)
{
- dump("*** mimeType = " + aMIMEType + "\n");
// remove entry from seq
var rdfc = Components.classes["@mozilla.org/rdf/container;1"].createInstance();
if (rdfc) {
@@ -372,7 +396,7 @@ function removeOverride(aMIMEType)
// remove items from the graph
var urns = [ [MIME_URI, ["description", "editable", "value", "fileExtensions", "smallIcon", "largeIcon"],
[HANDLER_URI, "handlerProp"]],
- [HANDLER_URI, ["handleInternal", "saveToDisk", "alwaysAsk"],
+ [HANDLER_URI, ["handleInternal", "saveToDisk", "alwaysAsk", "useSystemDefault"],
[APP_URI, "externalApplication"]],
[APP_URI, ["path", "prettyName"]] ];
for (var i = 0; i < urns.length; i++) {
@@ -396,7 +420,7 @@ function removeOverride(aMIMEType)
gDS.Unassert(mimeRes, propertyRes, mimeValue, true);
}
}
- if (urns[i][2]) {
+ if ("2" in urns[i] && urns[i][2]) {
var linkRes = gRDF.GetResource(NC_RDF(urns[i][2][1]), true);
var linkTarget = gRDF.GetResource(urns[i][2][0](aMIMEType), true);
gDS.Unassert(mimeRes, linkRes, linkTarget);
diff --git a/suite/common/pref/pref-applications-edit.xul b/suite/common/pref/pref-applications-edit.xul
index 5aed2dfe8be..5efe0d780ca 100644
--- a/suite/common/pref/pref-applications-edit.xul
+++ b/suite/common/pref/pref-applications-edit.xul
@@ -31,6 +31,7 @@
style="width: 30em;"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&editType.label;"
+ newtitle="&newType.label;"
onload="Startup();"
ondialogaccept="return onAccept();">
@@ -41,28 +42,38 @@
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
+
-
+
+
+
+
+
+
+
diff --git a/suite/common/pref/pref-applications.js b/suite/common/pref/pref-applications.js
index 5104f4ed355..5518718ac38 100644
--- a/suite/common/pref/pref-applications.js
+++ b/suite/common/pref/pref-applications.js
@@ -25,7 +25,7 @@ var gDS = null;
var gPrefApplicationsBundle = null;
var gExtensionField = null;
-var gMIMETypeField = null;
+var gMIMEDescField = null;
var gHandlerField = null;
var gNewTypeButton = null;
var gEditButton = null;
@@ -33,7 +33,8 @@ var gRemoveButton = null;
function newType()
{
- window.openDialog("chrome://communicator/content/pref/pref-applications-new.xul", "appEdit", "chrome,modal=yes,resizable=no");
+ var handlerOverride = new HandlerOverride();
+ window.openDialog("chrome://communicator/content/pref/pref-applications-edit.xul", "appEdit", "chrome,modal=yes,resizable=no", handlerOverride);
if (gNewTypeRV) {
//gList.builder.rebuild();
gList.setAttribute("ref", "urn:mimetypes");
@@ -43,17 +44,22 @@ function newType()
function removeType()
{
- var titleMsg = gPrefApplicationsBundle.getString("removeHandlerTitle");
- var dialogMsg = gPrefApplicationsBundle.getString("removeHandler");
- dialogMsg = dialogMsg.replace(/%n/g, "\n");
- var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
- var remove = promptService.confirm(window, titleMsg, dialogMsg);
- if (remove) {
- var uri = gList.selectedItems[0].id;
- var handlerOverride = new HandlerOverride(uri);
- removeOverride(handlerOverride.mimeType);
- gList.setAttribute("ref", "urn:mimetypes");
+ // Only prompt if setting is "useHelperApp".
+ var uri = gList.selectedItems[0].id;
+ var handlerOverride = new HandlerOverride(uri);
+ if ( !handlerOverride.useSystemDefault && !handlerOverride.saveToDisk ) {
+ var titleMsg = gPrefApplicationsBundle.getString("removeHandlerTitle");
+ var dialogMsg = gPrefApplicationsBundle.getString("removeHandler");
+ dialogMsg = dialogMsg.replace(/%n/g, "\n");
+ var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
+ var remove = promptService.confirm(window, titleMsg, dialogMsg);
+ if (!remove) {
+ return;
+ }
}
+ removeOverride(handlerOverride.mimeType);
+ gList.setAttribute("ref", "urn:mimetypes");
+ selectApplication();
}
function editType()
@@ -66,6 +72,89 @@ function editType()
}
}
+const xmlSinkObserver = {
+ onBeginLoad: function(aSink)
+ {
+ },
+ onInterrupt: function(aSink)
+ {
+ },
+ onResume: function(aSink)
+ {
+ },
+ // This is called when the RDF data source has finished loading.
+ onEndLoad: function(aSink)
+ {
+ // Unhook observer.
+ aSink.removeXMLSinkObserver(this);
+
+ // Convert old "don't ask" pref info to helper app pref entries
+ try {
+ var prefService = Components.classes["@mozilla.org/preferences;1"].getService(Components.interfaces.nsIPrefService);
+ var prefBranch = prefService.getBranch("browser.helperApps.neverAsk.");
+ if (!prefBranch) return;
+ } catch(e) { return; }
+
+ var neverAskSave = new Array();
+ var neverAskOpen = new Array();
+ try {
+ neverAskSave = prefBranch.getCharPref("saveToDisk").split(",");
+ } catch(e) {}
+ try {
+ neverAskOpen = prefBranch.getCharPref("openFile").split(",");
+ } catch(e) {}
+
+ var i;
+ var newEntries = {};
+ for ( i = 0; i < neverAskSave.length; i++ ) {
+ // See if mime type is in data source.
+ var type = unescape(neverAskSave[i]);
+ if (type != "" && !mimeHandlerExists(type)) {
+ // Not in there, need to create an entry now so user can edit it.
+ newEntries[type] = "saveToDisk";
+ }
+ }
+
+ for ( i = 0; i < neverAskOpen.length; i++ ) {
+ // See if mime type is in data source.
+ var type = unescape(neverAskOpen[i]);
+ if (type != "" && !mimeHandlerExists(type)) {
+ // Not in there, need to create an entry now so user can edit it.
+ newEntries[type] = "useSystemDefault";
+ }
+ }
+
+ // Now create all new entries.
+ for ( var newEntry in newEntries ) {
+ this.createNewEntry(newEntry, newEntries[newEntry]);
+ }
+
+ // Don't need these any more!
+ try { prefBranch.clearUserPref("saveToDisk"); } catch(e) {}
+ try { prefBranch.clearUserPref("openFile"); } catch(e) {}
+ },
+ onError: function(aSink, aStatus, aMsg)
+ {
+ },
+ createNewEntry: function(mimeType, action)
+ {
+ // Create HandlerOverride and populate it.
+ var entry = new HandlerOverride(MIME_URI(mimeType));
+ entry.mUpdateMode = false;
+ entry.mimeType = mimeType;
+ entry.description = "";
+ entry.isEditable = true;
+ entry.alwaysAsk = false;
+ entry.appPath = "";
+ entry.appDisplayName = "";
+ // This sets preferred action.
+ entry[action] = true;
+
+ // Do RDF magic.
+ entry.buildLinks();
+ }
+}
+
function Startup()
{
// set up the string bundle
@@ -74,7 +163,7 @@ function Startup()
// set up the elements
gList = document.getElementById("appList");
gExtensionField = document.getElementById("extension");
- gMIMETypeField = document.getElementById("mimeType");
+ gMIMEDescField = document.getElementById("mimeDesc");
gHandlerField = document.getElementById("handler");
gNewTypeButton = document.getElementById("newTypeButton");
gEditButton = document.getElementById("editButton");
@@ -90,12 +179,20 @@ function Startup()
var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
var fileHandler = ioService.getProtocolHandler("file").QueryInterface(Components.interfaces.nsIFileProtocolHandler);
- dump("spec is " + fileHandler.getURLSpecFromFile(file));
gDS = gRDF.GetDataSource(fileHandler.getURLSpecFromFile(file));
// intialize the listbox
gList.database.AddDataSource(gDS);
gList.setAttribute("ref", "urn:mimetypes");
+
+ // Test whether the data source is already loaded.
+ if (gDS.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).loaded) {
+ // Do it now.
+ xmlSinkObserver.onEndLoad(gDS.QueryInterface(Components.interfaces.nsIRDFXMLSink));
+ } else {
+ // Add observer that will kick in when data source load completes.
+ gDS.QueryInterface(Components.interfaces.nsIRDFXMLSink).addXMLSinkObserver( xmlSinkObserver );
+ }
}
function selectApplication()
@@ -104,7 +201,7 @@ function selectApplication()
var uri = gList.selectedItems[0].id;
var handlerOverride = new HandlerOverride(uri);
gExtensionField.setAttribute("value", handlerOverride.extensions);
- gMIMETypeField.setAttribute("value", handlerOverride.mimeType);
+ gMIMEDescField.setAttribute("value", handlerOverride.description);
// figure out how this type is handled
if (handlerOverride.handleInternal == "true")
@@ -113,8 +210,12 @@ function selectApplication()
else if (handlerOverride.saveToDisk == "true")
gHandlerField.setAttribute("value",
gPrefApplicationsBundle.getString("saveToDisk"));
+ else if (handlerOverride.useSystemDefault == "true")
+ gHandlerField.setAttribute("value",
+ gPrefApplicationsBundle.getString("useSystemDefault"));
else
- gHandlerField.setAttribute("value", handlerOverride.appDisplayName);
+ gHandlerField.setAttribute("value",
+ gPrefApplicationsBundle.getFormattedString("useHelperApp", [handlerOverride.appDisplayName]));
var ext;
var posOfFirstSpace = handlerOverride.extensions.indexOf(" ");
if (posOfFirstSpace > -1)
@@ -130,7 +231,7 @@ function selectApplication()
gHandlerField.removeAttribute("value");
document.getElementById("contentTypeImage").removeAttribute("src");
gExtensionField.removeAttribute("value");
- gMIMETypeField.removeAttribute("value");
+ gMIMEDescField.removeAttribute("value");
}
}
@@ -152,12 +253,3 @@ function updateLockedButtonState(handlerEditable)
gRemoveButton.disabled = false;
}
}
-
-function clearRememberedSettings()
-{
- var prefBranch = Components.classes["@mozilla.org/preferences;1"].getService(Components.interfaces.nsIPrefBranch);
- if (prefBranch) {
- prefBranch.setCharPref("browser.helperApps.neverAsk.saveToDisk", "");
- prefBranch.setCharPref("browser.helperApps.neverAsk.openFile", "");
- }
-}
diff --git a/suite/common/pref/pref-applications.xul b/suite/common/pref/pref-applications.xul
index 37778c8c713..52aff9cc21d 100644
--- a/suite/common/pref/pref-applications.xul
+++ b/suite/common/pref/pref-applications.xul
@@ -45,8 +45,8 @@
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
-
+
-
+
+
+
+
+
-
+
-
-
-
-
-
+
-
+
-
-
-
-
-
-
-
+
+
@@ -126,12 +125,4 @@
&pluginFinderDesc.label;
-
-
-
- &resetText.label;
-
-
-
-
diff --git a/suite/locales/en-US/chrome/common/pref/pref-applications-edit.dtd b/suite/locales/en-US/chrome/common/pref/pref-applications-edit.dtd
index eaa99418a57..cc2f3b90e13 100644
--- a/suite/locales/en-US/chrome/common/pref/pref-applications-edit.dtd
+++ b/suite/locales/en-US/chrome/common/pref/pref-applications-edit.dtd
@@ -1,31 +1,24 @@
+
+
+
+
+
-
-
-
-
-
+
+
+
+
-
-
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
diff --git a/suite/locales/en-US/chrome/common/pref/pref-applications.dtd b/suite/locales/en-US/chrome/common/pref/pref-applications.dtd
index 178f3edce64..9095b8d72fe 100644
--- a/suite/locales/en-US/chrome/common/pref/pref-applications.dtd
+++ b/suite/locales/en-US/chrome/common/pref/pref-applications.dtd
@@ -2,7 +2,7 @@
-
+
@@ -12,12 +12,9 @@
-
-
-
-
-
-
+
+
+
diff --git a/suite/locales/en-US/chrome/common/pref/pref-applications.properties b/suite/locales/en-US/chrome/common/pref/pref-applications.properties
index 5a8e92c1cec..eadec141891 100644
--- a/suite/locales/en-US/chrome/common/pref/pref-applications.properties
+++ b/suite/locales/en-US/chrome/common/pref/pref-applications.properties
@@ -1,12 +1,14 @@
# foo
-saveToDisk=Save to Disk
-handleInternally=Handled Internally
+saveToDisk=Save these files to disk
+useSystemDefault=Open these files using the default application
+useHelperApp=Open these files with %S
+handleInternally=Display files of this type in the browser
chooseHandler=Choose Application Helper
programsFilter=Programs
-handlerExists=A helper already exists for the MIME type '%mime%'. Do you want to replace it?
+handlerExists=A helper already exists for the MIME type '%mime%'. Do you want to replace it?
handlerExistsTitle=Helper Application Exists
emptyMIMEType=You must specify a MIME type.