Backed out changeset 06f41c22f3a6 (bug 1888460) for causing linux xpcshell failures...
[gecko.git] / dom / webidl / AddonManager.webidl
blobfc942289541bef4e8e011bb4c56e942dde698b2e
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3  * You can obtain one at http://mozilla.org/MPL/2.0/.
4  */
6 /* We need a JSImplementation but cannot get one without a contract ID.
7    Since Addon and AddonInstall are only ever created from JS they don't need
8    real contract IDs. */
9 [ChromeOnly, JSImplementation="dummy",
10  Exposed=Window]
11 interface Addon {
12   // The add-on's ID.
13   readonly attribute DOMString id;
14   // The add-on's version.
15   readonly attribute DOMString version;
16   // The add-on's type (extension, theme, etc.).
17   readonly attribute DOMString type;
18   // The add-on's name in the current locale.
19   readonly attribute DOMString name;
20   // The add-on's description in the current locale.
21   readonly attribute DOMString description;
22   // If the user has enabled this add-on, note that it still may not be running
23   // depending on whether enabling requires a restart or if the add-on is
24   // incompatible in some way.
25   readonly attribute boolean isEnabled;
26   // If the add-on is currently active in the browser.
27   readonly attribute boolean isActive;
28   // If the add-on may be uninstalled
29   readonly attribute boolean canUninstall;
31   Promise<boolean> uninstall();
32   Promise<undefined> setEnabled(boolean value);
35 [ChromeOnly, JSImplementation="dummy",
36  Exposed=Window]
37 interface AddonInstall : EventTarget {
38   // One of the STATE_* symbols from AddonManager.sys.mjs
39   readonly attribute DOMString state;
40   // One of the ERROR_* symbols from AddonManager.sys.mjs, or null
41   readonly attribute DOMString? error;
42   // How many bytes have been downloaded
43   readonly attribute long long progress;
44   // How many total bytes will need to be downloaded or -1 if unknown
45   readonly attribute long long maxProgress;
47   Promise<undefined> install();
48   Promise<undefined> cancel();
51 dictionary addonInstallOptions {
52   required DOMString url;
53   // If a non-empty string is passed for "hash", it is used to verify the
54   // checksum of the downloaded XPI before installing.  If is omitted or if
55   // it is null or empty string, no checksum verification is performed.
56   DOMString? hash = null;
59 [HeaderFile="mozilla/AddonManagerWebAPI.h",
60  Func="mozilla::AddonManagerWebAPI::IsAPIEnabled",
61  JSImplementation="@mozilla.org/addon-web-api/manager;1",
62  WantsEventListenerHooks,
63  Exposed=Window]
64 interface AddonManager : EventTarget {
65   /**
66    * Gets information about an add-on
67    *
68    * @param  id
69    *         The ID of the add-on to test for.
70    * @return A promise. It will resolve to an Addon if the add-on is installed.
71    */
72   Promise<Addon> getAddonByID(DOMString id);
74   /**
75    * Creates an AddonInstall object for a given URL.
76    *
77    * @param options
78    *        Only one supported option: 'url', the URL of the addon to install.
79    * @return A promise that resolves to an instance of AddonInstall.
80    */
81   Promise<AddonInstall> createInstall(optional addonInstallOptions options = {});
83   /**
84    * Opens an Abuse Report dialog window for the addon with the given id.
85    * The addon may be currently installed (in which case the report will
86    * include the details available locally), or not (in which case the report
87    * will include the details that can be retrieved from the AMO API endpoint).
88    *
89    * @param  id
90    *         The ID of the add-on to report.
91    * @return A promise that resolves to a boolean (true when the report
92    *         has been submitted successfully, false if the user cancelled
93    *         the report). The Promise is rejected is the report fails
94    *         for a reason other than user cancellation.
95    */
96   Promise<boolean> reportAbuse(DOMString id);
98   // Indicator to content whether handing off the reports to the integrated
99   // abuse report panel is enabled.
100   readonly attribute boolean abuseReportPanelEnabled;
103 [ChromeOnly,Exposed=Window,HeaderFile="mozilla/AddonManagerWebAPI.h"]
104 namespace AddonManagerPermissions {
105   boolean isHostPermitted(DOMString host);