Dart Documentationchrome.managementChromeManagement

ChromeManagement class

class ChromeManagement extends ChromeApi {
 static final JsObject _management = chrome['management'];

 ChromeManagement._();

 bool get available => _management != null;

 /**
  * Returns a list of information about installed extensions and apps.
  */
 Future<List<ExtensionInfo>> getAll() {
   if (_management == null) _throwNotAvailable();

   var completer = new ChromeCompleter<List<ExtensionInfo>>.oneArg((e) => listify(e, _createExtensionInfo));
   _management.callMethod('getAll', [completer.callback]);
   return completer.future;
 }

 /**
  * Returns information about the installed extension, app, or theme that has
  * the given ID.
  * 
  * [id] The ID from an item of [ExtensionInfo.]
  */
 Future<ExtensionInfo> get(String id) {
   if (_management == null) _throwNotAvailable();

   var completer = new ChromeCompleter<ExtensionInfo>.oneArg(_createExtensionInfo);
   _management.callMethod('get', [id, completer.callback]);
   return completer.future;
 }

 /**
  * Returns a list of [permission warnings](permission_warnings.html) for the
  * given extension id.
  * 
  * [id] The ID of an already installed extension.
  */
 Future<List<String>> getPermissionWarningsById(String id) {
   if (_management == null) _throwNotAvailable();

   var completer = new ChromeCompleter<List<String>>.oneArg(listify);
   _management.callMethod('getPermissionWarningsById', [id, completer.callback]);
   return completer.future;
 }

 /**
  * Returns a list of [permission warnings](permission_warnings.html) for the
  * given extension manifest string. Note: This function can be used without
  * requesting the 'management' permission in the manifest.
  * 
  * [manifestStr] Extension manifest JSON string.
  */
 Future<List<String>> getPermissionWarningsByManifest(String manifestStr) {
   if (_management == null) _throwNotAvailable();

   var completer = new ChromeCompleter<List<String>>.oneArg(listify);
   _management.callMethod('getPermissionWarningsByManifest', [manifestStr, completer.callback]);
   return completer.future;
 }

 /**
  * Enables or disables an app or extension.
  * 
  * [id] This should be the id from an item of [ExtensionInfo.]
  * 
  * [enabled] Whether this item should be enabled or disabled.
  */
 Future setEnabled(String id, bool enabled) {
   if (_management == null) _throwNotAvailable();

   var completer = new ChromeCompleter.noArgs();
   _management.callMethod('setEnabled', [id, enabled, completer.callback]);
   return completer.future;
 }

 /**
  * Uninstalls a currently installed app or extension.
  * 
  * [id] This should be the id from an item of [ExtensionInfo.]
  */
 Future uninstall(String id, [ManagementUninstallParams options]) {
   if (_management == null) _throwNotAvailable();

   var completer = new ChromeCompleter.noArgs();
   _management.callMethod('uninstall', [id, jsify(options), completer.callback]);
   return completer.future;
 }

 /**
  * Uninstalls the calling extension. Note: This function can be used without
  * requesting the 'management' permission in the manifest.
  */
 Future uninstallSelf([ManagementUninstallSelfParams options]) {
   if (_management == null) _throwNotAvailable();

   var completer = new ChromeCompleter.noArgs();
   _management.callMethod('uninstallSelf', [jsify(options), completer.callback]);
   return completer.future;
 }

 /**
  * Launches an application.
  * 
  * [id] The extension id of the application.
  */
 Future launchApp(String id) {
   if (_management == null) _throwNotAvailable();

   var completer = new ChromeCompleter.noArgs();
   _management.callMethod('launchApp', [id, completer.callback]);
   return completer.future;
 }

 /**
  * Fired when an app or extension has been installed.
  */
 Stream<ExtensionInfo> get onInstalled => _onInstalled.stream;

 final ChromeStreamController<ExtensionInfo> _onInstalled =
     new ChromeStreamController<ExtensionInfo>.oneArg(_management, 'onInstalled', _createExtensionInfo);

 /**
  * Fired when an app or extension has been uninstalled.
  */
 Stream<String> get onUninstalled => _onUninstalled.stream;

 final ChromeStreamController<String> _onUninstalled =
     new ChromeStreamController<String>.oneArg(_management, 'onUninstalled', selfConverter);

 /**
  * Fired when an app or extension has been enabled.
  */
 Stream<ExtensionInfo> get onEnabled => _onEnabled.stream;

 final ChromeStreamController<ExtensionInfo> _onEnabled =
     new ChromeStreamController<ExtensionInfo>.oneArg(_management, 'onEnabled', _createExtensionInfo);

 /**
  * Fired when an app or extension has been disabled.
  */
 Stream<ExtensionInfo> get onDisabled => _onDisabled.stream;

 final ChromeStreamController<ExtensionInfo> _onDisabled =
     new ChromeStreamController<ExtensionInfo>.oneArg(_management, 'onDisabled', _createExtensionInfo);

 void _throwNotAvailable() {
   throw new UnsupportedError("'chrome.management' is not available");
 }
}

Extends

ChromeApi > ChromeManagement

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 => _management != null;

final Stream<ExtensionInfo> onDisabled #

Fired when an app or extension has been disabled.

Stream<ExtensionInfo> get onDisabled => _onDisabled.stream;

final Stream<ExtensionInfo> onEnabled #

Fired when an app or extension has been enabled.

Stream<ExtensionInfo> get onEnabled => _onEnabled.stream;

final Stream<ExtensionInfo> onInstalled #

Fired when an app or extension has been installed.

Stream<ExtensionInfo> get onInstalled => _onInstalled.stream;

final Stream<String> onUninstalled #

Fired when an app or extension has been uninstalled.

Stream<String> get onUninstalled => _onUninstalled.stream;

Methods

Future<ExtensionInfo> get(String id) #

Returns information about the installed extension, app, or theme that has the given ID.

id The ID from an item of ExtensionInfo.

Future<ExtensionInfo> get(String id) {
 if (_management == null) _throwNotAvailable();

 var completer = new ChromeCompleter<ExtensionInfo>.oneArg(_createExtensionInfo);
 _management.callMethod('get', [id, completer.callback]);
 return completer.future;
}

Future<List<ExtensionInfo>> getAll() #

Returns a list of information about installed extensions and apps.

Future<List<ExtensionInfo>> getAll() {
 if (_management == null) _throwNotAvailable();

 var completer = new ChromeCompleter<List<ExtensionInfo>>.oneArg((e) => listify(e, _createExtensionInfo));
 _management.callMethod('getAll', [completer.callback]);
 return completer.future;
}

Future<List<String>> getPermissionWarningsById(String id) #

Returns a list of permission warnings for the given extension id.

id The ID of an already installed extension.

Future<List<String>> getPermissionWarningsById(String id) {
 if (_management == null) _throwNotAvailable();

 var completer = new ChromeCompleter<List<String>>.oneArg(listify);
 _management.callMethod('getPermissionWarningsById', [id, completer.callback]);
 return completer.future;
}

Future<List<String>> getPermissionWarningsByManifest(String manifestStr) #

Returns a list of permission warnings for the given extension manifest string. Note: This function can be used without requesting the 'management' permission in the manifest.

manifestStr Extension manifest JSON string.

Future<List<String>> getPermissionWarningsByManifest(String manifestStr) {
 if (_management == null) _throwNotAvailable();

 var completer = new ChromeCompleter<List<String>>.oneArg(listify);
 _management.callMethod('getPermissionWarningsByManifest', [manifestStr, completer.callback]);
 return completer.future;
}

Future launchApp(String id) #

Launches an application.

id The extension id of the application.

Future launchApp(String id) {
 if (_management == null) _throwNotAvailable();

 var completer = new ChromeCompleter.noArgs();
 _management.callMethod('launchApp', [id, completer.callback]);
 return completer.future;
}

Future setEnabled(String id, bool enabled) #

Enables or disables an app or extension.

id This should be the id from an item of ExtensionInfo.

enabled Whether this item should be enabled or disabled.

Future setEnabled(String id, bool enabled) {
 if (_management == null) _throwNotAvailable();

 var completer = new ChromeCompleter.noArgs();
 _management.callMethod('setEnabled', [id, enabled, completer.callback]);
 return completer.future;
}

Future uninstall(String id, [ManagementUninstallParams options]) #

Uninstalls a currently installed app or extension.

id This should be the id from an item of ExtensionInfo.

Future uninstall(String id, [ManagementUninstallParams options]) {
 if (_management == null) _throwNotAvailable();

 var completer = new ChromeCompleter.noArgs();
 _management.callMethod('uninstall', [id, jsify(options), completer.callback]);
 return completer.future;
}

Future uninstallSelf([ManagementUninstallSelfParams options]) #

Uninstalls the calling extension. Note: This function can be used without requesting the 'management' permission in the manifest.

Future uninstallSelf([ManagementUninstallSelfParams options]) {
 if (_management == null) _throwNotAvailable();

 var completer = new ChromeCompleter.noArgs();
 _management.callMethod('uninstallSelf', [jsify(options), completer.callback]);
 return completer.future;
}