add: try { const helperAppService = Components.classes["@mozilla.org/uriloader/external-helper-app-service;1"].getService(Components.interfaces.nsIExternalHelperAppService); if (helperAppService.applyDecodingForType(persistArgs.contentType)) { persist.persistFlags &= ~nsIWBP.PERSIST_FLAGS_NO_CONVERSION; } } catch (e) { }  
context: function foundHeaderInfo(aSniffer, aData){  var contentType = aSniffer.contentType;  var fp = makeFilePicker();  var titleKey = aData.filePickerTitle || "SaveLinkTitle";  var bundle = getStringBundle();  fp.init(window, bundle.GetStringFromName(titleKey),           Components.interfaces.nsIFilePicker.modeSave);  var isDocument = aData.document != null && isDocumentType(contentType);  appendFiltersForContentType(fp, aSniffer.contentType,                              isDocument ? MODE_COMPLETE : MODE_FILEONLY);    const prefSvcContractID = "@mozilla.org/preferences-service;1";  const prefSvcIID = Components.interfaces.nsIPrefService;                                var prefs = Components.classes[prefSvcContractID].getService(prefSvcIID).getBranch("browser.download.");    const nsILocalFile = Components.interfaces.nsILocalFile;  try {    fp.displayDirectory = prefs.getComplexValue("dir", nsILocalFile);  }  catch (e) {  }  if (isDocument) {    try {      fp.filterIndex = prefs.getIntPref("save_converter_index");    }    catch (e) {    }  }    // Determine what the 'default' string to display in the File Picker dialog   // should be.   var defaultFileName = getDefaultFileName(aData.fileName,                                            aSniffer.suggestedFileName,                                            aSniffer.uri);  var defaultExtension = getDefaultExtension(defaultFileName, aSniffer.uri, contentType);  fp.defaultExtension = defaultExtension;  fp.defaultString = getNormalizedLeafName(defaultFileName, defaultExtension);    if (fp.show() == Components.interfaces.nsIFilePicker.returnCancel || !fp.file)    return;      if (isDocument)     prefs.setIntPref("save_converter_index", fp.filterIndex);  var directory = fp.file.parent.QueryInterface(nsILocalFile);  prefs.setComplexValue("dir", nsILocalFile, directory);      fp.file.leafName = validateFileName(fp.file.leafName);    // If we're saving a document, and are saving either in complete mode or   // as converted text, pass the document to the web browser persist component.  // If we're just saving the HTML (second option in the list), send only the URI.  var source = (isDocument && fp.filterIndex != 1) ? aData.document : aSniffer.uri;    var persistArgs = {    source      : source,    contentType : (isDocument && fp.filterIndex == 2) ? "text/plain" : contentType,    target      : fp.file,    postData    : isDocument ? getPostData() : null,    bypassCache : aData.bypassCache  };    // Create persist object and progress dialog, connect them up, and  // initiate download.  var dialog  = makeProgressDialog();  var persist = makeWebBrowserPersist();  dialog.source = makeURL(aData.url);  dialog.target = persistArgs.target;  // Set up the persist object to do the download/save.  persist.progressListener = dialog;  // Calculate persist flags.  const nsIWBP = Components.interfaces.nsIWebBrowserPersist;  const flags = nsIWBP.PERSIST_FLAGS_NO_CONVERSION | nsIWBP.PERSIST_FLAGS_REPLACE_EXISTING_FILES;  if (aData.bypassCache)    persist.persistFlags = flags | nsIWBP.PERSIST_FLAGS_BYPASS_CACHE;  else     persist.persistFlags = flags | nsIWBP.PERSIST_FLAGS_FROM_CACHE;  if (isDocument && fp.filterIndex != 1) {    // Saving a Document, not a URI:    var filesFolder = null;    if (persistArgs.contentType != "text/plain") {      // Create the local directory into which to save associated files.       const lfContractID = "@mozilla.org/file/local;1";      const lfIID = Components.interfaces.nsILocalFile;      filesFolder = Components .classes[lfContractID].createInstance(lfIID);      filesFolder.initWithUnicodePath(persistArgs.target.unicodePath);            var nameWithoutExtension = filesFolder.leafName;      nameWithoutExtension = nameWithoutExtension.substring(0, nameWithoutExtension.lastIndexOf("."));      var filesFolderLeafName = getStringBundle().formatStringFromName("filesFolder",                                                                       [nameWithoutExtension],                                                                       1);      filesFolder.leafName = filesFolderLeafName;    }          var encodingFlags = 0;    if (persistArgs.contentType == "text/plain") {      encodingFlags |= nsIWBP.ENCODE_FLAGS_FORMATTED;      encodingFlags |= nsIWBP.ENCODE_FLAGS_ABSOLUTE_LINKS;      encodingFlags |= nsIWBP.ENCODE_FLAGS_NOFRAMES_CONTENT;            }        const kWrapColumn = 80;    dialog.open(null, persist);    persist.saveDocument(persistArgs.source, persistArgs.target, filesFolder,                          persistArgs.contentType, encodingFlags, kWrapColumn);  } else {    dialog.open(null, persist);    persist.saveURI(source, persistArgs.postData, persistArgs.target);  }}
meta: 8395	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/8395/976d2b9f23cfe255c9b2bc6a09e397df7f402717/contentAreaUtils.js/clean/suite/common/contentAreaUtils.js