nsresult AsyncFaviconDataReady::OnFaviconDataNotAvailable(void) { if (!mURLShortcut) { return NS_OK; } nsCOMPtr<nsIFile> icoFile; nsresult rv = FaviconHelper::GetOutputIconPath(mNewURI, icoFile, mURLShortcut); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIURI> mozIconURI; rv = NS_NewURI(getter_AddRefs(mozIconURI), "moz-icon://.html?size=32"); if (NS_FAILED(rv)) { return rv; } nsCOMPtr<nsIChannel> channel; rv = NS_NewChannel(getter_AddRefs(channel), mozIconURI); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<myDownloadObserver> downloadObserver = new myDownloadObserver; nsCOMPtr<nsIStreamListener> listener; rv = NS_NewDownloader(getter_AddRefs(listener), downloadObserver, icoFile); NS_ENSURE_SUCCESS(rv, rv); channel->AsyncOpen(listener, nullptr); return NS_OK; }
nsresult nsJARChannel::EnsureJarInput(PRBool blocking) { LOG(("nsJARChannel::EnsureJarInput [this=%x %s]\n", this, mSpec.get())); nsresult rv; nsCOMPtr<nsIURI> uri; rv = mJarURI->GetJARFile(getter_AddRefs(mJarBaseURI)); if (NS_FAILED(rv)) return rv; rv = mJarURI->GetJAREntry(mJarEntry); if (NS_FAILED(rv)) return rv; // The name of the JAR entry must not contain URL-escaped characters: // we're moving from URL domain to a filename domain here. nsStandardURL // does basic escaping by default, which breaks reading zipped files which // have e.g. spaces in their filenames. NS_UnescapeURL(mJarEntry); // try to get a nsIFile directly from the url, which will often succeed. { nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(mJarBaseURI); if (fileURL) fileURL->GetFile(getter_AddRefs(mJarFile)); } if (mJarFile) { mIsUnsafe = PR_FALSE; // NOTE: we do not need to deal with mSecurityInfo here, // because we're loading from a local file rv = CreateJarInput(gJarHandler->JarCache()); } else if (blocking) { NS_NOTREACHED("need sync downloader"); rv = NS_ERROR_NOT_IMPLEMENTED; } else { // kick off an async download of the base URI... rv = NS_NewDownloader(getter_AddRefs(mDownloader), this); if (NS_SUCCEEDED(rv)) rv = NS_OpenURI(mDownloader, nsnull, mJarBaseURI, nsnull, mLoadGroup, mCallbacks, mLoadFlags & ~(LOAD_DOCUMENT_URI | LOAD_CALL_CONTENT_SNIFFERS)); } return rv; }