context: function getDefaultFileName(aDefaultFileName, aNameFromHeaders, aDocumentURI, aDocument){  if (aNameFromHeaders)    // 1) Use the name suggested by the HTTP headers    return validateFileName(aNameFromHeaders);  try {    var url = aDocumentURI.QueryInterface(Components.interfaces.nsIURL);    if (url.fileName != "") {      // 2) Use the actual file name, if present      return validateFileName(decodeURIComponent(url.fileName));    }  } catch (e) {    try {      // the file name might be non ASCII      // try unescape again with a characterSet      var textToSubURI = Components.classes["@mozilla.org/intl/texttosuburi;1"]                                   .getService(Components.interfaces.nsITextToSubURI);      var charset = getCharsetforSave(aDocument);      return validateFileName(textToSubURI.unEscapeURIForUI(charset, url.fileName));    } catch (e) {      // This is something like a wyciwyg:, data:, and so forth      // URI... no usable filename here.    }  }    if (aDocument) {    var docTitle = validateFileName(aDocument.title).replace(/^\s+|\s+$/g, "");    if (docTitle != "") {      // 3) Use the document title      return docTitle;    }  }    if (aDefaultFileName)    // 4) Use the caller-provided name, if any    return validateFileName(aDefaultFileName);  // 5) If this is a directory, use the last directory name  var re = /\/([^\/]+)\/$/;  var path = aDocumentURI.path.match(re);  if (path && path.length > 1) {      return validateFileName(path[1]);  }    try {    if (aDocumentURI.host)      // 6) Use the host.      return aDocumentURI.host;  } catch (e) {    // Some files have no information at all, like Javascript generated pages  }  try {    // 7) Use the default file name    return getStringBundle().GetStringFromName("DefaultSaveFileName");  } catch (e) {    //in case localized string cannot be found  }  // 8) If all else fails, use "index"  return "index";}
meta: 10234	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/10234/0545d3f114e89dd60d62918be774dce26056e457/contentAreaUtils.js/clean/toolkit/content/contentAreaUtils.js