95 #include "nsNetUtil.h"
96 #include "nsParserCIID.h"
97 #include "nsStringAPI.h"
98 #include "nsUnicharUtils.h"
99 #include "nsAppDirectoryServiceDefs.h"
100 #include "nsDirectoryServiceUtils.h"
101 #include "nsIPrefService.h"
102 #include "nsToolkitCompsCID.h"
103 #include "nsIHTMLContentSink.h"
104 #include "nsIParser.h"
106 #include "nsIBrowserGlue.h"
107 #include "nsIObserverService.h"
108 #include "nsISupportsPrimitives.h"
112 #define KEY_TOOLBARFOLDER_LOWER "personal_toolbar_folder"
113 #define KEY_BOOKMARKSMENU_LOWER "bookmarks_menu"
114 #define KEY_UNFILEDFOLDER_LOWER "unfiled_bookmarks_folder"
115 #define KEY_PLACESROOT_LOWER "places_root"
116 #define KEY_HREF_LOWER "href"
117 #define KEY_FEEDURL_LOWER "feedurl"
118 #define KEY_WEB_PANEL_LOWER "web_panel"
119 #define KEY_LASTCHARSET_LOWER "last_charset"
120 #define KEY_ICON_LOWER "icon"
121 #define KEY_ICON_URI_LOWER "icon_uri"
122 #define KEY_SHORTCUTURL_LOWER "shortcuturl"
123 #define KEY_POST_DATA_LOWER "post_data"
124 #define KEY_NAME_LOWER "name"
125 #define KEY_MICSUM_GEN_URI_LOWER "micsum_gen_uri"
126 #define KEY_DATE_ADDED_LOWER "add_date"
127 #define KEY_LAST_MODIFIED_LOWER "last_modified"
128 #define KEY_GENERATED_TITLE_LOWER "generated_title"
130 #define LOAD_IN_SIDEBAR_ANNO NS_LITERAL_CSTRING("bookmarkProperties/loadInSidebar")
131 #define DESCRIPTION_ANNO NS_LITERAL_CSTRING("bookmarkProperties/description")
132 #define POST_DATA_ANNO NS_LITERAL_CSTRING("bookmarkProperties/POSTData")
133 #define STATIC_TITLE_ANNO NS_LITERAL_CSTRING("bookmarks/staticTitle")
135 #define BOOKMARKS_MENU_ICON_URI "chrome://browser/skin/places/bookmarksMenu.png"
139 #define RESTORE_BEGIN_NSIOBSERVER_TOPIC "bookmarks-restore-begin"
140 #define RESTORE_SUCCESS_NSIOBSERVER_TOPIC "bookmarks-restore-success"
141 #define RESTORE_FAILED_NSIOBSERVER_TOPIC "bookmarks-restore-failed"
142 #define RESTORE_NSIOBSERVER_DATA NS_LITERAL_STRING("html")
143 #define RESTORE_INITIAL_NSIOBSERVER_DATA NS_LITERAL_STRING("html-initial")
149 #if defined(XP_WIN) || defined(XP_OS2)
150 #define NS_LINEBREAK "\015\012"
152 #define NS_LINEBREAK "\012"
155 class nsIOutputStream;
157 static nsresult
WriteEscapedUrl(
const nsCString &aString, nsIOutputStream* aOutput);
256 PRUint32 len = strlen(
string);
260 rv = (
char *) NS_Alloc((len * 6) + 1);
265 for(; *
string !=
'\0';
string++)
274 else if(*
string ==
'>')
281 else if(*
string ==
'&')
289 else if (*
string ==
'"')
298 else if (*
string ==
'\'')
318 nsINavHistoryBatchCallback)
323 mHistoryService = do_GetService(NS_NAVHISTORYSERVICE_CONTRACTID, &rv);
324 NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
"could not get history service");
325 mFaviconService = do_GetService(NS_FAVICONSERVICE_CONTRACTID, &rv);
326 NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
"could not get favicon service");
327 mAnnotationService = do_GetService(NS_ANNOTATIONSERVICE_CONTRACTID, &rv);
328 NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
"could not get annotation service");
329 mBookmarksService = do_GetService(NS_NAVBOOKMARKSSERVICE_CONTRACTID, &rv);
330 NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
"could not get bookmarks service");
331 mLivemarkService = do_GetService(NS_LIVEMARKSERVICE_CONTRACTID, &rv);
332 NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
"could not get livemark service");
333 mMicrosummaryService = do_GetService(
"@mozilla.org/microsummary/service;1", &rv);
334 NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
"could not get microsummary service");
337 nsPlacesImportExportService::~nsPlacesImportExportService()
349 nsresult
Init(PRBool aAllowRootChanges,
350 nsINavBookmarksService* bookmarkService,
352 PRBool aIsImportDefaults);
370 { *aReturn = PR_TRUE;
return NS_OK; }
376 NS_IMETHOD
AddLeaf(
const nsIParserNode& aNode);
426 NS_ASSERTION(
mFrames.Length() > 0,
"Asking for frame when there are none!");
431 NS_ASSERTION(
mFrames.Length() > 1,
"Asking for frame when there are not enough!");
438 const nsString&
aData);
447 for (PRUint32
i = 0;
i <
mFrames.Length();
i ++)
465 nsINavBookmarksService* bookmarkService,
467 PRBool aIsImportDefaults)
472 NS_ENSURE_SUCCESS(rv, rv);
474 NS_ENSURE_SUCCESS(rv, rv);
476 NS_ENSURE_SUCCESS(rv, rv);
478 NS_ENSURE_SUCCESS(rv, rv);
487 NS_ENSURE_SUCCESS(rv, rv);
495 return NS_ERROR_OUT_OF_MEMORY;
510 switch(aNode.GetNodeType()) {
512 HandleHead1Begin(aNode);
519 HandleHeadBegin(aNode);
522 HandleLinkBegin(aNode);
527 HandleContainerBegin(aNode);
530 CurFrame().mInDescription = PR_TRUE;
551 PRBool hasDescription = PR_FALSE;
555 if (NS_SUCCEEDED(rv) && !hasDescription) {
558 nsIAnnotationService::EXPIRE_NEVER);
580 if (itemId > 0 && lastModified > 0) {
582 NS_ASSERTION(NS_SUCCEEDED(rv),
"SetItemLastModified failed");
631 switch (aNode.GetNodeType()) {
636 case eHTMLTag_entity: {
638 PRInt32 unicode = aNode.TranslateToUnicodeStr(tmp);
647 case eHTMLTag_whitespace:
686 NS_ASSERTION(NS_SUCCEEDED(rv),
"SetItemLastModified failed");
702 PRInt32 attrCount = node.GetAttributeCount();
703 for (PRInt32
i = 0;
i < attrCount;
i ++) {
706 NS_WARNING(
"Trying to set the places root from the middle of the hierarchy. "
707 "This can only be set at the beginning.");
713 NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
"could not get placesRoot");
759 PRInt32 attrCount = node.GetAttributeCount();
762 for (PRInt32
i = 0;
i < attrCount;
i ++) {
833 nsAutoString feedUrl;
835 nsAutoString iconUri;
836 nsAutoString lastCharset;
837 nsAutoString keyword;
838 nsAutoString postData;
839 nsAutoString webPanel;
841 nsAutoString micsumGenURI;
842 nsAutoString generatedTitle;
843 nsAutoString dateAdded;
844 nsAutoString lastModified;
846 PRInt32 attrCount = node.GetAttributeCount();
847 for (PRInt32
i = 0;
i < attrCount;
i ++) {
848 const nsAString&
key = node.GetKeyAt(
i);
850 href = node.GetValueAt(
i);
852 feedUrl = node.GetValueAt(
i);
854 icon = node.GetValueAt(
i);
856 iconUri = node.GetValueAt(
i);
858 lastCharset = node.GetValueAt(
i);
860 keyword = node.GetValueAt(
i);
862 postData = node.GetValueAt(
i);
864 webPanel = node.GetValueAt(
i);
866 micsumGenURI = node.GetValueAt(
i);
868 generatedTitle = node.GetValueAt(
i);
870 dateAdded = node.GetValueAt(
i);
872 lastModified = node.GetValueAt(
i);
891 if (!feedUrl.IsEmpty()) {
893 NS_ConvertUTF16toUTF8(feedUrl), nsnull);
897 if (href.IsEmpty()) {
920 if (!lastModified.IsEmpty()) {
945 NS_ASSERTION(NS_SUCCEEDED(rv),
"InsertBookmark failed");
950 if (!dateAdded.IsEmpty()) {
952 if (convertedDateAdded) {
954 NS_ASSERTION(NS_SUCCEEDED(rv),
"SetItemDateAdded failed");
960 if (!icon.IsEmpty() || !iconUri.IsEmpty()) {
961 nsCOMPtr<nsIURI> iconUriObject;
962 rv = NS_NewURI(getter_AddRefs(iconUriObject), iconUri);
963 if (!icon.IsEmpty() || NS_SUCCEEDED(rv)) {
966 nsCAutoString warnMsg;
967 warnMsg.Append(
"Bookmarks Import: unable to set favicon '");
968 warnMsg.Append(NS_ConvertUTF16toUTF8(iconUri));
969 warnMsg.Append(
"' for page '");
972 if (NS_SUCCEEDED(rv))
973 warnMsg.Append(spec);
975 NS_WARNING(warnMsg.get());
981 if (!keyword.IsEmpty()) {
985 if (!postData.IsEmpty()) {
988 nsIAnnotationService::EXPIRE_NEVER);
992 if (webPanel.LowerCaseEqualsLiteral(
"true")) {
996 nsIAnnotationService::EXPIRE_NEVER);
1000 if (!micsumGenURI.IsEmpty()) {
1001 nsCOMPtr<nsIURI> micsumGenURIObject;
1002 if (NS_SUCCEEDED(NS_NewURI(getter_AddRefs(micsumGenURIObject), micsumGenURI))) {
1010 if (!lastCharset.IsEmpty()) {
1012 NS_ASSERTION(NS_SUCCEEDED(rv),
"setCharsetForURI failed");
1043 PRBool isLivemark = PR_FALSE;
1050 printf(
"Updating livemark '%s' %lld\n",
1054 NS_ASSERTION(NS_SUCCEEDED(rv),
"SetSiteURI failed!");
1056 NS_ASSERTION(NS_SUCCEEDED(rv),
"SetFeedURI failed!");
1058 NS_ASSERTION(NS_SUCCEEDED(rv),
"SetItemTitle failed!");
1070 NS_ASSERTION(NS_SUCCEEDED(rv),
"CreateLivemarkFolderOnly failed!");
1078 NS_ASSERTION(NS_SUCCEEDED(rv),
"CreateLivemark failed!");
1082 printf(
"Creating livemark '%s' %lld\n",
1090 printf(
"Creating bookmark '%s' %lld\n",
1096 nsIAnnotationService::EXPIRE_NEVER);
1097 NS_ASSERTION(NS_SUCCEEDED(rv),
"Could not store user's bookmark title!");
1111 NS_ASSERTION(NS_SUCCEEDED(rv),
"SetItemLastModified failed");
1132 printf(
"--------\n");
1140 PRInt32 attrCount = aNode.GetAttributeCount();
1141 for (PRInt32
i = 0;
i < attrCount;
i ++) {
1142 const nsAString&
key = aNode.GetKeyAt(
i);
1144 name = aNode.GetValueAt(
i);
1148 if (!name.IsEmpty())
1169 nsString containerName;
1174 PRBool updateFolder = PR_FALSE;
1176 switch (containerType) {
1180 NS_ConvertUTF16toUTF8(containerName),
1183 NS_ENSURE_SUCCESS(rv, rv);
1189 NS_ENSURE_SUCCESS(rv, rv);
1194 NS_ENSURE_SUCCESS(rv, rv);
1196 updateFolder = PR_TRUE;
1201 NS_ENSURE_SUCCESS(rv, rv);
1203 updateFolder = PR_TRUE;
1208 NS_ENSURE_SUCCESS(rv, rv);
1219 NS_ENSURE_SUCCESS(rv, rv);
1220 if (itemType == nsINavBookmarksService::TYPE_SEPARATOR) {
1223 NS_ENSURE_SUCCESS(rv, rv);
1228 NS_NOTREACHED(
"Unknown container type");
1233 printf(
"Folder %lld \'%s\'", ourID, NS_ConvertUTF16toUTF8(containerName).
get());
1241 printf(
" [reparenting]");
1251 NS_ASSERTION(NS_SUCCEEDED(rv),
"SetItemDateAdded failed");
1256 NS_ASSERTION(NS_SUCCEEDED(rv),
"SetItemLastModified failed");
1263 return NS_ERROR_OUT_OF_MEMORY;
1277 NS_NOTREACHED(
"Trying to complete more bookmark folders than you started");
1278 return NS_ERROR_FAILURE;
1300 const nsString&
aData)
1303 static PRUint32 serialNumber = 0;
1305 nsCOMPtr<nsIFaviconService> faviconService(do_GetService(NS_FAVICONSERVICE_CONTRACTID, &rv));
1306 NS_ENSURE_SUCCESS(rv, rv);
1311 nsCString faviconScheme;
1312 aIconURI->GetScheme(faviconScheme);
1313 if (faviconScheme.EqualsLiteral(
"chrome")) {
1314 return faviconService->SetFaviconUrlForPage(aPageURI, aIconURI);
1320 if (aData.Length() <= 5)
1325 faviconURI = aIconURI;
1328 nsCAutoString faviconSpec;
1329 faviconSpec.AssignLiteral(
"http://www.mozilla.org/2005/made-up-favicon/");
1330 faviconSpec.AppendInt(serialNumber);
1331 faviconSpec.AppendLiteral(
"-");
1333 PR_snprintf(buf,
sizeof(buf),
"%lld", PR_Now());
1334 faviconSpec.Append(buf);
1335 rv = NS_NewURI(getter_AddRefs(faviconURI), faviconSpec);
1336 if (NS_FAILED(rv)) {
1337 nsCAutoString warnMsg;
1338 warnMsg.Append(
"Bookmarks Import: Unable to make up new favicon '");
1339 warnMsg.Append(faviconSpec);
1340 warnMsg.Append(
"' for page '");
1342 rv = aPageURI->GetSpec(spec);
1343 if (NS_SUCCEEDED(rv))
1344 warnMsg.Append(spec);
1345 warnMsg.Append(
"'");
1346 NS_WARNING(warnMsg.get());
1355 (void) faviconService->SetFaviconDataFromDataURL(faviconURI, aData, 0);
1357 rv = faviconService->SetFaviconUrlForPage(aPageURI, faviconURI);
1358 NS_ENSURE_SUCCESS(rv, rv);
1370 intId = aId.ToInteger(&rv);
1379 PRTime convertedDate = 0;
1380 if (!aDate.IsEmpty()) {
1382 convertedDate = aDate.ToInteger(&rv);
1383 if (NS_SUCCEEDED(rv)) {
1384 convertedDate *= 1000000;
1390 return convertedDate;
1402 nsresult channelStatus;
1403 channel->GetStatus(&channelStatus);
1404 if (NS_FAILED(channelStatus))
1405 return channelStatus;
1407 if (NS_SUCCEEDED(status))
1411 channel->Cancel(status);
1419 "<!-- This is an automatically generated file." NS_LINEBREAK
1422 "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=UTF-8\">" NS_LINEBREAK
1468 nsresult rv = aOutput->Write(PromiseFlatCString(aIndent).
get(), aIndent.Length(), &dummy);
1469 NS_ENSURE_SUCCESS(rv, rv);
1470 rv = aOutput->Write(kBookmarkIntro,
sizeof(kBookmarkIntro)-1, &dummy);
1471 NS_ENSURE_SUCCESS(rv, rv);
1486 nsresult rv = aOutput->Write(PromiseFlatCString(aIndent).
get(), aIndent.Length(), &dummy);
1487 NS_ENSURE_SUCCESS(rv, rv);
1488 rv = aOutput->Write(kBookmarkClose,
sizeof(kBookmarkClose)-1, &dummy);
1489 NS_ENSURE_SUCCESS(rv, rv);
1508 nsCOMPtr<nsIURI>
uri;
1509 rv = NS_NewURI(getter_AddRefs(uri), aURI);
1510 if (NS_FAILED(rv)) {
1511 nsCAutoString warnMsg;
1512 warnMsg.Append(
"Bookmarks Export: Found invalid favicon '");
1513 warnMsg.Append(aURI);
1514 warnMsg.Append(
"'");
1515 NS_WARNING(warnMsg.get());
1520 nsCOMPtr<nsIFaviconService> faviconService = do_GetService(NS_FAVICONSERVICE_CONTRACTID, &rv);
1521 NS_ENSURE_SUCCESS(rv, rv);
1523 rv = faviconService->GetFaviconForPage(uri, getter_AddRefs(faviconURI));
1524 if (rv == NS_ERROR_NOT_AVAILABLE)
1526 NS_ENSURE_SUCCESS(rv, rv);
1528 nsCAutoString faviconScheme;
1529 nsCAutoString faviconSpec;
1530 rv = faviconURI->GetSpec(faviconSpec);
1531 NS_ENSURE_SUCCESS(rv, rv);
1532 rv = faviconURI->GetScheme(faviconScheme);
1533 NS_ENSURE_SUCCESS(rv, rv);
1536 rv = aOutput->Write(kIconURIAttribute,
sizeof(kIconURIAttribute)-1, &dummy);
1537 NS_ENSURE_SUCCESS(rv, rv);
1539 NS_ENSURE_SUCCESS(rv, rv);
1540 rv = aOutput->Write(kQuoteStr,
sizeof(kQuoteStr)-1, &dummy);
1541 NS_ENSURE_SUCCESS(rv, rv);
1543 if (!faviconScheme.EqualsLiteral(
"chrome")) {
1546 nsAutoString faviconContents;
1547 rv = faviconService->GetFaviconDataAsDataURL(faviconURI, faviconContents);
1548 NS_ENSURE_SUCCESS(rv, rv);
1549 if (faviconContents.Length() > 0) {
1550 rv = aOutput->Write(kIconAttribute,
sizeof(kIconAttribute)-1, &dummy);
1551 NS_ENSURE_SUCCESS(rv, rv);
1552 NS_ConvertUTF16toUTF8 utf8Favicon(faviconContents);
1553 rv = aOutput->Write(utf8Favicon.get(), utf8Favicon.Length(), &dummy);
1554 NS_ENSURE_SUCCESS(rv, rv);
1555 rv = aOutput->Write(kQuoteStr,
sizeof(kQuoteStr)-1, &dummy);
1556 NS_ENSURE_SUCCESS(rv, rv);
1568 WriteDateAttribute(
const char aAttributeStart[], PRInt32 aLength, PRTime aAttributeValue, nsIOutputStream* aOutput)
1572 nsresult rv = aOutput->Write(aAttributeStart, aLength, &dummy);
1573 NS_ENSURE_SUCCESS(rv, rv);
1576 aAttributeValue /= 1000000;
1579 char dateInSeconds[32];
1580 PR_snprintf(dateInSeconds,
sizeof(dateInSeconds),
"%lld", aAttributeValue);
1581 rv = aOutput->Write(dateInSeconds, strlen(dateInSeconds), &dummy);
1583 NS_ENSURE_SUCCESS(rv, rv);
1584 return aOutput->Write(kQuoteStr,
sizeof(kQuoteStr)-1, &dummy);
1594 nsIOutputStream* aOutput)
1597 NS_ENSURE_SUCCESS(rv, rv);
1599 NS_ENSURE_SUCCESS(rv, rv);
1601 NS_ENSURE_SUCCESS(rv, rv);
1603 NS_ENSURE_SUCCESS(rv, rv);
1615 nsIOutputStream* aOutput)
1621 if (!aIndent.IsEmpty()) {
1622 rv = aOutput->Write(PromiseFlatCString(aIndent).
get(), aIndent.Length(), &dummy);
1623 NS_ENSURE_SUCCESS(rv, rv);
1627 rv = aOutput->Write(kContainerIntro,
sizeof(kContainerIntro)-1, &dummy);
1628 NS_ENSURE_SUCCESS(rv, rv);
1632 rv = aFolder->GetItemId(&folderId);
1633 NS_ENSURE_SUCCESS(rv, rv);
1636 PRTime dateAdded = 0;
1637 rv = aFolder->GetDateAdded(&dateAdded);
1638 NS_ENSURE_SUCCESS(rv, rv);
1641 rv =
WriteDateAttribute(kDateAddedAttribute,
sizeof(kDateAddedAttribute)-1, dateAdded, aOutput);
1642 NS_ENSURE_SUCCESS(rv, rv);
1646 PRTime lastModified = 0;
1647 rv = aFolder->GetLastModified(&lastModified);
1648 NS_ENSURE_SUCCESS(rv, rv);
1651 rv =
WriteDateAttribute(kLastModifiedAttribute,
sizeof(kLastModifiedAttribute)-1, lastModified, aOutput);
1652 NS_ENSURE_SUCCESS(rv, rv);
1657 NS_ENSURE_SUCCESS(rv,rv);
1659 PRInt64 bookmarksMenuFolder;
1661 NS_ENSURE_SUCCESS(rv,rv);
1663 PRInt64 toolbarFolder;
1665 NS_ENSURE_SUCCESS(rv,rv);
1667 PRInt64 unfiledBookmarksFolder;
1669 NS_ENSURE_SUCCESS(rv,rv);
1672 if (folderId == placesRoot) {
1673 rv = aOutput->Write(kPlacesRootAttribute,
sizeof(kPlacesRootAttribute)-1, &dummy);
1674 NS_ENSURE_SUCCESS(rv, rv);
1675 }
else if (folderId == bookmarksMenuFolder) {
1676 rv = aOutput->Write(kBookmarksRootAttribute,
sizeof(kBookmarksRootAttribute)-1, &dummy);
1677 NS_ENSURE_SUCCESS(rv, rv);
1678 }
else if (folderId == unfiledBookmarksFolder) {
1679 rv = aOutput->Write(kUnfiledBookmarksFolderAttribute,
sizeof(kUnfiledBookmarksFolderAttribute)-1, &dummy);
1680 NS_ENSURE_SUCCESS(rv, rv);
1681 }
else if (folderId == toolbarFolder) {
1682 rv = aOutput->Write(kToolbarFolderAttribute,
sizeof(kToolbarFolderAttribute)-1, &dummy);
1683 NS_ENSURE_SUCCESS(rv, rv);
1687 rv = aOutput->Write(kCloseAngle,
sizeof(kCloseAngle)-1, &dummy);
1688 NS_ENSURE_SUCCESS(rv, rv);
1692 NS_ENSURE_SUCCESS(rv, rv);
1695 rv = aOutput->Write(kContainerClose,
sizeof(kContainerClose)-1, &dummy);
1696 NS_ENSURE_SUCCESS(rv, rv);
1700 NS_ENSURE_SUCCESS(rv, rv);
1715 nsresult rv = aItem->GetType(&type);
1716 NS_ENSURE_SUCCESS(rv, rv);
1717 if (type == nsINavHistoryResultNode::RESULT_TYPE_SEPARATOR)
1718 return NS_ERROR_INVALID_ARG;
1720 nsCAutoString title;
1721 rv = aItem->GetTitle(title);
1722 NS_ENSURE_SUCCESS(rv, rv);
1727 rv = aOutput->Write(escapedTitle, strlen(escapedTitle), &dummy);
1728 nsMemory::Free(escapedTitle);
1729 NS_ENSURE_SUCCESS(rv, rv);
1740 nsIOutputStream* aOutput)
1742 PRBool hasDescription = PR_FALSE;
1746 if (NS_FAILED(rv) || !hasDescription)
1749 nsAutoString description;
1752 NS_ENSURE_SUCCESS(rv, rv);
1754 char* escapedDesc =
nsEscapeHTML(NS_ConvertUTF16toUTF8(description).
get());
1757 rv = aOutput->Write(kDescriptionIntro,
sizeof(kDescriptionIntro)-1, &dummy);
1758 if (NS_FAILED(rv)) {
1759 nsMemory::Free(escapedDesc);
1762 rv = aOutput->Write(escapedDesc, strlen(escapedDesc), &dummy);
1763 nsMemory::Free(escapedDesc);
1764 NS_ENSURE_SUCCESS(rv, rv);
1765 aOutput->Write(kDescriptionClose,
sizeof(kDescriptionClose)-1, &dummy);
1766 NS_ENSURE_SUCCESS(rv, rv);
1777 const nsACString& aIndent,
1778 nsIOutputStream* aOutput)
1787 rv = aItem->GetUri(uri);
1788 NS_ENSURE_SUCCESS(rv, rv);
1789 nsCOMPtr<nsIURI> pageURI;
1790 rv = NS_NewURI(getter_AddRefs(pageURI), uri, nsnull);
1791 if (NS_FAILED(rv)) {
1792 nsCAutoString warnMsg;
1793 warnMsg.Append(
"Bookmarks Export: Found invalid item uri '");
1794 warnMsg.Append(uri);
1795 warnMsg.Append(
"'");
1796 NS_WARNING(warnMsg.get());
1801 if (!aIndent.IsEmpty()) {
1802 rv = aOutput->Write(PromiseFlatCString(aIndent).
get(), aIndent.Length(), &dummy);
1803 NS_ENSURE_SUCCESS(rv, rv);
1807 rv = aOutput->Write(kItemOpen,
sizeof(kItemOpen)-1, &dummy);
1808 NS_ENSURE_SUCCESS(rv, rv);
1812 rv = aOutput->Write(kHrefAttribute,
sizeof(kHrefAttribute)-1, &dummy);
1813 NS_ENSURE_SUCCESS(rv, rv);
1815 NS_ENSURE_SUCCESS(rv, rv);
1816 rv = aOutput->Write(kQuoteStr,
sizeof(kQuoteStr)-1, &dummy);
1817 NS_ENSURE_SUCCESS(rv, rv);
1820 PRTime dateAdded = 0;
1821 rv = aItem->GetDateAdded(&dateAdded);
1822 NS_ENSURE_SUCCESS(rv, rv);
1825 rv =
WriteDateAttribute(kDateAddedAttribute,
sizeof(kDateAddedAttribute)-1, dateAdded, aOutput);
1826 NS_ENSURE_SUCCESS(rv, rv);
1830 PRTime lastModified = 0;
1831 rv = aItem->GetLastModified(&lastModified);
1832 NS_ENSURE_SUCCESS(rv, rv);
1835 rv =
WriteDateAttribute(kLastModifiedAttribute,
sizeof(kLastModifiedAttribute)-1, lastModified, aOutput);
1836 NS_ENSURE_SUCCESS(rv, rv);
1841 NS_ENSURE_SUCCESS(rv, rv);
1845 rv = aItem->GetItemId(&itemId);
1846 NS_ENSURE_SUCCESS(rv, rv);
1849 nsAutoString keyword;
1851 NS_ENSURE_SUCCESS(rv, rv);
1852 if (!keyword.IsEmpty()) {
1853 rv = aOutput->Write(kKeywordAttribute,
sizeof(kKeywordAttribute)-1, &dummy);
1854 NS_ENSURE_SUCCESS(rv, rv);
1855 char* escapedKeyword =
nsEscapeHTML(NS_ConvertUTF16toUTF8(keyword).
get());
1856 rv = aOutput->Write(escapedKeyword, strlen(escapedKeyword), &dummy);
1857 nsMemory::Free(escapedKeyword);
1858 NS_ENSURE_SUCCESS(rv, rv);
1859 rv = aOutput->Write(kQuoteStr,
sizeof(kQuoteStr)-1, &dummy);
1860 NS_ENSURE_SUCCESS(rv, rv);
1867 NS_ENSURE_SUCCESS(rv, rv);
1869 nsAutoString postData;
1872 NS_ENSURE_SUCCESS(rv, rv);
1873 rv = aOutput->Write(kPostDataAttribute,
sizeof(kPostDataAttribute)-1, &dummy);
1874 NS_ENSURE_SUCCESS(rv, rv);
1875 char* escapedPostData =
nsEscapeHTML(NS_ConvertUTF16toUTF8(postData).
get());
1876 rv = aOutput->Write(escapedPostData, strlen(escapedPostData), &dummy);
1877 nsMemory::Free(escapedPostData);
1878 NS_ENSURE_SUCCESS(rv, rv);
1879 rv = aOutput->Write(kQuoteStr,
sizeof(kQuoteStr)-1, &dummy);
1880 NS_ENSURE_SUCCESS(rv, rv);
1885 PRBool loadInSidebar = PR_FALSE;
1888 NS_ENSURE_SUCCESS(rv, rv);
1890 aOutput->Write(kWebPanelAttribute,
sizeof(kWebPanelAttribute)-1, &dummy);
1893 nsCOMPtr<nsIMicrosummary> microsummary;
1895 NS_ENSURE_SUCCESS(rv, rv);
1897 nsCOMPtr<nsIMicrosummaryGenerator> generator;
1898 rv = microsummary->GetGenerator(getter_AddRefs(generator));
1899 NS_ENSURE_SUCCESS(rv, rv);
1900 nsCOMPtr<nsIURI> genURI;
1901 rv = generator->GetUri(getter_AddRefs(genURI));
1902 NS_ENSURE_SUCCESS(rv, rv);
1904 rv = genURI->GetSpec(spec);
1905 NS_ENSURE_SUCCESS(rv, rv);
1908 rv = aOutput->Write(kMicsumGenURIAttribute,
sizeof(kMicsumGenURIAttribute)-1, &dummy);
1909 NS_ENSURE_SUCCESS(rv, rv);
1911 NS_ENSURE_SUCCESS(rv, rv);
1912 rv = aOutput->Write(kQuoteStr,
sizeof(kQuoteStr)-1, &dummy);
1913 NS_ENSURE_SUCCESS(rv, rv);
1917 nsAutoString lastCharset;
1918 if (NS_SUCCEEDED(
mHistoryService->GetCharsetForURI(pageURI, lastCharset)) &&
1919 !lastCharset.IsEmpty()) {
1920 rv = aOutput->Write(kLastCharsetAttribute,
sizeof(kLastCharsetAttribute)-1, &dummy);
1921 NS_ENSURE_SUCCESS(rv, rv);
1922 char* escapedLastCharset =
nsEscapeHTML(NS_ConvertUTF16toUTF8(lastCharset).
get());
1923 rv = aOutput->Write(escapedLastCharset, strlen(escapedLastCharset), &dummy);
1924 nsMemory::Free(escapedLastCharset);
1925 NS_ENSURE_SUCCESS(rv, rv);
1926 rv = aOutput->Write(kQuoteStr,
sizeof(kQuoteStr)-1, &dummy);
1927 NS_ENSURE_SUCCESS(rv, rv);
1931 rv = aOutput->Write(kCloseAngle,
sizeof(kCloseAngle)-1, &dummy);
1932 NS_ENSURE_SUCCESS(rv, rv);
1935 nsCAutoString title;
1936 rv = aItem->GetTitle(title);
1937 NS_ENSURE_SUCCESS(rv, rv);
1940 rv = aOutput->Write(escapedTitle, strlen(escapedTitle), &dummy);
1941 nsMemory::Free(escapedTitle);
1942 NS_ENSURE_SUCCESS(rv, rv);
1946 rv = aOutput->Write(kItemClose,
sizeof(kItemClose)-1, &dummy);
1947 NS_ENSURE_SUCCESS(rv, rv);
1951 NS_ENSURE_SUCCESS(rv, rv);
1964 nsIOutputStream* aOutput)
1970 if (!aIndent.IsEmpty()) {
1971 rv = aOutput->Write(PromiseFlatCString(aIndent).
get(), aIndent.Length(), &dummy);
1972 NS_ENSURE_SUCCESS(rv, rv);
1976 rv = aOutput->Write(kItemOpen,
sizeof(kItemOpen)-1, &dummy);
1977 NS_ENSURE_SUCCESS(rv, rv);
1981 rv = aFolder->GetItemId(&folderId);
1982 NS_ENSURE_SUCCESS(rv, rv);
1985 nsCOMPtr<nsIURI> feedURI;
1987 NS_ENSURE_SUCCESS(rv, rv);
1990 rv = feedURI->GetSpec(feedSpec);
1991 NS_ENSURE_SUCCESS(rv, rv);
1994 rv = aOutput->Write(kFeedURIAttribute,
sizeof(kFeedURIAttribute)-1, &dummy);
1995 NS_ENSURE_SUCCESS(rv, rv);
1997 NS_ENSURE_SUCCESS(rv, rv);
1998 rv = aOutput->Write(kQuoteStr,
sizeof(kQuoteStr)-1, &dummy);
1999 NS_ENSURE_SUCCESS(rv, rv);
2003 nsCOMPtr<nsIURI> siteURI;
2005 NS_ENSURE_SUCCESS(rv, rv);
2008 rv = siteURI->GetSpec(siteSpec);
2009 NS_ENSURE_SUCCESS(rv, rv);
2012 rv = aOutput->Write(kHrefAttribute,
sizeof(kHrefAttribute)-1, &dummy);
2013 NS_ENSURE_SUCCESS(rv, rv);
2015 NS_ENSURE_SUCCESS(rv, rv);
2016 rv = aOutput->Write(kQuoteStr,
sizeof(kQuoteStr)-1, &dummy);
2017 NS_ENSURE_SUCCESS(rv, rv);
2021 rv = aOutput->Write(kCloseAngle,
sizeof(kCloseAngle)-1, &dummy);
2022 NS_ENSURE_SUCCESS(rv, rv);
2026 NS_ENSURE_SUCCESS(rv, rv);
2029 rv = aOutput->Write(kItemClose,
sizeof(kItemClose)-1, &dummy);
2030 NS_ENSURE_SUCCESS(rv, rv);
2034 NS_ENSURE_SUCCESS(rv, rv);
2046 const nsACString& aIndent,
2047 nsIOutputStream* aOutput)
2053 if (!aIndent.IsEmpty()) {
2054 rv = aOutput->Write(PromiseFlatCString(aIndent).
get(), aIndent.Length(),
2056 NS_ENSURE_SUCCESS(rv, rv);
2059 rv = aOutput->Write(kSeparator,
sizeof(kSeparator)-1, &dummy);
2063 rv = aItem->GetItemId(&itemId);
2064 NS_ENSURE_SUCCESS(rv, rv);
2069 nsCAutoString title;
2071 if (NS_SUCCEEDED(rv) && !title.IsEmpty()) {
2072 rv = aOutput->Write(kNameAttribute, strlen(kNameAttribute), &dummy);
2073 NS_ENSURE_SUCCESS(rv, rv);
2078 rv = aOutput->Write(escapedTitle, strlen(escapedTitle), &dummy);
2079 nsMemory::Free(escapedTitle);
2080 NS_ENSURE_SUCCESS(rv, rv);
2081 rv = aOutput->Write(kQuoteStr,
sizeof(kQuoteStr)-1, &dummy);
2082 NS_ENSURE_SUCCESS(rv, rv);
2087 rv = aOutput->Write(kCloseAngle,
sizeof(kCloseAngle)-1, &dummy);
2088 NS_ENSURE_SUCCESS(rv, rv);
2091 rv = aOutput->Write(NS_LINEBREAK,
sizeof(NS_LINEBREAK)-1, &dummy);
2092 NS_ENSURE_SUCCESS(rv, rv);
2109 nsCAutoString escaped(aString);
2111 while ((offset = escaped.FindChar(
'\"')) >= 0) {
2112 escaped.Cut(offset, 1);
2113 escaped.Insert(NS_LITERAL_CSTRING(
"%22"), offset);
2116 return aOutput->Write(escaped.get(), escaped.Length(), &dummy);
2127 nsIOutputStream* aOutput)
2129 nsCAutoString myIndent(aIndent);
2130 myIndent.Append(kIndent);
2133 nsresult rv = aFolder->GetItemId(&folderId);
2134 NS_ENSURE_SUCCESS(rv, rv);
2136 nsCOMPtr<nsINavHistoryContainerResultNode> folderNode = do_QueryInterface(aFolder, &rv);
2137 NS_ENSURE_SUCCESS(rv, rv);
2139 rv = folderNode->SetContainerOpen(PR_TRUE);
2140 NS_ENSURE_SUCCESS(rv, rv);
2142 PRUint32 childCount = 0;
2143 folderNode->GetChildCount(&childCount);
2144 for (PRUint32
i = 0;
i < childCount; ++
i) {
2145 nsCOMPtr<nsINavHistoryResultNode> child;
2146 rv = folderNode->GetChild(
i, getter_AddRefs(child));
2147 NS_ENSURE_SUCCESS(rv, rv);
2149 rv = child->GetType(&type);
2150 NS_ENSURE_SUCCESS(rv, rv);
2151 if (type == nsINavHistoryResultNode::RESULT_TYPE_FOLDER) {
2153 PRInt64 childFolderId;
2154 rv = child->GetItemId(&childFolderId);
2155 NS_ENSURE_SUCCESS(rv, rv);
2160 NS_ENSURE_SUCCESS(rv, rv);
2166 }
else if (type == nsINavHistoryResultNode::RESULT_TYPE_SEPARATOR) {
2169 rv =
WriteItem(child, myIndent, aOutput);
2171 NS_ENSURE_SUCCESS(rv, rv);
2185 PRBool aIsInitialImport)
2188 nsCOMPtr<nsIObserverService> obs =
2189 do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv);
2193 nsCOMPtr<nsISupports> folderIdSupp = nsnull;
2194 if (aFolderId > 0) {
2195 nsCOMPtr<nsISupportsPRInt64> folderIdInt =
2196 do_CreateInstance(NS_SUPPORTS_PRINT64_CONTRACTID, &rv);
2200 rv = folderIdInt->SetData(aFolderId);
2204 folderIdSupp = do_QueryInterface(folderIdInt);
2207 obs->NotifyObservers(folderIdSupp,
2216 nsPlacesImportExportService::ImportHTMLFromFile(nsILocalFile* aFile, PRBool aIsInitialImport)
2226 if (NS_FAILED(rv)) {
2243 nsPlacesImportExportService::ImportHTMLFromFileToFolder(nsILocalFile* aFile, PRInt64 aFolderId, PRBool aIsInitialImport)
2255 if (NS_FAILED(rv)) {
2271 PRBool aAllowRootChanges,
2273 PRBool aIsImportDefaults)
2276 NS_ENSURE_SUCCESS(rv, rv);
2278 nsCOMPtr<nsIFile>
file(do_QueryInterface(aFile));
2281 file->GetPath(path);
2282 printf(
"\nImporting %s\n", NS_ConvertUTF16toUTF8(path).
get());
2287 rv = file->Exists(&exists);
2288 NS_ENSURE_SUCCESS(rv, rv);
2290 return NS_ERROR_INVALID_ARG;
2293 nsCOMPtr<nsIParser> parser = do_CreateInstance(kParserCID, &rv);
2294 NS_ENSURE_SUCCESS(rv, rv);
2297 NS_ENSURE_TRUE(sink, NS_ERROR_OUT_OF_MEMORY);
2298 rv = sink->Init(aAllowRootChanges,
mBookmarksService, aFolder, aIsImportDefaults);
2299 NS_ENSURE_SUCCESS(rv, rv);
2300 parser->SetContentSink(sink);
2304 nsCOMPtr<nsIIOService> ioservice = do_GetIOService(&rv);
2305 NS_ENSURE_SUCCESS(rv, rv);
2306 nsCOMPtr<nsIURI> fileURI;
2307 rv = ioservice->NewFileURI(file, getter_AddRefs(fileURI));
2308 NS_ENSURE_SUCCESS(rv, rv);
2309 rv = ioservice->NewChannelFromURI(fileURI, getter_AddRefs(
mImportChannel));
2310 NS_ENSURE_SUCCESS(rv, rv);
2311 rv =
mImportChannel->SetContentType(NS_LITERAL_CSTRING(
"text/html"));
2312 NS_ENSURE_SUCCESS(rv, rv);
2315 rv = parser->Parse(fileURI, nsnull);
2316 NS_ENSURE_SUCCESS(rv, rv);
2326 nsPlacesImportExportService::RunBatched(
nsISupports* aUserData)
2330 PRInt64 bookmarksMenuFolder;
2332 NS_ENSURE_SUCCESS(rv,rv);
2335 NS_ENSURE_SUCCESS(rv, rv);
2337 PRInt64 toolbarFolder;
2339 NS_ENSURE_SUCCESS(rv,rv);
2342 NS_ENSURE_SUCCESS(rv, rv);
2344 PRInt64 unfiledBookmarksFolder;
2346 NS_ENSURE_SUCCESS(rv,rv);
2349 NS_ENSURE_SUCCESS(rv,rv);
2352 nsCOMPtr<nsIBrowserGlue> glue(do_GetService(
"@mozilla.org/browser/browserglue;1", &rv));
2353 NS_ENSURE_SUCCESS(rv, rv);
2355 rv = glue->EnsurePlacesDefaultQueriesInitialized();
2356 NS_ENSURE_SUCCESS(rv, rv);
2360 nsCOMPtr<nsIInputStream> stream;
2362 NS_ENSURE_SUCCESS(rv, rv);
2363 nsCOMPtr<nsIInputStream> bufferedstream;
2364 rv = NS_NewBufferedInputStream(getter_AddRefs(bufferedstream), stream, 4096);
2365 NS_ENSURE_SUCCESS(rv, rv);
2370 nsCOMPtr<nsIStreamListener>
listener = do_QueryInterface(aUserData, &rv);
2371 NS_ENSURE_SUCCESS(rv, rv);
2374 while (NS_SUCCEEDED(rv))
2377 rv = bufferedstream->Available(&available);
2378 if (rv == NS_BASE_STREAM_CLOSED) {
2382 if (NS_FAILED(rv)) {
2389 rv = listener->OnDataAvailable(
mImportChannel, nsnull, bufferedstream, 0,
2402 nsPlacesImportExportService::ExportHTMLToFile(nsILocalFile* aBookmarksFile)
2404 if (!aBookmarksFile)
2405 return NS_ERROR_NULL_POINTER;
2409 aBookmarksFile->GetPath(path);
2410 printf(
"\nExporting %s\n", NS_ConvertUTF16toUTF8(path).
get());
2412 PRTime startTime = PR_Now();
2413 printf(
"\nStart time: %lld\n", startTime);
2417 NS_ENSURE_SUCCESS(rv, rv);
2421 nsCOMPtr<nsIOutputStream> out;
2422 rv = NS_NewSafeLocalFileOutputStream(getter_AddRefs(out),
2427 NS_ENSURE_SUCCESS(rv, rv);
2431 nsCOMPtr<nsIOutputStream> strm;
2432 rv = NS_NewBufferedOutputStream(getter_AddRefs(strm), out, 4096);
2433 NS_ENSURE_SUCCESS(rv, rv);
2436 PRInt64 bookmarksMenuFolder;
2438 NS_ENSURE_SUCCESS(rv,rv);
2440 PRInt64 toolbarFolder;
2442 NS_ENSURE_SUCCESS(rv,rv);
2444 PRInt64 unfiledBookmarksFolder;
2446 NS_ENSURE_SUCCESS(rv,rv);
2450 rv = strm->Write(kFileIntro,
sizeof(kFileIntro)-1, &dummy);
2451 NS_ENSURE_SUCCESS(rv, rv);
2454 nsCOMPtr<nsINavHistoryQueryOptions>
options;
2456 NS_ENSURE_SUCCESS(rv, rv);
2459 nsCOMPtr<nsINavHistoryQuery> query;
2461 NS_ENSURE_SUCCESS(rv, rv);
2464 rv = query->SetFolders(&bookmarksMenuFolder, 1);
2465 NS_ENSURE_SUCCESS(rv, rv);
2468 nsCOMPtr<nsINavHistoryResult> result;
2469 rv =
mHistoryService->ExecuteQuery(query, options, getter_AddRefs(result));
2470 NS_ENSURE_SUCCESS(rv, rv);
2473 nsCOMPtr<nsINavHistoryContainerResultNode> rootNode;
2474 rv = result->GetRoot(getter_AddRefs(rootNode));
2475 NS_ENSURE_SUCCESS(rv, rv);
2478 rv = strm->Write(kRootIntro,
sizeof(kRootIntro)-1, &dummy);
2479 NS_ENSURE_SUCCESS(rv, rv);
2482 rv = strm->Write(kCloseAngle,
sizeof(kCloseAngle)-1, &dummy);
2483 NS_ENSURE_SUCCESS(rv, rv);
2485 NS_ENSURE_SUCCESS(rv, rv);
2486 rv = strm->Write(kCloseRootH1,
sizeof(kCloseRootH1)-1, &dummy);
2487 NS_ENSURE_SUCCESS(rv, rv);
2491 NS_ENSURE_SUCCESS(rv, rv);
2494 nsCAutoString indent;
2495 indent.Assign(kIndent);
2499 NS_ENSURE_SUCCESS(rv, rv);
2503 rv = query->SetFolders(&toolbarFolder, 1);
2504 NS_ENSURE_SUCCESS(rv, rv);
2506 rv =
mHistoryService->ExecuteQuery(query, options, getter_AddRefs(result));
2507 NS_ENSURE_SUCCESS(rv, rv);
2510 rv = result->GetRoot(getter_AddRefs(rootNode));
2511 NS_ENSURE_SUCCESS(rv, rv);
2513 rv =
WriteContainer(rootNode, nsDependentCString(kIndent), strm);
2514 NS_ENSURE_SUCCESS(rv, rv);
2517 rv = query->SetFolders(&unfiledBookmarksFolder, 1);
2518 NS_ENSURE_SUCCESS(rv, rv);
2520 rv =
mHistoryService->ExecuteQuery(query, options, getter_AddRefs(result));
2521 NS_ENSURE_SUCCESS(rv, rv);
2524 rv = result->GetRoot(getter_AddRefs(rootNode));
2525 NS_ENSURE_SUCCESS(rv, rv);
2527 rv = rootNode->SetContainerOpen(PR_TRUE);
2528 NS_ENSURE_SUCCESS(rv, rv);
2530 PRUint32 childCount = 0;
2531 rv = rootNode->GetChildCount(&childCount);
2532 NS_ENSURE_SUCCESS(rv, rv);
2534 if (childCount > 0) {
2535 rv =
WriteContainer(rootNode, nsDependentCString(kIndent), strm);
2536 NS_ENSURE_SUCCESS(rv, rv);
2541 NS_ENSURE_SUCCESS(rv, rv);
2544 nsCOMPtr<nsISafeOutputStream> safeStream = do_QueryInterface(strm, &rv);
2545 NS_ENSURE_SUCCESS(rv, rv);
2546 rv = safeStream->Finish();
2548 printf(
"\nTotal time in seconds: %lld\n", (PR_Now() - startTime)/1000000);
2553 #define BROWSER_BOOKMARKS_MAX_BACKUPS_PREF "browser.bookmarks.max_backups"
2556 nsPlacesImportExportService::BackupBookmarksFile()
2559 NS_ENSURE_SUCCESS(rv, rv);
2562 NS_ENSURE_SUCCESS(rv, rv);
2565 nsCOMPtr<nsIFile> bookmarksFileDir;
2567 getter_AddRefs(bookmarksFileDir));
2569 NS_ENSURE_SUCCESS(rv, rv);
2570 nsCOMPtr<nsILocalFile> bookmarksFile(do_QueryInterface(bookmarksFileDir));
2574 rv = bookmarksFile->Exists(&exists);
2575 if (NS_FAILED(rv)) {
2576 rv = bookmarksFile->Create(nsIFile::NORMAL_FILE_TYPE, 0600);
2577 NS_ASSERTION(rv,
"Unable to create bookmarks.html!");
2582 rv = ExportHTMLToFile(bookmarksFile);
2583 NS_ENSURE_SUCCESS(rv, rv);
static const char kToolbarFolderAttribute[]
#define KEY_GENERATED_TITLE_LOWER
static const char kBookmarkClose[]
#define RESTORE_INITIAL_NSIOBSERVER_DATA
#define KEY_BOOKMARKSMENU_LOWER
#define KEY_WEB_PANEL_LOWER
nsCOMPtr< nsIAnnotationService > mAnnotationService
nsCOMPtr< nsIURI > mPreviousLink
NS_IMETHOD BeginContext(PRInt32 aPosition)
PRTime mPreviousLastModifiedDate
static const char kFeedURIAttribute[]
nsresult WriteLivemark(nsINavHistoryResultNode *aFolder, const nsACString &aIndent, nsIOutputStream *aOutput)
#define KEY_PLACESROOT_LOWER
#define KEY_DATE_ADDED_LOWER
#define KEY_ICON_URI_LOWER
nsCOMPtr< nsIMicrosummaryService > mMicrosummaryService
const NS_PREFSERVICE_CONTRACTID
static const char kItemClose[]
#define KEY_LAST_MODIFIED_LOWER
NS_IMETHOD_(PRBool) IsFormOnStack()
BookmarkImportFrame & PreviousFrame()
NS_IMETHOD WillProcessAToken()
NS_IMPL_ISUPPORTS2(nsPlacesImportExportService, nsIPlacesImportExportService, nsINavHistoryBatchCallback) nsPlacesImportExportService
nsCOMPtr< nsIChannel > mImportChannel
static void NotifyImportObservers(const char *aTopic, PRInt64 aFolderId, PRBool aIsInitialImport)
static const char kCloseAngle[]
nsresult Init(PRBool aAllowRootChanges, nsINavBookmarksService *bookmarkService, PRInt64 aFolder, PRBool aIsImportDefaults)
nsresult EnsureServiceState()
static nsresult SyncChannelStatus(nsIChannel *channel, nsresult status)
nsresult ImportHTMLFromFileInternal(nsILocalFile *aFile, PRBool aAllowRootChanges, PRInt64 aFolder, PRBool aIsImportDefaults)
static const char kUnfiledBookmarksFolderAttribute[]
const NS_APP_BOOKMARKS_50_FILE
static const char kDateAddedAttribute[]
static const char kWhitespace[]
static const char kDescriptionClose[]
static nsresult WriteContainerPrologue(const nsACString &aIndent, nsIOutputStream *aOutput)
void HandleContainerEnd()
nsCOMPtr< nsILivemarkService > mLivemarkService
nsCOMPtr< nsINavHistoryService > mHistoryService
PRTime mPreviousDateAdded
#define KEY_FEEDURL_LOWER
void HandleContainerBegin(const nsIParserNode &node)
NS_IMETHOD AddDocTypeDecl(const nsIParserNode &aNode)
nsCOMPtr< nsINavBookmarksService > mBookmarksService
#define RESTORE_SUCCESS_NSIOBSERVER_TOPIC
#define KEY_UNFILEDFOLDER_LOWER
static const char kBookmarksRootAttribute[]
static const char kDescriptionIntro[]
#define KEY_SHORTCUTURL_LOWER
NS_IMETHOD OpenContainer(const nsIParserNode &aNode)
char * nsEscapeHTML(const char *string)
nsresult WriteDescription(PRInt64 aId, PRInt32 aType, nsIOutputStream *aOutput)
void HandleSeparator(const nsIParserNode &node)
nsresult WriteContainerHeader(nsINavHistoryResultNode *aFolder, const nsACString &aIndent, nsIOutputStream *aOutput)
nsCOMPtr< nsILivemarkService > mLivemarkService
static const char kPlacesRootAttribute[]
PRInt32 mContainerNesting
nsresult WriteSeparator(nsINavHistoryResultNode *aItem, const nsACString &aIndent, nsIOutputStream *aOutput)
static nsresult WriteDateAttribute(const char aAttributeStart[], PRInt32 aLength, PRTime aAttributeValue, nsIOutputStream *aOutput)
NS_IMETHOD CloseContainer(const nsHTMLTag aTag)
static nsresult WriteFaviconAttribute(const nsACString &aURI, nsIOutputStream *aOutput)
#define KEY_LASTCHARSET_LOWER
static const char kHrefAttribute[]
static const char kQuoteStr[]
nsresult WriteContainerContents(nsINavHistoryResultNode *aFolder, const nsACString &aIndent, nsIOutputStream *aOutput)
void ConsumeHeading(nsAString *aHeading, ContainerType *aContainerType)
NS_DECL_ISUPPORTS NS_IMETHOD WillParse()
static const char kMicsumGenURIAttribute[]
static const char kIconAttribute[]
nsresult SetFaviconForURI(nsIURI *aPageURI, nsIURI *aFaviconURI, const nsString &aData)
static nsresult WriteEscapedUrl(const nsCString &aString, nsIOutputStream *aOutput)
static const char kItemOpen[]
NS_IMETHOD DidProcessAToken()
nsCOMPtr< nsIAnnotationService > mAnnotationService
static const char kIconURIAttribute[]
PRTime ConvertImportedDateToInternalDate(const nsACString &aDate)
static const char kLastModifiedAttribute[]
static nsresult WriteContainerEpilogue(const nsACString &aIndent, nsIOutputStream *aOutput)
static const char kSeparator[]
static const char kPostDataAttribute[]
#define KEY_POST_DATA_LOWER
NS_IMETHOD SetDocumentCharset(nsACString &aCharset)
NS_IMETHOD AddLeaf(const nsIParserNode &aNode)
NS_IMETHOD EndContext(PRInt32 aPosition)
static const char kNameAttribute[]
static const char kItemIdAttribute[]
nsCOMPtr< nsIURI > mPreviousFeed
NS_IMETHOD SetParser(nsIParser *aParser)
nsString mPreviousMicrosummaryText
virtual nsISupports * GetTarget()
void HandleHeadBegin(const nsIParserNode &node)
BookmarkImportFrame & CurFrame()
nsCOMPtr< nsIMicrosummaryService > mMicrosummaryService
nsresult WriteTitle(nsINavHistoryResultNode *aItem, nsIOutputStream *aOutput)
#define KEY_MICSUM_GEN_URI_LOWER
NS_IMETHOD NotifyTagObservers(nsIParserNode *aNode)
void HandleLinkBegin(const nsIParserNode &node)
nsresult WriteItem(nsINavHistoryResultNode *aItem, const nsACString &aIndent, nsIOutputStream *aOutput)
static const char kIndent[]
#define LOAD_IN_SIDEBAR_ANNO
nsCOMPtr< nsINavBookmarksService > mBookmarksService
nsCOMPtr< nsINavHistoryService > mHistoryService
static NS_DEFINE_CID(kParserCID, NS_PARSER_CID)
#define RESTORE_NSIOBSERVER_DATA
#define KEY_TOOLBARFOLDER_LOWER
static const char kCloseRootH1[]
static const char kContainerClose[]
virtual void FlushPendingNotifications(mozFlushType aType)
static const char kRootIntro[]
nsresult WriteContainer(nsINavHistoryResultNode *aFolder, const nsACString &aIndent, nsIOutputStream *aOutput)
#define STATIC_TITLE_ANNO
nsCOMPtr< nsIMicrosummary > mPreviousMicrosummary
ContainerType mLastContainerType
static const char kKeywordAttribute[]
NS_IMETHOD WillInterrupt()
nsTArray< BookmarkImportFrame > mFrames
BookmarkImportFrame(PRInt64 aID)
_getSelectedPageStyle s i
NS_IMETHOD DidProcessTokens()
static const char kBookmarkIntro[]
#define RESTORE_BEGIN_NSIOBSERVER_TOPIC
PRInt64 ConvertImportedIdToInternalId(const nsCString &aId)
NS_IMETHOD AddProcessingInstruction(const nsIParserNode &aNode)
void HandleHead1Begin(const nsIParserNode &node)
static const char kWebPanelAttribute[]
_updateTextAndScrollDataForFrame aData
NS_IMETHOD AddComment(const nsIParserNode &aNode)
NS_IMETHOD IsEnabled(PRInt32 aTag, PRBool *aReturn)
#define RESTORE_FAILED_NSIOBSERVER_TOPIC
static const char kLastCharsetAttribute[]
static const char kContainerIntro[]