Source code

Revision control

Other Tools

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
3
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5
#include "nsISupports.idl"
6
7
interface nsILoginInfo;
8
interface nsIPropertyBag;
9
10
[scriptable, uuid(38c7f6af-7df9-49c7-b558-2776b24e6cc1)]
11
interface nsILoginManager : nsISupports {
12
/**
13
* This promise is resolved when initialization is complete, and is rejected
14
* in case initialization failed. This includes the initial loading of the
15
* login data as well as any migration from previous versions.
16
*
17
* Calling any method of nsILoginManager before this promise is resolved
18
* might trigger the synchronous initialization fallback.
19
*/
20
readonly attribute Promise initializationPromise;
21
22
/**
23
* Store a new login in the login manager.
24
*
25
* @param aLogin
26
* The login to be added.
27
* @return a clone of the login info with the guid set (even if it was not provided)
28
*
29
* Default values for the login's nsILoginMetaInfo properties will be
30
* created. However, if the caller specifies non-default values, they will
31
* be used instead.
32
*/
33
nsILoginInfo addLogin(in nsILoginInfo aLogin);
34
35
/**
36
* Like addLogin, but asynchronous and for many logins.
37
*
38
* @param aLogins
39
* A JS Array of nsILoginInfos to add.
40
* @return A promise which resolves with a JS Array of cloned logins with
41
* the guids set.
42
*
43
* Default values for each login's nsILoginMetaInfo properties will be
44
* created. However, if the caller specifies non-default values, they will
45
* be used instead.
46
*/
47
Promise addLogins(in jsval aLogins);
48
49
/**
50
* Remove a login from the login manager.
51
*
52
* @param aLogin
53
* The login to be removed.
54
*
55
* The specified login must exactly match a stored login. However, the
56
* values of any nsILoginMetaInfo properties are ignored.
57
*/
58
void removeLogin(in nsILoginInfo aLogin);
59
60
/**
61
* Modify an existing login in the login manager.
62
*
63
* @param oldLogin
64
* The login to be modified.
65
* @param newLoginData
66
* The new login values (either a nsILoginInfo or nsIProperyBag)
67
*
68
* If newLoginData is a nsILoginInfo, all of the old login's nsILoginInfo
69
* properties are changed to the values from newLoginData (but the old
70
* login's nsILoginMetaInfo properties are unmodified).
71
*
72
* If newLoginData is a nsIPropertyBag, only the specified properties
73
* will be changed. The nsILoginMetaInfo properties of oldLogin can be
74
* changed in this manner.
75
*
76
* If the propertybag contains an item named "timesUsedIncrement", the
77
* login's timesUsed property will be incremented by the item's value.
78
*/
79
void modifyLogin(in nsILoginInfo oldLogin, in nsISupports newLoginData);
80
81
/**
82
* Record that the password of a saved login was used (e.g. submitted or copied).
83
*
84
* @param nsILoginInfo aLogin
85
* The login record of the password that was used.
86
*
87
* If only the username was used, this method shouldn't be called as we don't
88
* want to double-count the use if both the username and password are copied.
89
* Copying of the username normally precedes the copying of the password anyways.
90
*/
91
void recordPasswordUse(in nsILoginInfo aLogin);
92
93
/**
94
* Remove all logins known to login manager.
95
*
96
* The browser sanitization feature allows the user to clear any stored
97
* passwords. This interface allows that to be done without getting each
98
* login first (which might require knowing the master password).
99
*/
100
void removeAllLogins();
101
102
/**
103
* Fetch all logins in the login manager. An array is always returned;
104
* if there are no logins the array is empty.
105
*
106
* @return An array of nsILoginInfo objects.
107
*/
108
Array<nsILoginInfo> getAllLogins();
109
110
/**
111
* Like getAllLogins, but asynchronous. This method is faster when large
112
* amounts of logins are present since it will handle decryption in one batch.
113
*
114
* @return A promise which resolves with a JS Array of nsILoginInfo objects.
115
*/
116
Promise getAllLoginsAsync();
117
118
/**
119
* Obtain a list of all origins for which password saving is disabled.
120
*
121
* @return An array of origin strings. For example: ["https://www.site.com"].
122
*/
123
Array<AString> getAllDisabledHosts();
124
125
/**
126
* Check to see if saving logins has been disabled for an origin.
127
*
128
* @param aHost
129
* The origin to check. For example: "http://foo.com".
130
*/
131
boolean getLoginSavingEnabled(in AString aHost);
132
133
/**
134
* Disable (or enable) storing logins for the specified origin. When
135
* disabled, the login manager will not prompt to store logins for
136
* that origin. Existing logins are not affected.
137
*
138
* @param aHost
139
* The origin to set. For example: "http://foo.com".
140
* @param isEnabled
141
* Specify if saving logins should be enabled (true) or
142
* disabled (false)
143
*/
144
void setLoginSavingEnabled(in AString aHost, in boolean isEnabled);
145
146
/**
147
* Search for logins matching the specified criteria. Called when looking
148
* for logins that might be applicable to a form or authentication request.
149
*
150
* @param aOrigin
151
* The origin to restrict searches to. For example: "http://www.site.com".
152
* To find logins for a given nsIURI, you would typically pass in
153
* its prePath (excluding userPass).
154
* @param aActionOrigin
155
* For form logins, this argument should be the origin to which the
156
* form will be submitted, not the whole URL.
157
* For HTTP auth. logins, specify null.
158
* An empty string ("") will match any value (except null).
159
* @param aHttpRealm
160
* For HTTP auth. logins, this argument should be the HTTP Realm
161
* for which the login applies. This is obtained from the
162
* WWW-Authenticate header. See RFC2617. For form logins,
163
* specify null.
164
* An empty string ("") will match any value (except null).
165
* @return An array of nsILoginInfo objects.
166
*/
167
Array<nsILoginInfo> findLogins(in AString aOrigin, in AString aActionOrigin,
168
in AString aHttpRealm);
169
170
/**
171
* Search for logins matching the specified criteria, as with
172
* findLogins(). This interface only returns the number of matching
173
* logins (and not the logins themselves), which allows a caller to
174
* check for logins without causing the user to be prompted for a master
175
* password to decrypt the logins.
176
*
177
* @param aOrigin
178
* The origin to restrict searches to. Specify an empty string
179
* to match all origins. A null value will not match any logins, and
180
* will thus always return a count of 0.
181
* @param aActionOrigin
182
* The origin to which a form login will be submitted. To match any
183
* form login, specify an empty string. To not match any form
184
* login, specify null.
185
* @param aHttpRealm
186
* The HTTP Realm for which the login applies. To match logins for
187
* any realm, specify an empty string. To not match logins for any
188
* realm, specify null.
189
*/
190
unsigned long countLogins(in AString aOrigin, in AString aActionOrigin,
191
in AString aHttpRealm);
192
193
/**
194
* Asynchonously search for logins in the login manager. The Promise always
195
* resolves to an array; if there are no logins the array is empty.
196
*
197
* @param {object} matchData
198
* The data used to search as a JS object. This does not follow the same
199
* requirements as findLogins for those fields. Wildcard matches are
200
* simply not specified.
201
* @return A promise resolving to an array of nsILoginInfo objects.
202
*/
203
Promise searchLoginsAsync(in jsval matchData);
204
205
/**
206
* Search for logins in the login manager. An array is always returned;
207
* if there are no logins the array is empty.
208
* @deprecated New code should use `searchLoginsAsync`.
209
* Only autocomplete, prompt, and test code still use this.
210
*
211
* @param matchData
212
* The data used to search. This does not follow the same
213
* requirements as findLogins for those fields. Wildcard matches are
214
* simply not specified.
215
* @return An array of nsILoginInfo objects.
216
*/
217
Array<nsILoginInfo> searchLogins(in nsIPropertyBag matchData);
218
219
/**
220
* True when a master password prompt is being displayed.
221
*/
222
readonly attribute boolean uiBusy;
223
224
/**
225
* True when the master password has already been entered, and so a caller
226
* can ask for decrypted logins without triggering a prompt.
227
*/
228
readonly attribute boolean isLoggedIn;
229
};
230
231
%{C++
232
233
#define NS_LOGINMANAGER_CONTRACTID "@mozilla.org/login-manager;1"
234
235
%}