Bug 1235099 - Remove the NS_APP_BOOKMARKS_50_FILE directory service key. r=dolske

Nothing in mozilla-central uses the NS_APP_BOOKMARKS_50_FILE/BMarks key except
tests. It's also not been very useful since the switch to places in ... Firefox
3? so even if addons use it, it's not doing them much good.
BookmarkHTMLUtils.defaultPath returns the same thing anyways for those that
really do insist on getting the equivalent thing (but I'd argue
BookmarkHTMLUtils.defaultPath, as well as the browser.bookmarks.file pref could
just go away as well).

Seamonkey does use NS_APP_BOOKMARKS_50_FILE/BMarks, but they really only need
the #define, which they can add in their source.
This commit is contained in:
Mike Hommey 2015-12-25 09:07:59 +09:00
Родитель 80765f938f
Коммит 8810bde2ef
7 изменённых файлов: 1 добавлений и 120 удалений

Просмотреть файл

@ -34,57 +34,7 @@ NS_IMPL_ISUPPORTS(DirectoryProvider,
NS_IMETHODIMP
DirectoryProvider::GetFile(const char *aKey, bool *aPersist, nsIFile* *aResult)
{
nsresult rv;
*aResult = nullptr;
// NOTE: This function can be reentrant through the NS_GetSpecialDirectory
// call, so be careful not to cause infinite recursion.
nsCOMPtr<nsIFile> file;
char const* leafName = nullptr;
if (!strcmp(aKey, NS_APP_BOOKMARKS_50_FILE)) {
leafName = "bookmarks.html";
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefs) {
nsCString path;
rv = prefs->GetCharPref("browser.bookmarks.file", getter_Copies(path));
if (NS_SUCCEEDED(rv)) {
NS_NewNativeLocalFile(path, true, getter_AddRefs(file));
}
}
}
else {
return NS_ERROR_FAILURE;
}
nsDependentCString leafstr(leafName);
nsCOMPtr<nsIFile> parentDir;
if (file) {
rv = file->GetParent(getter_AddRefs(parentDir));
if (NS_FAILED(rv))
return rv;
}
else {
rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(parentDir));
if (NS_FAILED(rv))
return rv;
rv = parentDir->Clone(getter_AddRefs(file));
if (NS_FAILED(rv))
return rv;
file->AppendNative(leafstr);
}
*aPersist = true;
NS_ADDREF(*aResult = file);
return NS_OK;
return NS_ERROR_FAILURE;
}
static void

Просмотреть файл

@ -12,10 +12,6 @@ SOURCES += [
'DirectoryProvider.cpp',
]
XPCSHELL_TESTS_MANIFESTS += [
'tests/unit/xpcshell.ini',
]
FINAL_LIBRARY = 'browsercomps'
LOCAL_INCLUDES += [

Просмотреть файл

@ -1,20 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var Cc = Components.classes;
var Ci = Components.interfaces;
var gProfD = do_get_profile();
var gDirSvc = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties);
var gPrefSvc = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
function writeTestFile(aParent, aName) {
let file = aParent.clone();
file.append(aName);
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0644);
return file;
}

Просмотреть файл

@ -1,14 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// We need to run this test separately since DirectoryProvider persists BMarks
function run_test() {
let dir = gProfD.clone();
let tfile = writeTestFile(dir, "bookmarkfile.test");
gPrefSvc.setCharPref("browser.bookmarks.file", tfile.path);
let bmarks = gDirSvc.get("BMarks", Ci.nsIFile);
do_check_true(tfile.equals(bmarks));
}

Просмотреть файл

@ -1,21 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
function test_bookmarkhtml() {
let bmarks = gProfD.clone();
bmarks.append("bookmarks.html");
let tbmarks = gDirSvc.get("BMarks", Ci.nsIFile);
do_check_true(bmarks.equals(tbmarks));
}
function run_test() {
[test_bookmarkhtml
].forEach(function(f) {
do_test_pending();
print("Running test: " + f.name);
f();
do_test_finished();
});
}

Просмотреть файл

@ -1,8 +0,0 @@
[DEFAULT]
head = head_dirprovider.js
tail =
firefox-appdir = browser
skip-if = toolkit == 'android' || toolkit == 'gonk'
[test_bookmark_pref.js]
[test_keys.js]

Просмотреть файл

@ -74,8 +74,6 @@
#define NS_APP_USER_MIMETYPES_50_FILE "UMimTyp"
#define NS_APP_CACHE_PARENT_DIR "cachePDir"
#define NS_APP_BOOKMARKS_50_FILE "BMarks"
#define NS_APP_DOWNLOADS_50_FILE "DLoads"
#define NS_APP_SEARCH_50_FILE "SrchF"