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