Bug 1526211 - Port bug 1492475: Switch to new search engine async API. r=jorgk
--HG-- extra : rebase_source : eae0369fa40c8a56d2c440f6f1b195f9090db241
This commit is contained in:
Родитель
4772b60f39
Коммит
7e94a7986d
|
@ -196,12 +196,11 @@ function openWhatsNew() {
|
|||
* @param engine (optional) the search engine to use
|
||||
*/
|
||||
function openWebSearch(query, engine) {
|
||||
Services.search.init({
|
||||
onInitComplete() {
|
||||
if (!engine)
|
||||
engine = Services.search.defaultEngine;
|
||||
Services.search.init().then(async () => {
|
||||
if (!engine) {
|
||||
engine = await Services.search.getDefault();
|
||||
openLinkExternally(engine.getSubmission(query).uri.spec);
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -176,25 +176,24 @@ var gGeneralPane = {
|
|||
},
|
||||
|
||||
updateWebSearch() {
|
||||
Services.search.init({
|
||||
onInitComplete() {
|
||||
let engineList = document.getElementById("defaultWebSearch");
|
||||
for (let engine of Services.search.getVisibleEngines()) {
|
||||
let item = engineList.appendItem(engine.name);
|
||||
item.engine = engine;
|
||||
item.className = "menuitem-iconic";
|
||||
item.setAttribute(
|
||||
"image", engine.iconURI ? engine.iconURI.spec :
|
||||
"resource://gre-resources/broken-image.png"
|
||||
);
|
||||
if (engine == Services.search.defaultEngine)
|
||||
engineList.selectedItem = item;
|
||||
Services.search.init().then(async () => {
|
||||
let defaultEngine = await Services.search.getDefault();
|
||||
let engineList = document.getElementById("defaultWebSearch");
|
||||
for (let engine of await Services.search.getVisibleEngines()) {
|
||||
let item = engineList.appendItem(engine.name);
|
||||
item.engine = engine;
|
||||
item.className = "menuitem-iconic";
|
||||
item.setAttribute("image", engine.iconURI ? engine.iconURI.spec :
|
||||
"resource://gre-resources/broken-image.png"
|
||||
);
|
||||
if (engine == defaultEngine) {
|
||||
engineList.selectedItem = item;
|
||||
}
|
||||
}
|
||||
|
||||
engineList.addEventListener("command", function() {
|
||||
Services.search.defaultEngine = engineList.selectedItem.engine;
|
||||
});
|
||||
},
|
||||
engineList.addEventListener("command", () => {
|
||||
Services.search.setDefault(engineList.selectedItem.engine);
|
||||
});
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче