| // Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file |
| // for details. All rights reserved. Use of this source code is governed by a |
| // BSD-style license that can be found in the LICENSE file. |
| |
| import 'package:js/js.dart'; |
| |
| @JS() |
| external Chrome get chrome; |
| |
| @JS() |
| @anonymous |
| class Chrome { |
| external Action get action; |
| external Runtime get runtime; |
| } |
| |
| /// chrome.action APIs |
| /// https://developer.chrome.com/docs/extensions/reference/action |
| |
| @JS() |
| @anonymous |
| class Action { |
| external void setIcon(IconInfo iconInfo, Function? callback); |
| |
| external OnClickedHandler get onClicked; |
| } |
| |
| @JS() |
| @anonymous |
| class OnClickedHandler { |
| external void addListener(void Function(Tab tab) callback); |
| } |
| |
| @JS() |
| @anonymous |
| class IconInfo { |
| external String get path; |
| external factory IconInfo({String path}); |
| } |
| |
| /// chrome.runtime APIs: |
| /// https://developer.chrome.com/docs/extensions/reference/runtime |
| |
| @JS() |
| @anonymous |
| class Runtime { |
| external void sendMessage( |
| String? id, Object? message, Object? options, Function? callback); |
| |
| external OnMessageHandler get onMessage; |
| } |
| |
| @JS() |
| @anonymous |
| class OnMessageHandler { |
| external void addListener( |
| void Function(dynamic, MessageSender, Function) callback); |
| } |
| |
| @JS() |
| @anonymous |
| class MessageSender { |
| external String? get id; |
| external Tab? get tab; |
| external String? get url; |
| external factory MessageSender({String? id, String? url, Tab? tab}); |
| } |
| |
| @JS() |
| @anonymous |
| class Tab { |
| external int get id; |
| external String get url; |
| } |