if (!mCurrentArcs) { mCurrentArcs = mInstallArcs; mCurrentDataSource = mInstallDataSource;  if (!mInstallArcs) return NS_ERROR_FAILURE; } else if (mCurrentArcs == mProfileArcs) { PRBool hasMore; mProfileArcs->HasMoreElements(&hasMore); if (!hasMore) { mCurrentArcs = mInstallArcs; mCurrentDataSource = mInstallDataSource; } if (!mInstallArcs) return NS_ERROR_FAILURE; }
if (!mArcs) return NS_ERROR_FAILURE;
NS_IMETHODIMP nsChromeEntryEnumerator::GetNext(nsISupports **aResult){  nsresult rv;  *aResult = nsnull;  if (!mCurrentArcs) {    mCurrentArcs = mInstallArcs;    mCurrentDataSource = mInstallDataSource;    if (!mInstallArcs)      return NS_ERROR_FAILURE;  }  else if (mCurrentArcs == mProfileArcs) {    PRBool hasMore;    mProfileArcs->HasMoreElements(&hasMore);    if (!hasMore) {      mCurrentArcs = mInstallArcs;      mCurrentDataSource = mInstallDataSource;    }    if (!mInstallArcs)      return NS_ERROR_FAILURE;  }  nsCOMPtr<nsISupports> supports;  mCurrentArcs->GetNext(getter_AddRefs(supports));  // The resource that we obtain is the name of the skin/locale/package with  // "chrome:" prepended to it. It has arcs to simple literals  // for each of the fields that should be in the chrome entry.  // We need to construct a chrome entry and then fill in the  // values by enumerating the arcs out of our resource (to the  // literals)  nsCOMPtr<nsIRDFResource> resource = do_QueryInterface(supports, &rv);  if (NS_FAILED(rv))    return rv;  nsCOMPtr<nsIChromeEntry> chromeEntry;  rv = nsComponentManager::CreateInstance("component://netscape/chrome/chrome-entry",                                          nsnull,                                          NS_GET_IID(nsIChromeEntry),                                          getter_AddRefs(chromeEntry));  // XXX Now that we have a resource, we must examine all of its outgoing  // arcs and use the literals at the ends of the arcs to set the fields  // of the chrome entry.  nsAutoString name, text, author, version, siteURL, previewImageURL, archive;  nsChromeRegistry::GetChromeResource(mCurrentDataSource, name, resource,                                       nsChromeRegistry::kCHROME_name);  nsChromeRegistry::GetChromeResource(mCurrentDataSource, name, resource,                                       nsChromeRegistry::kCHROME_text);  nsChromeRegistry::GetChromeResource(mCurrentDataSource, name, resource,                                       nsChromeRegistry::kCHROME_author);  nsChromeRegistry::GetChromeResource(mCurrentDataSource, name, resource,                                       nsChromeRegistry::kCHROME_version);  nsChromeRegistry::GetChromeResource(mCurrentDataSource, name, resource,                                       nsChromeRegistry::kCHROME_siteURL);  nsChromeRegistry::GetChromeResource(mCurrentDataSource, name, resource,                                       nsChromeRegistry::kCHROME_previewImageURL);  nsChromeRegistry::GetChromeResource(mCurrentDataSource, name, resource,                                       nsChromeRegistry::kCHROME_archive);  chromeEntry->SetName(name.GetUnicode());  chromeEntry->SetText(text.GetUnicode());  chromeEntry->SetAuthor(author.GetUnicode());  chromeEntry->SetVersion(version.GetUnicode());  chromeEntry->SetSiteURL(siteURL.GetUnicode());  chromeEntry->SetPreviewImageURL(previewImageURL.GetUnicode());  chromeEntry->SetArchive(archive.GetUnicode());  nsCOMPtr<nsISupports> sup;  sup = do_QueryInterface(chromeEntry, &rv);  if (NS_FAILED(rv))    return NS_OK;  *aResult = sup;  NS_ADDREF(*aResult);  return NS_OK;}