ext-omnibox.js (1321B)
1 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 /* vim: set sts=2 sw=2 et tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 "use strict"; 8 9 this.omnibox = class extends ExtensionAPI { 10 getAPI(context) { 11 return { 12 omnibox: { 13 onInputChanged: new EventManager({ 14 context, 15 name: "omnibox.onInputChanged", 16 // Parent event already resets idle if needed, no need to do it here. 17 resetIdleOnEvent: false, 18 register: fire => { 19 let listener = (text, id) => { 20 fire.asyncWithoutClone(text, suggestions => { 21 context.childManager.callParentFunctionNoReturn( 22 "omnibox.addSuggestions", 23 [id, suggestions] 24 ); 25 }); 26 }; 27 context.childManager 28 .getParentEvent("omnibox.onInputChanged") 29 .addListener(listener); 30 return () => { 31 context.childManager 32 .getParentEvent("omnibox.onInputChanged") 33 .removeListener(listener); 34 }; 35 }, 36 }).api(), 37 }, 38 }; 39 } 40 };