зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1619926 - Remove distribution search directory provider definitions. r=daleharvey
Also remove DirectoryProvider as it is now unused. Depends on D88018 Differential Revision: https://phabricator.services.mozilla.com/D88019
This commit is contained in:
Родитель
0a0f3485a5
Коммит
5a80757288
|
@ -4,15 +4,7 @@
|
|||
# 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/.
|
||||
|
||||
Classes = [
|
||||
{
|
||||
'cid': '{6deb193c-f87d-4078-bc78-5e64655b4d62}',
|
||||
'contract_ids': ['@mozilla.org/browser/directory-provider;1'],
|
||||
'type': 'mozilla::browser::DirectoryProvider',
|
||||
'headers': ['mozilla/browser/DirectoryProvider.h'],
|
||||
'categories': {'xpcom-directory-providers': 'browser-directory-provider'},
|
||||
},
|
||||
]
|
||||
Classes = []
|
||||
|
||||
TOOLKIT = buildconfig.substs['MOZ_WIDGET_TOOLKIT']
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ FINAL_LIBRARY = 'xul'
|
|||
|
||||
LOCAL_INCLUDES += [
|
||||
'../about',
|
||||
'../dirprovider',
|
||||
'../migration',
|
||||
'../sessionstore',
|
||||
'../shell',
|
||||
|
|
|
@ -39,11 +39,3 @@
|
|||
0xb1, 0x31, 0xd9, 0x3d, 0x7d, 0x70, 0x4f, 0x64 \
|
||||
} \
|
||||
}
|
||||
|
||||
// {6DEB193C-F87D-4078-BC78-5E64655B4D62}
|
||||
#define NS_BROWSERDIRECTORYPROVIDER_CID \
|
||||
{ \
|
||||
0x6deb193c, 0xf87d, 0x4078, { \
|
||||
0xbc, 0x78, 0x5e, 0x64, 0x65, 0x5b, 0x4d, 0x62 \
|
||||
} \
|
||||
}
|
||||
|
|
|
@ -1,168 +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/. */
|
||||
|
||||
#include "DirectoryProvider.h"
|
||||
|
||||
#include "nsIFile.h"
|
||||
#include "nsISimpleEnumerator.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
|
||||
#include "nsArrayEnumerator.h"
|
||||
#include "nsEnumeratorUtils.h"
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsCategoryManagerUtils.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsDirectoryServiceUtils.h"
|
||||
#include "mozilla/ModuleUtils.h"
|
||||
#include "mozilla/intl/LocaleService.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
|
||||
using mozilla::intl::LocaleService;
|
||||
|
||||
namespace mozilla {
|
||||
namespace browser {
|
||||
|
||||
NS_IMPL_ISUPPORTS(DirectoryProvider, nsIDirectoryServiceProvider,
|
||||
nsIDirectoryServiceProvider2)
|
||||
|
||||
NS_IMETHODIMP
|
||||
DirectoryProvider::GetFile(const char* aKey, bool* aPersist,
|
||||
nsIFile** aResult) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Appends the distribution-specific search engine directories to the
|
||||
// array. The directory structure is as follows:
|
||||
|
||||
// appdir/
|
||||
// \- distribution/
|
||||
// \- searchplugins/
|
||||
// |- common/
|
||||
// \- locale/
|
||||
// |- <locale 1>/
|
||||
// ...
|
||||
// \- <locale N>/
|
||||
|
||||
// common engines are loaded for all locales. If there is no locale
|
||||
// directory for the current locale, there is a pref:
|
||||
// "distribution.searchplugins.defaultLocale"
|
||||
// which specifies a default locale to use.
|
||||
|
||||
static void AppendDistroSearchDirs(nsIProperties* aDirSvc,
|
||||
nsCOMArray<nsIFile>& array) {
|
||||
nsCOMPtr<nsIFile> searchPlugins;
|
||||
nsresult rv = aDirSvc->Get(XRE_APP_DISTRIBUTION_DIR, NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(searchPlugins));
|
||||
if (NS_FAILED(rv)) return;
|
||||
searchPlugins->AppendNative("searchplugins"_ns);
|
||||
|
||||
nsCOMPtr<nsIFile> commonPlugins;
|
||||
rv = searchPlugins->Clone(getter_AddRefs(commonPlugins));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
commonPlugins->AppendNative("common"_ns);
|
||||
array.AppendObject(commonPlugins);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
if (prefs) {
|
||||
nsCOMPtr<nsIFile> localePlugins;
|
||||
rv = searchPlugins->Clone(getter_AddRefs(localePlugins));
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
localePlugins->AppendNative("locale"_ns);
|
||||
|
||||
nsAutoCString defLocale;
|
||||
rv = prefs->GetCharPref("distribution.searchplugins.defaultLocale",
|
||||
defLocale);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIFile> defLocalePlugins;
|
||||
rv = localePlugins->Clone(getter_AddRefs(defLocalePlugins));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
defLocalePlugins->AppendNative(defLocale);
|
||||
array.AppendObject(defLocalePlugins);
|
||||
return; // all done
|
||||
}
|
||||
}
|
||||
|
||||
// we didn't have a defaultLocale, use the user agent locale
|
||||
nsAutoCString locale;
|
||||
LocaleService::GetInstance()->GetAppLocaleAsBCP47(locale);
|
||||
|
||||
nsCOMPtr<nsIFile> curLocalePlugins;
|
||||
rv = localePlugins->Clone(getter_AddRefs(curLocalePlugins));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
curLocalePlugins->AppendNative(locale);
|
||||
array.AppendObject(curLocalePlugins);
|
||||
return; // all done
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DirectoryProvider::GetFiles(const char* aKey, nsISimpleEnumerator** aResult) {
|
||||
if (!strcmp(aKey, NS_APP_DISTRIBUTION_SEARCH_DIR_LIST)) {
|
||||
nsCOMPtr<nsIProperties> dirSvc(
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID));
|
||||
if (!dirSvc) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMArray<nsIFile> distroFiles;
|
||||
AppendDistroSearchDirs(dirSvc, distroFiles);
|
||||
|
||||
return NS_NewArrayEnumerator(aResult, distroFiles, NS_GET_IID(nsIFile));
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DirectoryProvider::AppendingEnumerator::HasMoreElements(bool* aResult) {
|
||||
*aResult = mNext ? true : false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DirectoryProvider::AppendingEnumerator::GetNext(nsISupports** aResult) {
|
||||
if (aResult) NS_ADDREF(*aResult = mNext);
|
||||
|
||||
mNext = nullptr;
|
||||
|
||||
// Ignore all errors
|
||||
|
||||
bool more;
|
||||
while (NS_SUCCEEDED(mBase->HasMoreElements(&more)) && more) {
|
||||
nsCOMPtr<nsISupports> nextbasesupp;
|
||||
mBase->GetNext(getter_AddRefs(nextbasesupp));
|
||||
|
||||
nsCOMPtr<nsIFile> nextbase(do_QueryInterface(nextbasesupp));
|
||||
if (!nextbase) continue;
|
||||
|
||||
nextbase->Clone(getter_AddRefs(mNext));
|
||||
if (!mNext) continue;
|
||||
|
||||
char const* const* i = mAppendList;
|
||||
while (*i) {
|
||||
mNext->AppendNative(nsDependentCString(*i));
|
||||
++i;
|
||||
}
|
||||
|
||||
mNext = nullptr;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
DirectoryProvider::AppendingEnumerator::AppendingEnumerator(
|
||||
nsISimpleEnumerator* aBase, char const* const* aAppendList)
|
||||
: mBase(aBase), mAppendList(aAppendList) {
|
||||
// Initialize mNext to begin.
|
||||
GetNext(nullptr);
|
||||
}
|
||||
|
||||
} // namespace browser
|
||||
} // namespace mozilla
|
|
@ -1,47 +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/. */
|
||||
|
||||
#ifndef DirectoryProvider_h__
|
||||
#define DirectoryProvider_h__
|
||||
|
||||
#include "nsIDirectoryService.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsSimpleEnumerator.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
||||
#define NS_BROWSERDIRECTORYPROVIDER_CONTRACTID \
|
||||
"@mozilla.org/browser/directory-provider;1"
|
||||
|
||||
namespace mozilla {
|
||||
namespace browser {
|
||||
|
||||
class DirectoryProvider final : public nsIDirectoryServiceProvider2 {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDIRECTORYSERVICEPROVIDER
|
||||
NS_DECL_NSIDIRECTORYSERVICEPROVIDER2
|
||||
|
||||
private:
|
||||
~DirectoryProvider() {}
|
||||
|
||||
class AppendingEnumerator final : public nsSimpleEnumerator {
|
||||
public:
|
||||
NS_DECL_NSISIMPLEENUMERATOR
|
||||
|
||||
AppendingEnumerator(nsISimpleEnumerator* aBase,
|
||||
char const* const* aAppendList);
|
||||
|
||||
private:
|
||||
~AppendingEnumerator() override = default;
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> mBase;
|
||||
char const* const* const mAppendList;
|
||||
nsCOMPtr<nsIFile> mNext;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace browser
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // DirectoryProvider_h__
|
|
@ -1,22 +0,0 @@
|
|||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# 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/.
|
||||
|
||||
with Files("**"):
|
||||
BUG_COMPONENT = ("Firefox", "General")
|
||||
|
||||
EXPORTS.mozilla.browser += [
|
||||
'DirectoryProvider.h',
|
||||
]
|
||||
|
||||
SOURCES += [
|
||||
'DirectoryProvider.cpp',
|
||||
]
|
||||
|
||||
FINAL_LIBRARY = 'browsercomps'
|
||||
|
||||
LOCAL_INCLUDES += [
|
||||
'../build'
|
||||
]
|
|
@ -33,7 +33,6 @@ DIRS += [
|
|||
'attribution',
|
||||
'contextualidentity',
|
||||
'customizableui',
|
||||
'dirprovider',
|
||||
'doh',
|
||||
'downloads',
|
||||
'enterprisepolicies',
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
<SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/">
|
||||
<ShortName>Google</ShortName>
|
||||
<Description>override-de-DE</Description>
|
||||
<InputEncoding>UTF-8</InputEncoding>
|
||||
<Url type="text/html" method="GET" template="http://searchtest.local">
|
||||
<Param name="search" value="{searchTerms}"/>
|
||||
</Url>
|
||||
</SearchPlugin>
|
|
@ -5,37 +5,12 @@
|
|||
* Tests that preferences are properly set by distribution.ini
|
||||
*/
|
||||
|
||||
// Import common head.
|
||||
var commonFile = do_get_file(
|
||||
"../../../../toolkit/components/places/tests/head_common.js",
|
||||
false
|
||||
);
|
||||
/* import-globals-from ../../../../toolkit/components/places/tests/head_common.js */
|
||||
if (commonFile) {
|
||||
let uri = Services.io.newFileURI(commonFile);
|
||||
Services.scriptloader.loadSubScript(uri.spec, this);
|
||||
}
|
||||
const { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm");
|
||||
|
||||
const { AddonTestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/AddonTestUtils.jsm"
|
||||
);
|
||||
const { PromiseTestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/PromiseTestUtils.jsm"
|
||||
);
|
||||
|
||||
AddonTestUtils.init(this);
|
||||
AddonTestUtils.createAppInfo(
|
||||
"xpcshell@tests.mozilla.org",
|
||||
"XPCShell",
|
||||
"42",
|
||||
"42"
|
||||
);
|
||||
|
||||
add_task(async function setup() {
|
||||
Services.prefs.setBoolPref("browser.search.modernConfig", false);
|
||||
await AddonTestUtils.promiseStartupManager();
|
||||
});
|
||||
|
||||
// This test causes BrowserGlue to start but not fully initialise, when the
|
||||
// AddonManager shuts down BrowserGlue will then try to uninit which will
|
||||
// cause AutoComplete.jsm to throw an error.
|
||||
|
@ -48,44 +23,6 @@ PromiseTestUtils.allowMatchingRejectionsGlobally(
|
|||
const TOPICDATA_DISTRIBUTION_CUSTOMIZATION = "force-distribution-customization";
|
||||
const TOPIC_BROWSERGLUE_TEST = "browser-glue-test";
|
||||
|
||||
/**
|
||||
* Copy the engine-distribution.xml engine to a fake distribution
|
||||
* created in the profile, and registered with the directory service.
|
||||
* Create an empty en-US directory to make sure it isn't used.
|
||||
*/
|
||||
function installDistributionEngine() {
|
||||
const XRE_APP_DISTRIBUTION_DIR = "XREAppDist";
|
||||
|
||||
let dir = gProfD.clone();
|
||||
dir.append("distribution");
|
||||
let distDir = dir.clone();
|
||||
|
||||
dir.append("searchplugins");
|
||||
dir.create(dir.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
|
||||
|
||||
dir.append("locale");
|
||||
dir.create(dir.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
|
||||
let localeDir = dir.clone();
|
||||
|
||||
dir.append("en-US");
|
||||
dir.create(dir.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
|
||||
|
||||
localeDir.append("de-DE");
|
||||
localeDir.create(dir.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
|
||||
|
||||
do_get_file("data/engine-de-DE.xml").copyTo(localeDir, "engine-de-DE.xml");
|
||||
|
||||
Services.dirsvc.registerProvider({
|
||||
getFile(aProp, aPersistent) {
|
||||
aPersistent.value = true;
|
||||
if (aProp == XRE_APP_DISTRIBUTION_DIR) {
|
||||
return distDir.clone();
|
||||
}
|
||||
return null;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
registerCleanupFunction(async function() {
|
||||
// Remove the distribution dir, even if the test failed, otherwise all
|
||||
// next tests will use it.
|
||||
|
@ -109,12 +46,10 @@ add_task(async function() {
|
|||
print("distribution.ini already exists, did some test forget to cleanup?");
|
||||
}
|
||||
|
||||
let testDistributionFile = gTestDir.clone();
|
||||
let testDistributionFile = do_get_cwd().clone();
|
||||
testDistributionFile.append("distribution.ini");
|
||||
testDistributionFile.copyTo(distroDir, "distribution.ini");
|
||||
Assert.ok(testDistributionFile.exists());
|
||||
|
||||
installDistributionEngine();
|
||||
});
|
||||
|
||||
add_task(async function() {
|
||||
|
@ -278,13 +213,4 @@ add_task(async function() {
|
|||
).data,
|
||||
"Language Set"
|
||||
);
|
||||
|
||||
Services.prefs.setCharPref(
|
||||
"distribution.searchplugins.defaultLocale",
|
||||
"de-DE"
|
||||
);
|
||||
|
||||
await Services.search.init();
|
||||
var engine = Services.search.getEngineByName("Google");
|
||||
Assert.equal(engine.description, "override-de-DE");
|
||||
});
|
||||
|
|
|
@ -4,7 +4,6 @@ firefox-appdir = browser
|
|||
skip-if = toolkit == 'android'
|
||||
support-files =
|
||||
distribution.ini
|
||||
data/engine-de-DE.xml
|
||||
|
||||
[test_distribution.js]
|
||||
[test_distribution_cachedexistence.js]
|
||||
|
|
|
@ -41,7 +41,6 @@
|
|||
|
||||
#define NS_APP_CHROME_DIR_LIST "AChromDL"
|
||||
#define NS_APP_PLUGINS_DIR_LIST "APluginsDL"
|
||||
#define NS_APP_DISTRIBUTION_SEARCH_DIR_LIST "SrchPluginsDistDL"
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Files and directories which exist on a per-profile basis
|
||||
|
|
|
@ -427,8 +427,5 @@ nsAppFileLocationProvider::GetFiles(const char* aProp,
|
|||
NS_ADDREF(*aResult);
|
||||
rv = NS_OK;
|
||||
}
|
||||
if (!strcmp(aProp, NS_APP_DISTRIBUTION_SEARCH_DIR_LIST)) {
|
||||
return NS_NewEmptyEnumerator(aResult);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче