From bdb26abe73c86925b0906670fce2d8fab2566cd7 Mon Sep 17 00:00:00 2001 From: "jshin%mailaps.org" Date: Wed, 12 Sep 2007 17:51:16 +0000 Subject: [PATCH] bug 191053 : relanding the original patch + ben's firefox patch + additional patch (sr=bz for additional changes to fix Windows bustage) --- suite/browser/public/nsIBookmarksService.idl | 6 ++--- suite/browser/src/nsBookmarksService.cpp | 28 +++++++++++++++----- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/suite/browser/public/nsIBookmarksService.idl b/suite/browser/public/nsIBookmarksService.idl index ab528aa3b51..42b3e76cf89 100644 --- a/suite/browser/public/nsIBookmarksService.idl +++ b/suite/browser/public/nsIBookmarksService.idl @@ -60,7 +60,7 @@ interface nsIBookmarksService : nsISupports boolean isBookmarked(in string aURL); boolean isBookmarkedResource(in nsIRDFResource aSource); - void addBookmarkImmediately(in string aURI, in wstring aTitle, in long bmType, in wstring docCharset); + void addBookmarkImmediately(in wstring aURI, in wstring aTitle, in long bmType, in wstring docCharset); nsIRDFResource createFolder(in wstring aName); nsIRDFResource createFolderInContainer(in wstring aName, in nsIRDFResource aParentFolder, @@ -77,12 +77,12 @@ interface nsIBookmarksService : nsISupports in boolean aRecurse); nsIRDFResource createBookmark(in wstring aName, - in string aURL, + in wstring aURL, in wstring aShortcutURL, in wstring aDescription, in wstring aDocCharSet); nsIRDFResource createBookmarkInContainer(in wstring aName, - in string aURL, + in wstring aURL, in wstring aShortcutURL, in wstring aDescription, in wstring aDocCharSet, diff --git a/suite/browser/src/nsBookmarksService.cpp b/suite/browser/src/nsBookmarksService.cpp index 2038b83e60e..ab54506084b 100644 --- a/suite/browser/src/nsBookmarksService.cpp +++ b/suite/browser/src/nsBookmarksService.cpp @@ -3082,7 +3082,7 @@ nsBookmarksService::SetNewPersonalToolbarFolder(nsIRDFResource* aFolder) NS_IMETHODIMP nsBookmarksService::CreateBookmark(const PRUnichar* aName, - const char* aURL, + const PRUnichar* aURL, const PRUnichar* aShortcutURL, const PRUnichar* aDescription, const PRUnichar* aDocCharSet, @@ -3119,7 +3119,7 @@ nsBookmarksService::CreateBookmark(const PRUnichar* aName, // Resource: URL nsAutoString url; - url.AssignWithConversion(aURL); + url.Assign(aURL); nsCOMPtr urlLiteral; rv = gRDF->GetLiteral(url.get(), getter_AddRefs(urlLiteral)); if (NS_FAILED(rv)) @@ -3181,7 +3181,7 @@ nsBookmarksService::CreateBookmark(const PRUnichar* aName, NS_IMETHODIMP nsBookmarksService::CreateBookmarkInContainer(const PRUnichar* aName, - const char* aURL, + const PRUnichar* aURL, const PRUnichar* aShortcutURL, const PRUnichar* aDescription, const PRUnichar* aDocCharSet, @@ -3275,7 +3275,7 @@ nsBookmarksService::CloneResource(nsIRDFResource* aSource, } NS_IMETHODIMP -nsBookmarksService::AddBookmarkImmediately(const char *aURI, +nsBookmarksService::AddBookmarkImmediately(const PRUnichar *aURI, const PRUnichar *aTitle, PRInt32 aBookmarkType, const PRUnichar *aCharset) @@ -3853,8 +3853,14 @@ nsBookmarksService::ParseFavoritesFolder(nsIFile* aDirectory, nsIRDFResource* aP bookmarkName.Truncate(lnkExtStart); nsCOMPtr bookmark; - CreateBookmarkInContainer(bookmarkName.get(), spec.get(), nsnull, - nsnull, nsnull, aParentResource, -1, getter_AddRefs(bookmark)); + // NS_GetURLSpecFromFile on Windows returns url-escaped URL in + // pure ASCII. However, in the future, we may return 'hostpart' + // of a remote file in UTF-8. Therefore, using UTF-8 in place of + // ASCII is not a bad idea. + CreateBookmarkInContainer(bookmarkName.get(), + NS_ConvertUTF8toUTF16(spec).get(), + nsnull, nsnull, nsnull, aParentResource, + -1, getter_AddRefs(bookmark)); if (NS_FAILED(rv)) continue; } @@ -3889,7 +3895,15 @@ nsBookmarksService::ParseFavoritesFolder(nsIFile* aDirectory, nsIRDFResource* aP ResolveShortcut(path, getter_Copies(resolvedURL)); nsCOMPtr bookmark; - rv = CreateBookmarkInContainer(name.get(), resolvedURL.get(), nsnull, nsnull, nsnull, aParentResource, -1, getter_AddRefs(bookmark)); + // As far as I can tell, IUniformResourceLocator::GetURL() + // returns the URL in pure ASCII. However, it could be UTF-8 (I'm + // almost sure that it's not in any legacy encoding) so that I'm + // assuming it's in UTF-8. + // http://msdn.microsoft.com/library/default.asp?url=/workshop/misc/shortcuts/reference/iuniformresourcelocator.asp + rv = CreateBookmarkInContainer(name.get(), + NS_ConvertUTF8toUTF16(resolvedURL).get(), + nsnull, nsnull, nsnull, aParentResource, -1, + getter_AddRefs(bookmark)); if (NS_FAILED(rv)) continue; }