rem: var prefs = getPrefsBrowserDownload("browser.download."); 
context: function internalSave(aURL, aDocument, aDefaultFileName, aShouldBypassCache,                      aFilePickerTitleKey, aChosenData, aReferrer){  // Note: aDocument == null when this code is used by save-link-as...  var contentType = (aDocument ? aDocument.contentType : null);  // Find the URI object for aURL and the FileName/Extension to use when saving.  // FileName/Extension will be ignored if aChosenData supplied.  var fileInfo = new FileInfo(aDefaultFileName);  if (!aChosenData)    initFileInfo(fileInfo, aURL, aDocument, contentType);  var saveMode = GetSaveModeForContentType(contentType);  var isDocument = aDocument != null && saveMode != SAVEMODE_FILEONLY;  // Show the file picker that allows the user to confirm the target filename:  var prefs = getPrefsBrowserDownload("browser.download.");  var fpParams = {    fp: makeFilePicker(),    prefs: prefs,    userDirectory: getUserDownloadDir(prefs),    fpTitleKey: aFilePickerTitleKey,    isDocument: isDocument,    fileInfo: fileInfo,    contentType: contentType,    saveMode: saveMode  };  // If aChosenData is null then the file picker is shown.  if (!aChosenData) {    if (!poseFilePicker(fpParams))      // If the method returned false this is because the user cancelled from      // the save file picker dialog.      return;  }  // XXX We depend on the following holding true in appendFiltersForContentType():  // If we should save as a complete page, the filterIndex is 0.  // If we should save as text, the filterIndex is 2.  var useSaveDocument = isDocument &&                        (((fpParams.saveMode & SAVEMODE_COMPLETE_DOM) && (fpParams.fp.filterIndex == 0)) ||                         ((fpParams.saveMode & SAVEMODE_COMPLETE_TEXT) && (fpParams.fp.filterIndex == 2)));  // 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 = useSaveDocument ? aDocument : fileInfo.uri;  var persistArgs = {    source      : source,    contentType : (!aChosenData && useSaveDocument && fpParams.fp.filterIndex == 2) ? "text/plain" : contentType,    target      : (aChosenData ? makeFileURI(aChosenData.file) : fpParams.fp.fileURL),    postData    : isDocument ? getPostData() : null,    bypassCache : aShouldBypassCache  };  var persist = makeWebBrowserPersist();  // Calculate persist flags.  const nsIWBP = Components.interfaces.nsIWebBrowserPersist;  const flags = nsIWBP.PERSIST_FLAGS_REPLACE_EXISTING_FILES;  if (aShouldBypassCache)    persist.persistFlags = flags | nsIWBP.PERSIST_FLAGS_BYPASS_CACHE;  else    persist.persistFlags = flags | nsIWBP.PERSIST_FLAGS_FROM_CACHE;  // Leave it to WebBrowserPersist to discover the encoding type (or lack thereof):  persist.persistFlags |= nsIWBP.PERSIST_FLAGS_AUTODETECT_APPLY_CONVERSION;  // Create download and initiate it (below)  var dl = Components.classes["@mozilla.org/download;1"].createInstance(Components.interfaces.nsIDownload);  if (useSaveDocument) {    // Saving a Document, not a URI:    var filesFolder = null;    if (persistArgs.contentType != "text/plain") {      // Create the local directory into which to save associated files.      var destFile = (aChosenData ? aChosenData.file : fpParams.fp.file);      filesFolder = destFile.clone();      var nameWithoutExtension = filesFolder.leafName.replace(/\.[^.]*$/, "");      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;    }    else {      encodingFlags |= nsIWBP.ENCODE_FLAGS_ENCODE_BASIC_ENTITIES;    }    const kWrapColumn = 80;    dl.init((aChosenData ? aChosenData.uri : fileInfo.uri),            persistArgs.target, null, null, null, persist);    persist.saveDocument(persistArgs.source, persistArgs.target, filesFolder,                         persistArgs.contentType, encodingFlags, kWrapColumn);  } else {    dl.init((aChosenData ? aChosenData.uri : source),            persistArgs.target, null, null, null, persist);    var referer = aReferrer || getReferrer(document);    persist.saveURI((aChosenData ? aChosenData.uri : source),                    null, referer, persistArgs.postData, null, persistArgs.target);  }}
meta: 5872	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/5872/50b8f5167829a160c7bb88c2b1ed32a070f52686/contentAreaUtils.js/buggy/suite/common/contentAreaUtils.js