|
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 |
|
6 #include "nsISupports.idl" |
|
7 |
|
8 interface nsIFile; |
|
9 interface nsILoginInfo; |
|
10 interface nsIPropertyBag; |
|
11 |
|
12 [scriptable, uuid(fe0a4e80-d36f-43cc-a37b-4e1906e77257)] |
|
13 |
|
14 /* |
|
15 * NOTE: This interface is intended to be implemented by modules |
|
16 * providing storage mechanisms for the login manager. |
|
17 * Other code should use the login manager's interfaces |
|
18 * (nsILoginManager), and should not call storage modules |
|
19 * directly. |
|
20 */ |
|
21 interface nsILoginManagerStorage : nsISupports { |
|
22 /** |
|
23 * Initialize the component. Not invoked automatically. |
|
24 */ |
|
25 void init(); |
|
26 |
|
27 |
|
28 /** |
|
29 * Initialize the component, but override the default filename |
|
30 * locations. This is primarily used to the unit tests and profile |
|
31 * migration. |
|
32 * |
|
33 * @param aFile |
|
34 * If non-null, file to use for login storage. |
|
35 * |
|
36 */ |
|
37 void initWithFile(in nsIFile aFile); |
|
38 |
|
39 |
|
40 /** |
|
41 * Store a new login in the storage module. |
|
42 * |
|
43 * @param aLogin |
|
44 * The login to be added. |
|
45 * |
|
46 * Default values for the login's nsILoginMetaInfo properties will be |
|
47 * created. However, if the caller specifies non-default values, they will |
|
48 * be used instead. |
|
49 */ |
|
50 void addLogin(in nsILoginInfo aLogin); |
|
51 |
|
52 |
|
53 /** |
|
54 * Remove a login from the storage module. |
|
55 * |
|
56 * @param aLogin |
|
57 * The login to be removed. |
|
58 * |
|
59 * The specified login must exactly match a stored login. However, the |
|
60 * values of any nsILoginMetaInfo properties are ignored. |
|
61 */ |
|
62 void removeLogin(in nsILoginInfo aLogin); |
|
63 |
|
64 |
|
65 /** |
|
66 * Modify an existing login in the storage module. |
|
67 * |
|
68 * @param oldLogin |
|
69 * The login to be modified. |
|
70 * @param newLoginData |
|
71 * The new login values (either a nsILoginInfo or nsIProperyBag) |
|
72 * |
|
73 * If newLoginData is a nsILoginInfo, all of the old login's nsILoginInfo |
|
74 * properties are changed to the values from newLoginData (but the old |
|
75 * login's nsILoginMetaInfo properties are unmodified). |
|
76 * |
|
77 * If newLoginData is a nsIPropertyBag, only the specified properties |
|
78 * will be changed. The nsILoginMetaInfo properties of oldLogin can be |
|
79 * changed in this manner. |
|
80 * |
|
81 * If the propertybag contains an item named "timesUsedIncrement", the |
|
82 * login's timesUsed property will be incremented by the item's value. |
|
83 */ |
|
84 void modifyLogin(in nsILoginInfo oldLogin, in nsISupports newLoginData); |
|
85 |
|
86 |
|
87 /** |
|
88 * Remove all stored logins. |
|
89 * |
|
90 * The browser sanitization feature allows the user to clear any stored |
|
91 * passwords. This interface allows that to be done without getting each |
|
92 * login first (which might require knowing the master password). |
|
93 * |
|
94 */ |
|
95 void removeAllLogins(); |
|
96 |
|
97 |
|
98 /** |
|
99 * Fetch all logins in the login manager. An array is always returned; |
|
100 * if there are no logins the array is empty. |
|
101 * |
|
102 * @param count |
|
103 * The number of elements in the array. JS callers can simply use |
|
104 * the array's .length property and omit this param. |
|
105 * @param logins |
|
106 * An array of nsILoginInfo objects. |
|
107 * |
|
108 * NOTE: This can be called from JS as: |
|
109 * var logins = pwmgr.getAllLogins(); |
|
110 * (|logins| is an array). |
|
111 */ |
|
112 void getAllLogins([optional] out unsigned long count, |
|
113 [retval, array, size_is(count)] out nsILoginInfo logins); |
|
114 |
|
115 |
|
116 /** |
|
117 * Fetch all logins in the login manager. An array is always returned; |
|
118 * if there are no logins the array is empty. This does not decrypt logins |
|
119 * before returning the array |
|
120 * |
|
121 * @param count |
|
122 * The number of elements in the array. JS callers can simply use |
|
123 * the array's .length property and omit this param. |
|
124 * @param logins |
|
125 * An array of nsILoginInfo objects. |
|
126 * |
|
127 * NOTE: This can be called from JS as: |
|
128 * var logins = pwmgr.getAllEncryptedLogins(); |
|
129 * (|logins| is an array). |
|
130 */ |
|
131 void getAllEncryptedLogins([optional] out unsigned long count, |
|
132 [retval, array, size_is(count)] out nsILoginInfo logins); |
|
133 |
|
134 |
|
135 /** |
|
136 * Search for logins in the login manager. An array is always returned; |
|
137 * if there are no logins the array is empty. |
|
138 * |
|
139 * @param count |
|
140 * The number of elements in the array. JS callers can simply use |
|
141 * the array's .length property, and supply an dummy object for |
|
142 * this out param. For example: |searchLogins({}, matchData)| |
|
143 * @param matchData |
|
144 * The data used to search. This does not follow the same |
|
145 * requirements as findLogins for those fields. Wildcard matches are |
|
146 * simply not specified. |
|
147 * @param logins |
|
148 * An array of nsILoginInfo objects. |
|
149 * |
|
150 * NOTE: This can be called from JS as: |
|
151 * var logins = pwmgr.searchLogins({}, matchData); |
|
152 * (|logins| is an array). |
|
153 */ |
|
154 void searchLogins(out unsigned long count, in nsIPropertyBag matchData, |
|
155 [retval, array, size_is(count)] out nsILoginInfo logins); |
|
156 |
|
157 |
|
158 /** |
|
159 * Obtain a list of all hosts for which password saving is disabled. |
|
160 * |
|
161 * @param count |
|
162 * The number of elements in the array. JS callers can simply use |
|
163 * the array's .length property and omit this param. |
|
164 * @param hostnames |
|
165 * An array of hostname strings, in origin URL format without a |
|
166 * pathname. For example: "https://www.site.com". |
|
167 * |
|
168 * NOTE: This can be called from JS as: |
|
169 * var logins = pwmgr.getAllDisabledHosts(); |
|
170 */ |
|
171 void getAllDisabledHosts([optional] out unsigned long count, |
|
172 [retval, array, size_is(count)] out wstring hostnames); |
|
173 |
|
174 |
|
175 /** |
|
176 * Check to see if saving logins has been disabled for a host. |
|
177 * |
|
178 * @param aHost |
|
179 * The hostname to check. This argument should be in the origin |
|
180 * URL format, without a pathname. For example: "http://foo.com". |
|
181 */ |
|
182 boolean getLoginSavingEnabled(in AString aHost); |
|
183 |
|
184 |
|
185 /** |
|
186 * Disable (or enable) storing logins for the specified host. When |
|
187 * disabled, the login manager will not prompt to store logins for |
|
188 * that host. Existing logins are not affected. |
|
189 * |
|
190 * @param aHost |
|
191 * The hostname to set. This argument should be in the origin |
|
192 * URL format, without a pathname. For example: "http://foo.com". |
|
193 * @param isEnabled |
|
194 * Specify if saving logins should be enabled (true) or |
|
195 * disabled (false) |
|
196 */ |
|
197 void setLoginSavingEnabled(in AString aHost, in boolean isEnabled); |
|
198 |
|
199 |
|
200 /** |
|
201 * Search for logins matching the specified criteria. Called when looking |
|
202 * for logins that might be applicable to a form or authentication request. |
|
203 * |
|
204 * @param count |
|
205 * The number of elements in the array. JS callers can simply use |
|
206 * the array's .length property, and supply an dummy object for |
|
207 * this out param. For example: |findLogins({}, hostname, ...)| |
|
208 * @param aHostname |
|
209 * The hostname to restrict searches to, in URL format. For |
|
210 * example: "http://www.site.com". |
|
211 * @param aActionURL |
|
212 * For form logins, this argument should be the URL to which the |
|
213 * form will be submitted. For protocol logins, specify null. |
|
214 * @param aHttpRealm |
|
215 * For protocol logins, this argument should be the HTTP Realm |
|
216 * for which the login applies. This is obtained from the |
|
217 * WWW-Authenticate header. See RFC2617. For form logins, |
|
218 * specify null. |
|
219 * @param logins |
|
220 * An array of nsILoginInfo objects. |
|
221 * |
|
222 * NOTE: This can be called from JS as: |
|
223 * var logins = pwmgr.findLogins({}, hostname, ...); |
|
224 * |
|
225 */ |
|
226 void findLogins(out unsigned long count, in AString aHostname, |
|
227 in AString aActionURL, in AString aHttpRealm, |
|
228 [retval, array, size_is(count)] out nsILoginInfo logins); |
|
229 |
|
230 |
|
231 /** |
|
232 * Search for logins matching the specified criteria, as with |
|
233 * findLogins(). This interface only returns the number of matching |
|
234 * logins (and not the logins themselves), which allows a caller to |
|
235 * check for logins without causing the user to be prompted for a master |
|
236 * password to decrypt the logins. |
|
237 * |
|
238 * @param aHostname |
|
239 * The hostname to restrict searches to. Specify an empty string |
|
240 * to match all hosts. A null value will not match any logins, and |
|
241 * will thus always return a count of 0. |
|
242 * @param aActionURL |
|
243 * The URL to which a form login will be submitted. To match any |
|
244 * form login, specify an empty string. To not match any form |
|
245 * login, specify null. |
|
246 * @param aHttpRealm |
|
247 * The HTTP Realm for which the login applies. To match logins for |
|
248 * any realm, specify an empty string. To not match logins for any |
|
249 * realm, specify null. |
|
250 */ |
|
251 unsigned long countLogins(in AString aHostname, in AString aActionURL, |
|
252 in AString aHttpRealm); |
|
253 /** |
|
254 * True when a master password prompt is being shown. |
|
255 */ |
|
256 readonly attribute boolean uiBusy; |
|
257 |
|
258 /** |
|
259 * True when the master password has already been entered, and so a caller |
|
260 * can ask for decrypted logins without triggering a prompt. |
|
261 */ |
|
262 readonly attribute boolean isLoggedIn; |
|
263 }; |