nsresult
nsNetscapeProfileMigratorBase::ImportNetscapeBookmarks(const nsAString& aBookmarksFileName,
                                                       const PRUnichar* aImportSourceNameKey)
{
  nsCOMPtr<nsIFile> bookmarksFile;
  mSourceProfile->Clone(getter_AddRefs(bookmarksFile));
  bookmarksFile->Append(aBookmarksFileName);
  
  return ImportBookmarksHTML(bookmarksFile, PR_FALSE, PR_FALSE, aImportSourceNameKey);
}
nsresult
nsNetscapeProfileMigratorBase::ImportNetscapeBookmarks(const char* aBookmarksFileName,
                                                       const char* aImportSourceNameKey)
{
  nsCOMPtr<nsIFile> bookmarksFile;
  mSourceProfile->Clone(getter_AddRefs(bookmarksFile));
  bookmarksFile->AppendNative(nsDependentCString(aBookmarksFileName));

  return ImportBookmarksHTML(bookmarksFile,
                             NS_ConvertUTF8toUTF16(aImportSourceNameKey).get());
}
nsresult
nsSeamonkeyProfileMigrator::CopyBookmarks(PRBool aReplace)
{
  nsresult rv;
  if (aReplace) {
    // Initialize the default bookmarks
    rv = InitializeBookmarks(mTargetProfile);
    NS_ENSURE_SUCCESS(rv, rv);

    // Merge in the bookmarks from the source profile
    nsCOMPtr<nsIFile> sourceFile;
    mSourceProfile->Clone(getter_AddRefs(sourceFile));
    sourceFile->Append(FILE_NAME_BOOKMARKS);
    rv = ImportBookmarksHTML(sourceFile, PR_TRUE, PR_FALSE, EmptyString().get());
    NS_ENSURE_SUCCESS(rv, rv);
  }
  else {
    rv = ImportNetscapeBookmarks(FILE_NAME_BOOKMARKS, 
                                 NS_LITERAL_STRING("sourceNameSeamonkey").get());
    NS_ENSURE_SUCCESS(rv, rv);
  }
  return NS_OK;
}
nsresult
nsMacIEProfileMigrator::CopyBookmarks(PRBool aReplace)
{
  nsresult rv;
  nsCOMPtr<nsIFile> sourceFile;
  mSourceProfile->Clone(getter_AddRefs(sourceFile));

  sourceFile->Append(MACIE_BOOKMARKS_FILE_NAME);
  PRBool exists = PR_FALSE;
  sourceFile->Exists(&exists);
  if (!exists)
    return NS_OK;

  // it's an import
  if (!aReplace)
    return ImportBookmarksHTML(sourceFile,
                               PR_FALSE,
                               PR_FALSE,
                               NS_LITERAL_STRING("sourceNameIE").get());

  // Initialize the default bookmarks
  rv = InitializeBookmarks(mTargetProfile);
  NS_ENSURE_SUCCESS(rv, rv);

  // If we're blowing away existing content, annotate the Personal Toolbar and
  // then import the file. 
  nsCOMPtr<nsIFile> tempFile;
  mTargetProfile->Clone(getter_AddRefs(tempFile));
  tempFile->Append(TEMP_BOOKMARKS_FILE_NAME);

  // Look for the localized name of the IE Favorites Bar
  nsCOMPtr<nsIStringBundleService> bundleService =
    do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsIStringBundle> bundle;
  rv = bundleService->CreateBundle(MIGRATION_BUNDLE, getter_AddRefs(bundle));
  NS_ENSURE_SUCCESS(rv, rv);

  nsString toolbarFolderNameMacIE;
  bundle->GetStringFromName(NS_LITERAL_STRING("toolbarFolderNameMacIE").get(), 
                            getter_Copies(toolbarFolderNameMacIE));
  nsCAutoString ctoolbarFolderNameMacIE;
  CopyUTF16toUTF8(toolbarFolderNameMacIE, ctoolbarFolderNameMacIE);

  // Now read the 4.x bookmarks file, correcting the Personal Toolbar Folder 
  // line and writing to the temporary file.
  rv = AnnotatePersonalToolbarFolder(sourceFile,
                                     tempFile,
                                     ctoolbarFolderNameMacIE.get());
  NS_ENSURE_SUCCESS(rv, rv);

  // import the temp file
  rv = ImportBookmarksHTML(tempFile,
                           PR_TRUE,
                           PR_FALSE,
                           EmptyString().get());
  NS_ENSURE_SUCCESS(rv, rv);

  // remove the temp file
  return tempFile->Remove(PR_FALSE);
}