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
* Remove all logins known to login manager.
83
*
84
* The browser sanitization feature allows the user to clear any stored
85
* passwords. This interface allows that to be done without getting each
86
* login first (which might require knowing the master password).
87
*/
88
void removeAllLogins();
89
90
/**
91
* Fetch all logins in the login manager. An array is always returned;
92
* if there are no logins the array is empty.
93
*
94
* @return An array of nsILoginInfo objects.
95
*/
96
Array<nsILoginInfo> getAllLogins();
97
98
/**
99
* Like getAllLogins, but asynchronous. This method is faster when large
100
* amounts of logins are present since it will handle decryption in one batch.
101
*
102
* @return A promise which resolves with a JS Array of nsILoginInfo objects.
103
*/
104
Promise getAllLoginsAsync();
105
106
/**
107
* Obtain a list of all origins for which password saving is disabled.
108
*
109
* @return An array of origin strings. For example: ["https://www.site.com"].
110
*/
111
Array<AString> getAllDisabledHosts();
112
113
/**
114
* Check to see if saving logins has been disabled for an origin.
115
*
116
* @param aHost
117
* The origin to check. For example: "http://foo.com".
118
*/
119
boolean getLoginSavingEnabled(in AString aHost);
120
121
/**
122
* Disable (or enable) storing logins for the specified origin. When
123
* disabled, the login manager will not prompt to store logins for
124
* that origin. Existing logins are not affected.
125
*
126
* @param aHost
127
* The origin to set. For example: "http://foo.com".
128
* @param isEnabled
129
* Specify if saving logins should be enabled (true) or
130
* disabled (false)
131
*/
132
void setLoginSavingEnabled(in AString aHost, in boolean isEnabled);
133
134
/**
135
* Search for logins matching the specified criteria. Called when looking
136
* for logins that might be applicable to a form or authentication request.
137
*
138
* @param aOrigin
139
* The origin to restrict searches to. For example: "http://www.site.com".
140
* To find logins for a given nsIURI, you would typically pass in
141
* its prePath (excluding userPass).
142
* @param aActionOrigin
143
* For form logins, this argument should be the origin to which the
144
* form will be submitted, not the whole URL.
145
* For HTTP auth. logins, specify null.
146
* An empty string ("") will match any value (except null).
147
* @param aHttpRealm
148
* For HTTP auth. logins, this argument should be the HTTP Realm
149
* for which the login applies. This is obtained from the
150
* WWW-Authenticate header. See RFC2617. For form logins,
151
* specify null.
152
* An empty string ("") will match any value (except null).
153
* @return An array of nsILoginInfo objects.
154
*/
155
Array<nsILoginInfo> findLogins(in AString aOrigin, in AString aActionOrigin,
156
in AString aHttpRealm);
157
158
/**
159
* Search for logins matching the specified criteria, as with
160
* findLogins(). This interface only returns the number of matching
161
* logins (and not the logins themselves), which allows a caller to
162
* check for logins without causing the user to be prompted for a master
163
* password to decrypt the logins.
164
*
165
* @param aOrigin
166
* The origin to restrict searches to. Specify an empty string
167
* to match all origins. A null value will not match any logins, and
168
* will thus always return a count of 0.
169
* @param aActionOrigin
170
* The origin to which a form login will be submitted. To match any
171
* form login, specify an empty string. To not match any form
172
* login, specify null.
173
* @param aHttpRealm
174
* The HTTP Realm for which the login applies. To match logins for
175
* any realm, specify an empty string. To not match logins for any
176
* realm, specify null.
177
*/
178
unsigned long countLogins(in AString aOrigin, in AString aActionOrigin,
179
in AString aHttpRealm);
180
181
/**
182
* Asynchonously search for logins in the login manager. The Promise always
183
* resolves to an array; if there are no logins the array is empty.
184
*
185
* @param {object} matchData
186
* The data used to search as a JS object. This does not follow the same
187
* requirements as findLogins for those fields. Wildcard matches are
188
* simply not specified.
189
* @return A promise resolving to an array of nsILoginInfo objects.
190
*/
191
Promise searchLoginsAsync(in jsval matchData);
192
193
/**
194
* Search for logins in the login manager. An array is always returned;
195
* if there are no logins the array is empty.
196
* @deprecated New code should use `searchLoginsAsync`.
197
* Only autocomplete, prompt, and test code still use this.
198
*
199
* @param matchData
200
* The data used to search. This does not follow the same
201
* requirements as findLogins for those fields. Wildcard matches are
202
* simply not specified.
203
* @return An array of nsILoginInfo objects.
204
*/
205
Array<nsILoginInfo> searchLogins(in nsIPropertyBag matchData);
206
207
/**
208
* True when a master password prompt is being displayed.
209
*/
210
readonly attribute boolean uiBusy;
211
212
/**
213
* True when the master password has already been entered, and so a caller
214
* can ask for decrypted logins without triggering a prompt.
215
*/
216
readonly attribute boolean isLoggedIn;
217
};
218
219
%{C++
220
221
#define NS_LOGINMANAGER_CONTRACTID "@mozilla.org/login-manager;1"
222
223
%}