ChromeOmnibox class
class ChromeOmnibox extends ChromeApi { static final JsObject _omnibox = chrome['omnibox']; ChromeOmnibox._(); bool get available => _omnibox != null; /** * A callback passed to the onInputChanged event used for sending suggestions * back to the browser. * * [suggestResults] An array of suggest results */ void sendSuggestions(int requestId, List<SuggestResult> suggestResults) { if (_omnibox == null) _throwNotAvailable(); _omnibox.callMethod('sendSuggestions', [requestId, jsify(suggestResults)]); } /** * Sets the description and styling for the default suggestion. The default * suggestion is the text that is displayed in the first suggestion row * underneath the URL bar. * * [suggestion] A partial SuggestResult object, without the 'content' * parameter. */ void setDefaultSuggestion(DefaultSuggestResult suggestion) { if (_omnibox == null) _throwNotAvailable(); _omnibox.callMethod('setDefaultSuggestion', [jsify(suggestion)]); } /** * User has started a keyword input session by typing the extension's keyword. * This is guaranteed to be sent exactly once per input session, and before * any onInputChanged events. */ Stream get onInputStarted => _onInputStarted.stream; final ChromeStreamController _onInputStarted = new ChromeStreamController.noArgs(_omnibox, 'onInputStarted'); /** * User has changed what is typed into the omnibox. */ Stream<OnInputChangedEvent> get onInputChanged => _onInputChanged.stream; final ChromeStreamController<OnInputChangedEvent> _onInputChanged = new ChromeStreamController<OnInputChangedEvent>.twoArgs(_omnibox, 'onInputChanged', _createOnInputChangedEvent); /** * User has accepted what is typed into the omnibox. */ Stream<OnInputEnteredEvent> get onInputEntered => _onInputEntered.stream; final ChromeStreamController<OnInputEnteredEvent> _onInputEntered = new ChromeStreamController<OnInputEnteredEvent>.twoArgs(_omnibox, 'onInputEntered', _createOnInputEnteredEvent); /** * User has ended the keyword input session without accepting the input. */ Stream get onInputCancelled => _onInputCancelled.stream; final ChromeStreamController _onInputCancelled = new ChromeStreamController.noArgs(_omnibox, 'onInputCancelled'); void _throwNotAvailable() { throw new UnsupportedError("'chrome.omnibox' is not available"); } }
Extends
ChromeApi > ChromeOmnibox
Properties
final bool available #
Returns true if the API is available. The common causes of an API not being avilable are:
- a permission is missing in the application's manifest.json file
- the API is defined on a newer version of Chrome then the current runtime
bool get available => _omnibox != null;
final Stream onInputCancelled #
User has ended the keyword input session without accepting the input.
Stream get onInputCancelled => _onInputCancelled.stream;
final Stream<OnInputChangedEvent> onInputChanged #
User has changed what is typed into the omnibox.
Stream<OnInputChangedEvent> get onInputChanged => _onInputChanged.stream;
final Stream<OnInputEnteredEvent> onInputEntered #
User has accepted what is typed into the omnibox.
Stream<OnInputEnteredEvent> get onInputEntered => _onInputEntered.stream;
final Stream onInputStarted #
User has started a keyword input session by typing the extension's keyword. This is guaranteed to be sent exactly once per input session, and before any onInputChanged events.
Stream get onInputStarted => _onInputStarted.stream;
Methods
void sendSuggestions(int requestId, List<SuggestResult> suggestResults) #
A callback passed to the onInputChanged event used for sending suggestions back to the browser.
suggestResults An array of suggest results
void sendSuggestions(int requestId, List<SuggestResult> suggestResults) { if (_omnibox == null) _throwNotAvailable(); _omnibox.callMethod('sendSuggestions', [requestId, jsify(suggestResults)]); }
void setDefaultSuggestion(DefaultSuggestResult suggestion) #
Sets the description and styling for the default suggestion. The default suggestion is the text that is displayed in the first suggestion row underneath the URL bar.
suggestion A partial SuggestResult object, without the 'content' parameter.
void setDefaultSuggestion(DefaultSuggestResult suggestion) { if (_omnibox == null) _throwNotAvailable(); _omnibox.callMethod('setDefaultSuggestion', [jsify(suggestion)]); }