Bug 1524688: Part 11 - Convert search service to static registration. r=mikedeboer

--HG--
rename : toolkit/components/search/nsSearchService.js => toolkit/components/search/SearchService.jsm
rename : toolkit/components/search/nsSearchSuggestions.js => toolkit/components/search/SearchSuggestions.jsm
rename : toolkit/components/search/nsSidebar.js => toolkit/components/search/Sidebar.jsm
extra : rebase_source : 9b964bfe5accac5e43e612ac05a0cd4279ac27c4
This commit is contained in:
Kris Maglione 2019-01-29 20:00:19 -08:00
Родитель e1d1e7df2f
Коммит 4f28c00bb3
8 изменённых файлов: 44 добавлений и 67 удалений

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

@ -197,9 +197,6 @@
@RESPATH@/components/crashmonitor.manifest
@RESPATH@/components/nsCrashMonitor.js
@RESPATH@/components/toolkitsearch.manifest
@RESPATH@/components/nsSearchService.js
@RESPATH@/components/nsSearchSuggestions.js
@RESPATH@/components/nsSidebar.js
#ifdef NIGHTLY_BUILD
@RESPATH@/browser/components/payments.manifest
@RESPATH@/browser/components/paymentUIService.js

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

@ -123,8 +123,6 @@
@BINPATH@/components/nsDNSServiceDiscovery.js
#endif
@BINPATH@/components/toolkitsearch.manifest
@BINPATH@/components/nsSearchService.js
@BINPATH@/components/nsSidebar.js
@BINPATH@/components/TooltipTextProvider.js
@BINPATH@/components/TooltipTextProvider.manifest
@BINPATH@/components/NetworkGeolocationProvider.manifest

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

@ -8,15 +8,11 @@ const {PromiseUtils} = ChromeUtils.import("resource://gre/modules/PromiseUtils.j
const {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
XPCOMUtils.defineLazyModuleGetters(this, {
AsyncShutdown: "resource://gre/modules/AsyncShutdown.jsm",
DeferredTask: "resource://gre/modules/DeferredTask.jsm",
OS: "resource://gre/modules/osfile.jsm",
Deprecated: "resource://gre/modules/Deprecated.jsm",
SearchStaticData: "resource://gre/modules/SearchStaticData.jsm",
setTimeout: "resource://gre/modules/Timer.jsm",
clearTimeout: "resource://gre/modules/Timer.jsm",
Lz4: "resource://gre/modules/lz4.js",
NetUtil: "resource://gre/modules/NetUtil.jsm",
ExtensionParent: "resource://gre/modules/ExtensionParent.jsm",
});
@ -51,21 +47,12 @@ XPCOMUtils.defineLazyGetter(this, "gEncoder",
});
const MODE_RDONLY = 0x01;
const MODE_WRONLY = 0x02;
const MODE_CREATE = 0x08;
const MODE_APPEND = 0x10;
const MODE_TRUNCATE = 0x20;
const PERMS_FILE = 0o644;
// Directory service keys
const NS_APP_DISTRIBUTION_SEARCH_DIR_LIST = "SrchPluginsDistDL";
const NS_APP_USER_PROFILE_50_DIR = "ProfD";
// We load plugins from APP_SEARCH_PREFIX, where a list.json
// file needs to exist to list available engines.
const APP_SEARCH_PREFIX = "resource://search-plugins/";
const EXT_SEARCH_PREFIX = "resource://search-extensions/";
// See documentation in nsISearchService.idl.
const SEARCH_ENGINE_TOPIC = "browser-search-engine-modified";
@ -92,9 +79,6 @@ const SEARCH_SERVICE_TOPIC = "browser-search-service";
*/
const SEARCH_SERVICE_CACHE_WRITTEN = "write-cache-to-disk-complete";
// Delay for lazy serialization (ms)
const LAZY_SERIALIZE_DELAY = 100;
// Delay for batching invalidation of the JSON cache (ms)
const CACHE_INVALIDATION_DELAY = 1000;
@ -104,8 +88,6 @@ const CACHE_VERSION = 1;
const CACHE_FILENAME = "search.json.mozlz4";
const NEW_LINES = /(\r\n|\r|\n)/;
// Set an arbitrary cap on the maximum icon size. Without this, large icons can
// cause big delays when loading them at startup.
const MAX_ICON_SIZE = 20000;
@ -148,7 +130,6 @@ const MOZ_PARAM_OFFICIAL = "moz:official";
// Supported OpenSearch parameters
// See http://opensearch.a9.com/spec/1.1/querysyntax/#core
const OS_PARAM_USER_DEFINED = "searchTerms";
const OS_PARAM_INPUT_ENCODING = "inputEncoding";
const OS_PARAM_LANGUAGE = "language";
const OS_PARAM_OUTPUT_ENCODING = "outputEncoding";
@ -189,7 +170,6 @@ const SEARCH_DEFAULT_UPDATE_INTERVAL = 7;
// from the server doesn't specify an interval.
const SEARCH_GEO_DEFAULT_UPDATE_INTERVAL = 2592000; // 30 days.
const SEARCH_COUNTS_HISTOGRAM_KEY = "SEARCH_COUNTS";
/**
* Prefixed to all search debug output.
*/
@ -732,21 +712,6 @@ function getVerificationHash(aName) {
return hasher.finish(true);
}
/**
* Safely close a nsISafeOutputStream.
* @param aFOS
* The file output stream to close.
*/
function closeSafeOutputStream(aFOS) {
if (aFOS instanceof Ci.nsISafeOutputStream) {
try {
aFOS.finish();
return;
} catch (e) { }
}
aFOS.close();
}
/**
* Wrapper function for nsIIOService::newURI.
* @param aURLSpec
@ -868,11 +833,6 @@ function notifyAction(aEngine, aVerb) {
}
}
function parseJsonFromStream(aInputStream) {
let bytes = NetUtil.readInputStream(aInputStream, aInputStream.available());
return JSON.parse(new TextDecoder().decode(bytes));
}
/**
* Simple object representing a name/value pair.
*/
@ -4532,4 +4492,4 @@ var engineUpdateService = {
},
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([SearchService]);
var EXPORTED_SYMBOLS = ["SearchService"];

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

@ -2,7 +2,6 @@
* 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/. */
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
const {FormAutoCompleteResult} = ChromeUtils.import("resource://gre/modules/nsFormAutoCompleteResult.jsm");
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.defineModuleGetter(this, "SearchSuggestionController",
@ -179,5 +178,4 @@ SearchSuggestAutoComplete.prototype = {
serviceURL: "",
};
var component = [SearchSuggestAutoComplete];
this.NSGetFactory = XPCOMUtils.generateNSGetFactory(component);
var EXPORTED_SYMBOLS = ["SearchSuggestAutoComplete"];

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

@ -3,7 +3,6 @@
* 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/. */
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
function nsSidebar() {
@ -43,4 +42,4 @@ nsSidebar.prototype = {
QueryInterface: ChromeUtils.generateQI([Ci.nsIDOMGlobalPropertyInitializer]),
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([nsSidebar]);
var EXPORTED_SYMBOLS = ["nsSidebar"];

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

@ -0,0 +1,33 @@
# -*- 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/.
HAVE_SIDEBAR = buildconfig.substs['MOZ_BUILD_APP'] in ('browser', 'mobile/android', 'xulrunner')
Classes = [
{
'cid': '{7319788a-fe93-4db3-9f39-818cf08f4256}',
'contract_ids': ['@mozilla.org/browser/search-service;1'],
'jsm': 'resource://gre/modules/SearchService.jsm',
'constructor': 'SearchService',
'processes': ProcessSelector.MAIN_PROCESS_ONLY,
},
{
'cid': '{aa892eb4-ffbf-477d-9f9a-06c995ae9f27}',
'contract_ids': ['@mozilla.org/autocomplete/search;1?name=search-autocomplete'],
'jsm': 'resource://gre/modules/SearchSuggestions.jsm',
'constructor': 'SearchSuggestAutoComplete',
},
]
if HAVE_SIDEBAR:
Classes += [
{
'cid': '{22117140-9c6e-11d3-aaf1-00805f8a4905}',
'contract_ids': ['@mozilla.org/sidebar;1'],
'jsm': 'resource://gre/modules/Sidebar.jsm',
'constructor': 'nsSidebar',
},
]

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

@ -14,26 +14,26 @@ if CONFIG['MOZ_TOOLKIT_SEARCH']:
XPIDL_MODULE = 'toolkit_search'
EXTRA_COMPONENTS += [
'nsSearchService.js',
'nsSearchSuggestions.js',
]
if CONFIG['MOZ_BUILD_APP'] in ['browser', 'mobile/android', 'xulrunner']:
DEFINES['HAVE_SIDEBAR'] = True
EXTRA_COMPONENTS += [
'nsSidebar.js',
EXTRA_JS_MODULES += [
'Sidebar.jsm',
]
EXTRA_JS_MODULES += [
'SearchService.jsm',
'SearchStaticData.jsm',
'SearchSuggestionController.jsm',
'SearchSuggestions.jsm',
]
EXTRA_PP_COMPONENTS += [
EXTRA_COMPONENTS += [
'toolkitsearch.manifest',
]
EXTRA_JS_MODULES += [
'SearchStaticData.jsm',
XPCOM_MANIFESTS += [
'components.conf',
]
with Files('**'):

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

@ -1,10 +1,2 @@
component {7319788a-fe93-4db3-9f39-818cf08f4256} nsSearchService.js process=main
contract @mozilla.org/browser/search-service;1 {7319788a-fe93-4db3-9f39-818cf08f4256} process=main
# 21600 == 6 hours
category update-timer nsSearchService @mozilla.org/browser/search-service;1,getService,search-engine-update-timer,browser.search.update.interval,21600
component {aa892eb4-ffbf-477d-9f9a-06c995ae9f27} nsSearchSuggestions.js
contract @mozilla.org/autocomplete/search;1?name=search-autocomplete {aa892eb4-ffbf-477d-9f9a-06c995ae9f27}
#ifdef HAVE_SIDEBAR
component {22117140-9c6e-11d3-aaf1-00805f8a4905} nsSidebar.js
contract @mozilla.org/sidebar;1 {22117140-9c6e-11d3-aaf1-00805f8a4905}
#endif