Bug 1405670 - remove support for NS_APP_SEARCH_DIR_LIST and NS_APP_SEARCH_DIR from the directory service, r=adw.

This commit is contained in:
Florian Quèze 2017-11-17 12:05:20 +01:00
parent 97356e430c
commit b44b6a963a
5 changed files with 4 additions and 119 deletions

View File

@ -40,23 +40,6 @@ DirectoryProvider::GetFile(const char *aKey, bool *aPersist, nsIFile* *aResult)
return NS_ERROR_FAILURE;
}
static void
AppendFileKey(const char *key, nsIProperties* aDirSvc,
nsCOMArray<nsIFile> &array)
{
nsCOMPtr<nsIFile> file;
nsresult rv = aDirSvc->Get(key, NS_GET_IID(nsIFile), getter_AddRefs(file));
if (NS_FAILED(rv))
return;
bool exists;
rv = file->Exists(&exists);
if (NS_FAILED(rv) || !exists)
return;
array.AppendObject(file);
}
// Appends the distribution-specific search engine directories to the
// array. The directory structure is as follows:
@ -148,23 +131,6 @@ AppendDistroSearchDirs(nsIProperties* aDirSvc, nsCOMArray<nsIFile> &array)
NS_IMETHODIMP
DirectoryProvider::GetFiles(const char *aKey, nsISimpleEnumerator* *aResult)
{
/**
* We want to preserve the following order, since the search service loads
* engines in first-loaded-wins order.
* - distro search plugin locations (Loaded by the search service using
* NS_APP_DISTRIBUTION_SEARCH_DIR_LIST)
*
* - engines shipped in chrome (Loaded from jar files by the search
* service)
*
* Then other locations, from NS_APP_SEARCH_DIR_LIST:
* - extension search plugin locations (prepended below using
* NS_NewUnionEnumerator)
* - user search plugin locations (profile)
*/
nsresult rv;
if (!strcmp(aKey, NS_APP_DISTRIBUTION_SEARCH_DIR_LIST)) {
nsCOMPtr<nsIProperties> dirSvc
(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID));
@ -177,37 +143,6 @@ DirectoryProvider::GetFiles(const char *aKey, nsISimpleEnumerator* *aResult)
return NS_NewArrayEnumerator(aResult, distroFiles);
}
if (!strcmp(aKey, NS_APP_SEARCH_DIR_LIST)) {
nsCOMPtr<nsIProperties> dirSvc
(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID));
if (!dirSvc)
return NS_ERROR_FAILURE;
nsCOMArray<nsIFile> baseFiles;
AppendFileKey(NS_APP_USER_SEARCH_DIR, dirSvc, baseFiles);
nsCOMPtr<nsISimpleEnumerator> baseEnum;
rv = NS_NewArrayEnumerator(getter_AddRefs(baseEnum), baseFiles);
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsISimpleEnumerator> list;
rv = dirSvc->Get(XRE_EXTENSIONS_DIR_LIST,
NS_GET_IID(nsISimpleEnumerator), getter_AddRefs(list));
if (NS_FAILED(rv))
return rv;
static char const *const kAppendSPlugins[] = {"searchplugins", nullptr};
nsCOMPtr<nsISimpleEnumerator> extEnum =
new AppendingEnumerator(list, kAppendSPlugins);
if (!extEnum)
return NS_ERROR_OUT_OF_MEMORY;
return NS_NewUnionEnumerator(aResult, extEnum, baseEnum);
}
return NS_ERROR_FAILURE;
}

View File

@ -20,10 +20,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
// -----------------------------------------------------------------------
const NS_APP_CACHE_PARENT_DIR = "cachePDir";
const NS_APP_SEARCH_DIR = "SrchPlugns";
const NS_APP_SEARCH_DIR_LIST = "SrchPluginsDL";
const NS_APP_DISTRIBUTION_SEARCH_DIR_LIST = "SrchPluginsDistDL";
const NS_APP_USER_SEARCH_DIR = "UsrSrchPlugns";
const NS_XPCOM_CURRENT_PROCESS_DIR = "XCurProcD";
const XRE_APP_DISTRIBUTION_DIR = "XREAppDist";
const XRE_UPDATE_ROOT_DIR = "UpdRootD";
@ -141,31 +138,11 @@ DirectoryProvider.prototype = {
},
getFiles: function(prop) {
if (prop != NS_APP_SEARCH_DIR_LIST &&
prop != NS_APP_DISTRIBUTION_SEARCH_DIR_LIST)
if (prop != NS_APP_DISTRIBUTION_SEARCH_DIR_LIST)
return null;
let result = [];
if (prop == NS_APP_DISTRIBUTION_SEARCH_DIR_LIST) {
this._appendDistroSearchDirs(result);
} else {
/**
* We want to preserve the following order, since the search service
* loads engines in first-loaded-wins order.
* - distro search plugin locations (loaded separately by the search
* service)
* - user search plugin locations (profile)
* - app search plugin location (shipped engines)
*/
let appUserSearchDir = FileUtils.getDir(NS_APP_USER_SEARCH_DIR, [], false);
if (appUserSearchDir.exists())
result.push(appUserSearchDir);
let appSearchDir = FileUtils.getDir(NS_APP_SEARCH_DIR, [], false);
if (appSearchDir.exists())
result.push(appSearchDir);
}
this._appendDistroSearchDirs(result);
return {
QueryInterface: XPCOMUtils.generateQI([Ci.nsISimpleEnumerator]),

View File

@ -381,9 +381,7 @@ interface nsIBrowserSearchService : nsISupports
[optional] in AString extensionID);
/**
* Un-hides all engines installed in the directory corresponding to
* the directory service's NS_APP_SEARCH_DIR key. (i.e. the set of
* engines returned by getDefaultEngines)
* Un-hides all engines in the set of engines returned by getDefaultEngines.
*/
void restoreDefaultEngines();

View File

@ -38,11 +38,9 @@
#define NS_APP_RES_DIR "ARes"
#define NS_APP_CHROME_DIR "AChrom"
#define NS_APP_PLUGINS_DIR "APlugns" // Deprecated - use NS_APP_PLUGINS_DIR_LIST
#define NS_APP_SEARCH_DIR "SrchPlugns"
#define NS_APP_CHROME_DIR_LIST "AChromDL"
#define NS_APP_PLUGINS_DIR_LIST "APluginsDL"
#define NS_APP_SEARCH_DIR_LIST "SrchPluginsDL"
#define NS_APP_DISTRIBUTION_SEARCH_DIR_LIST "SrchPluginsDistDL"
// --------------------------------------------------------------------------------------
@ -72,8 +70,6 @@
#define NS_APP_USER_PANELS_50_FILE "UPnls"
#define NS_APP_CACHE_PARENT_DIR "cachePDir"
#define NS_APP_SEARCH_50_FILE "SrchF"
#define NS_APP_INSTALL_CLEANUP_DIR "XPIClnupD" //location of xpicleanup.dat xpicleanup.exe
#define NS_APP_INDEXEDDB_PARENT_DIR "indexedDBPDir"

View File

@ -58,7 +58,6 @@
#define RES_DIR_NAME NS_LITERAL_CSTRING("res")
#define CHROME_DIR_NAME NS_LITERAL_CSTRING("chrome")
#define PLUGINS_DIR_NAME NS_LITERAL_CSTRING("plugins")
#define SEARCH_DIR_NAME NS_LITERAL_CSTRING("searchplugins")
//*****************************************************************************
// nsAppFileLocationProvider::Constructor/Destructor
@ -194,17 +193,7 @@ nsAppFileLocationProvider::GetFile(const char* aProp, bool* aPersistent,
}
#endif
#endif
else if (nsCRT::strcmp(aProp, NS_APP_SEARCH_DIR) == 0) {
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv)) {
rv = localFile->AppendRelativeNativePath(SEARCH_DIR_NAME);
}
} else if (nsCRT::strcmp(aProp, NS_APP_USER_SEARCH_DIR) == 0) {
rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, aResult);
if (NS_SUCCEEDED(rv)) {
rv = (*aResult)->AppendNative(SEARCH_DIR_NAME);
}
} else if (nsCRT::strcmp(aProp, NS_APP_INSTALL_CLEANUP_DIR) == 0) {
else if (nsCRT::strcmp(aProp, NS_APP_INSTALL_CLEANUP_DIR) == 0) {
// This is cloned so that embeddors will have a hook to override
// with their own cleanup dir. See bugzilla bug #105087
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
@ -557,16 +546,6 @@ nsAppFileLocationProvider::GetFiles(const char* aProp,
NS_ADDREF(*aResult);
rv = NS_OK;
}
if (!nsCRT::strcmp(aProp, NS_APP_SEARCH_DIR_LIST)) {
static const char* keys[] = { nullptr, NS_APP_USER_SEARCH_DIR, nullptr };
if (!keys[0] && !(keys[0] = PR_GetEnv("MOZ_SEARCH_ENGINE_PATH"))) {
static const char nullstr = 0;
keys[0] = &nullstr;
}
*aResult = new nsPathsDirectoryEnumerator(this, keys);
NS_ADDREF(*aResult);
rv = NS_OK;
}
if (!strcmp(aProp, NS_APP_DISTRIBUTION_SEARCH_DIR_LIST)) {
return NS_NewEmptyEnumerator(aResult);
}