File: AddonManager.webidl

package info (click to toggle)
firefox 143.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,617,328 kB
  • sloc: cpp: 7,478,492; javascript: 6,417,157; ansic: 3,720,058; python: 1,396,372; xml: 627,523; asm: 438,677; java: 186,156; sh: 63,477; makefile: 19,171; objc: 13,059; perl: 12,983; yacc: 4,583; cs: 3,846; pascal: 3,405; lex: 1,720; ruby: 1,003; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 53; csh: 10
file content (116 lines) | stat: -rw-r--r-- 4,207 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/.
 */

/* We need a JSImplementation but cannot get one without a contract ID.
   Since Addon and AddonInstall are only ever created from JS they don't need
   real contract IDs. */
[ChromeOnly, JSImplementation="dummy",
 Exposed=Window]
interface Addon {
  // The add-on's ID.
  readonly attribute DOMString id;
  // The add-on's version.
  readonly attribute DOMString version;
  // The add-on's type (extension, theme, etc.).
  readonly attribute DOMString type;
  // The add-on's name in the current locale.
  readonly attribute DOMString name;
  // The add-on's description in the current locale.
  readonly attribute DOMString description;
  // If the user has enabled this add-on, note that it still may not be running
  // depending on whether enabling requires a restart or if the add-on is
  // incompatible in some way.
  readonly attribute boolean isEnabled;
  // If the add-on is currently active in the browser.
  readonly attribute boolean isActive;
  // If the add-on may be uninstalled
  readonly attribute boolean canUninstall;

  Promise<boolean> uninstall();
  Promise<undefined> setEnabled(boolean value);
};

[ChromeOnly, JSImplementation="dummy",
 Exposed=Window]
interface AddonInstall : EventTarget {
  // One of the STATE_* symbols from AddonManager.sys.mjs
  readonly attribute DOMString state;
  // One of the ERROR_* symbols from AddonManager.sys.mjs, or null
  readonly attribute DOMString? error;
  // How many bytes have been downloaded
  readonly attribute long long progress;
  // How many total bytes will need to be downloaded or -1 if unknown
  readonly attribute long long maxProgress;

  Promise<undefined> install();
  Promise<undefined> cancel();
};

dictionary addonInstallOptions {
  required DOMString url;
  // If a non-empty string is passed for "hash", it is used to verify the
  // checksum of the downloaded XPI before installing.  If is omitted or if
  // it is null or empty string, no checksum verification is performed.
  DOMString? hash = null;
};

dictionary sendAbuseReportOptions {
  // This should be an Authorization HTTP header value.
  DOMString? authorization = null;
};

[HeaderFile="mozilla/AddonManagerWebAPI.h",
 Func="mozilla::AddonManagerWebAPI::IsAPIEnabled",
 JSImplementation="@mozilla.org/addon-web-api/manager;1",
 WantsEventListenerHooks,
 Exposed=Window]
interface AddonManager : EventTarget {
  /**
   * Gets information about an add-on
   *
   * @param  id
   *         The ID of the add-on to test for.
   * @return A promise. It will resolve to an Addon if the add-on is installed.
   */
  Promise<Addon> getAddonByID(DOMString id);

  /**
   * Creates an AddonInstall object for a given URL.
   *
   * @param options
   *        Only one supported option: 'url', the URL of the addon to install.
   * @return A promise that resolves to an instance of AddonInstall.
   */
  Promise<AddonInstall> createInstall(optional addonInstallOptions options = {});

  /**
   * Sends an abuse report to the AMO API.
   *
   * NOTE: The type for `data` and for the return value are loose because both
   * the AMO API might change its response and the caller (AMO frontend) might
   * also want to pass slightly different data in the future.
   *
   * @param addonId
   *        The ID of the add-on to report.
   * @param data
   *        The caller passes the data to be sent to the AMO API.
   * @param options
   *        Optional - A set of options. It currently only supports
   *        `authorization`, which is expected to be the value of an
   *        Authorization HTTP header when provided.
   * @return A promise that resolves to the AMO API response, or an error when
   *         something went wrong.
   */
  [NewObject] Promise<any> sendAbuseReport(
    DOMString addonId,
    record<DOMString, DOMString?> data,
    optional sendAbuseReportOptions options = {}
  );
};

[ChromeOnly,Exposed=Window,HeaderFile="mozilla/AddonManagerWebAPI.h"]
namespace AddonManagerPermissions {
  boolean isHostPermitted(DOMString host);
};