ChromeCommands class
class ChromeCommands extends ChromeApi { static final JsObject _commands = chrome['commands']; ChromeCommands._(); bool get available => _commands != null; /** * Returns all the registered extension commands for this extension and their * shortcut (if active). */ Future<List<Command>> getAll() { if (_commands == null) _throwNotAvailable(); var completer = new ChromeCompleter<List<Command>>.oneArg((e) => listify(e, _createCommand)); _commands.callMethod('getAll', [completer.callback]); return completer.future; } /** * Fired when a registered command is activated using a keyboard shortcut. */ Stream<String> get onCommand => _onCommand.stream; final ChromeStreamController<String> _onCommand = new ChromeStreamController<String>.oneArg(_commands, 'onCommand', selfConverter); void _throwNotAvailable() { throw new UnsupportedError("'chrome.commands' is not available"); } }
Extends
ChromeApi > ChromeCommands
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
docs inherited from ChromeApi
bool get available => _commands != null;
final Stream<String> onCommand #
Fired when a registered command is activated using a keyboard shortcut.
Stream<String> get onCommand => _onCommand.stream;
Methods
Future<List<Command>> getAll() #
Returns all the registered extension commands for this extension and their shortcut (if active).
Future<List<Command>> getAll() { if (_commands == null) _throwNotAvailable(); var completer = new ChromeCompleter<List<Command>>.oneArg((e) => listify(e, _createCommand)); _commands.callMethod('getAll', [completer.callback]); return completer.future; }