rv = bundle->GetStringFromName( NS_ConvertASCIItoUCS2( "FilePickerTitle" ).GetUnicode(),
rv = bundle->GetStringFromName( NS_ConvertASCIItoUCS2( "FilePickerTitle" ).get(),
nsStreamTransfer::SelectFile( nsIDOMWindowInternal *parent, nsILocalFile **aResult, const nsString &suggested ) {    nsresult rv = NS_OK;    if ( aResult ) {        *aResult = 0;        // Prompt user for file name.        nsCOMPtr<nsIFilePicker> picker = do_CreateInstance( "@mozilla.org/filepicker;1" );              if ( picker ) {            // Prompt for file name.            nsCOMPtr<nsILocalFile> startDir;            // Pull in the user's preferences and get the default download directory.            NS_WITH_SERVICE( nsIPref, prefs, NS_PREF_CONTRACTID, &rv );            if ( NS_SUCCEEDED( rv ) && prefs ) {                prefs->GetFileXPref( "browser.download.dir", getter_AddRefs( startDir ) );                if ( startDir ) {                    PRBool isValid = PR_FALSE;                    startDir->Exists( &isValid );                    if ( isValid ) {                      // Set file picker so startDir is used.                      picker->SetDisplayDirectory( startDir );                    }                }            }            nsAutoString title( NS_ConvertASCIItoUCS2( "Save File" ) );            nsCID cid = NS_STRINGBUNDLESERVICE_CID;            NS_WITH_SERVICE( nsIStringBundleService, bundleService, cid, &rv );            if ( NS_SUCCEEDED( rv ) ) {                nsCOMPtr<nsIStringBundle> bundle;                PRUnichar *pString;                rv = bundleService->CreateBundle( "chrome://global/locale/downloadProgress.properties",                                                  getter_AddRefs(bundle) );                if ( NS_SUCCEEDED( rv ) ) {                    rv = bundle->GetStringFromName( NS_ConvertASCIItoUCS2( "FilePickerTitle" ).GetUnicode(),                                                    &pString );                    if ( NS_SUCCEEDED( rv ) && pString ) {                        title = pString;                        nsAllocator::Free( pString );                    }                }            }                    rv = picker->Init( parent, title.GetUnicode(), nsIFilePicker::modeSave );            PRInt16 rc = nsIFilePicker::returnCancel;            if ( NS_SUCCEEDED( rv ) ) {                // Set default file name.                rv = picker->SetDefaultString( suggested.GetUnicode() );                // Set file filter mask.                rv = picker->AppendFilters( nsIFilePicker::filterAll );                rv = picker->Show( &rc );            }            if ( rc != nsIFilePicker::returnCancel ) {                // Give result to caller.                rv = picker->GetFile( aResult );                if ( NS_SUCCEEDED( rv ) && prefs ) {                    // Save selected directory for next time.                    nsCOMPtr<nsIFile> newStartDir;                    rv = (*aResult)->GetParent( getter_AddRefs( newStartDir ) );                    startDir = do_QueryInterface( newStartDir );                    if ( NS_SUCCEEDED( rv ) && startDir ) {                        prefs->SetFileXPref( "browser.download.dir", startDir );                    }                }            } else if ( NS_SUCCEEDED( rv ) ) {                // User cancelled.                rv = NS_ERROR_ABORT;            }        }    } else {        rv = NS_ERROR_NULL_POINTER;    }    return rv;}