Relanding bug 381280 (respect browser.bookmarks.file pref), this time with Ts fixes, r=mano
git-svn-id: svn://10.0.0.236/trunk@226694 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -113,12 +113,16 @@ nsBrowserDirectoryProvider::GetFile(const char *aKey, PRBool *aPersist,
|
||||
nsCOMPtr<nsIFile> file;
|
||||
|
||||
char const* leafName = nsnull;
|
||||
#ifndef MOZ_PLACES_BOOKMARKS
|
||||
PRBool restoreBookmarksBackup = PR_FALSE;
|
||||
PRBool ensureFilePermissions = PR_FALSE;
|
||||
#endif
|
||||
|
||||
if (!strcmp(aKey, NS_APP_BOOKMARKS_50_FILE)) {
|
||||
#ifndef MOZ_PLACES_BOOKMARKS
|
||||
ensureFilePermissions = PR_TRUE;
|
||||
restoreBookmarksBackup = PR_TRUE;
|
||||
#endif
|
||||
leafName = "bookmarks.html";
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
@@ -180,7 +184,7 @@ nsBrowserDirectoryProvider::GetFile(const char *aKey, PRBool *aPersist,
|
||||
|
||||
file->AppendNative(leafstr);
|
||||
}
|
||||
|
||||
#ifndef MOZ_PLACES_BOOKMARKS
|
||||
PRBool exists;
|
||||
rv = file->Exists(&exists);
|
||||
|
||||
@@ -212,7 +216,7 @@ nsBrowserDirectoryProvider::GetFile(const char *aKey, PRBool *aPersist,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
*aPersist = PR_TRUE;
|
||||
NS_ADDREF(*aResult = file);
|
||||
|
||||
@@ -334,7 +338,7 @@ static const nsModuleComponentInfo components[] = {
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE(BrowserDirProvider, components)
|
||||
|
||||
#ifndef MOZ_PLACES_BOOKMARKS
|
||||
nsresult
|
||||
nsBrowserDirectoryProvider::RestoreBookmarksFromBackup(const nsACString& aLeafName,
|
||||
nsIFile* aParentDir,
|
||||
@@ -379,7 +383,7 @@ nsBrowserDirectoryProvider::EnsureProfileFile(const nsACString& aLeafName,
|
||||
|
||||
defaults->CopyToNative(aParentDir, aLeafName);
|
||||
}
|
||||
|
||||
#endif
|
||||
NS_IMPL_ISUPPORTS1(nsBrowserDirectoryProvider::AppendingEnumerator,
|
||||
nsISimpleEnumerator)
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ BrowserGlue.prototype = {
|
||||
|
||||
/**
|
||||
* Initialize Places
|
||||
* - imports bookmarks.html if bookmarks datastore is empty
|
||||
* - imports the bookmarks html file if bookmarks datastore is empty
|
||||
*/
|
||||
_initPlaces: function bg__initPlaces() {
|
||||
#ifdef MOZ_PLACES_BOOKMARKS
|
||||
@@ -205,13 +205,11 @@ BrowserGlue.prototype = {
|
||||
|
||||
var dirService = Components.classes["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Components.interfaces.nsIProperties);
|
||||
var profDir = dirService.get("ProfD", Components.interfaces.nsILocalFile);
|
||||
|
||||
var bookmarksFile = profDir.clone(); // bookmarks.html
|
||||
bookmarksFile.append("bookmarks.html");
|
||||
var bookmarksFile = dirService.get("BMarks", Components.interfaces.nsILocalFile);
|
||||
|
||||
if (bookmarksFile.exists()) {
|
||||
// import bookmarks.html
|
||||
// import the file
|
||||
try {
|
||||
var importer =
|
||||
Components.classes["@mozilla.org/browser/places/import-export-service;1"]
|
||||
@@ -224,6 +222,7 @@ BrowserGlue.prototype = {
|
||||
|
||||
// backup pre-places bookmarks.html
|
||||
// XXXtodo remove this before betas, after import/export is solid
|
||||
var profDir = dirService.get("ProfD", Components.interfaces.nsILocalFile);
|
||||
var bookmarksBackup = profDir.clone();
|
||||
bookmarksBackup.append("bookmarks.preplaces.html");
|
||||
if (!bookmarksBackup.exists()) {
|
||||
|
||||
Reference in New Issue
Block a user