1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/passwordmgr/nsILoginManager.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,255 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 + 1.9 +#include "nsISupports.idl" 1.10 + 1.11 +interface nsIURI; 1.12 +interface nsILoginInfo; 1.13 +interface nsIAutoCompleteResult; 1.14 +interface nsIDOMHTMLInputElement; 1.15 +interface nsIDOMHTMLFormElement; 1.16 +interface nsIPropertyBag; 1.17 + 1.18 +[scriptable, uuid(338c8597-1e32-4682-b5c7-cf8142c0bd1d)] 1.19 + 1.20 +interface nsILoginManager : nsISupports { 1.21 + 1.22 + /** 1.23 + * Store a new login in the login manager. 1.24 + * 1.25 + * @param aLogin 1.26 + * The login to be added. 1.27 + * 1.28 + * Default values for the login's nsILoginMetaInfo properties will be 1.29 + * created. However, if the caller specifies non-default values, they will 1.30 + * be used instead. 1.31 + */ 1.32 + void addLogin(in nsILoginInfo aLogin); 1.33 + 1.34 + 1.35 + /** 1.36 + * Remove a login from the login manager. 1.37 + * 1.38 + * @param aLogin 1.39 + * The login to be removed. 1.40 + * 1.41 + * The specified login must exactly match a stored login. However, the 1.42 + * values of any nsILoginMetaInfo properties are ignored. 1.43 + */ 1.44 + void removeLogin(in nsILoginInfo aLogin); 1.45 + 1.46 + 1.47 + /** 1.48 + * Modify an existing login in the login manager. 1.49 + * 1.50 + * @param oldLogin 1.51 + * The login to be modified. 1.52 + * @param newLoginData 1.53 + * The new login values (either a nsILoginInfo or nsIProperyBag) 1.54 + * 1.55 + * If newLoginData is a nsILoginInfo, all of the old login's nsILoginInfo 1.56 + * properties are changed to the values from newLoginData (but the old 1.57 + * login's nsILoginMetaInfo properties are unmodified). 1.58 + * 1.59 + * If newLoginData is a nsIPropertyBag, only the specified properties 1.60 + * will be changed. The nsILoginMetaInfo properties of oldLogin can be 1.61 + * changed in this manner. 1.62 + * 1.63 + * If the propertybag contains an item named "timesUsedIncrement", the 1.64 + * login's timesUsed property will be incremented by the item's value. 1.65 + */ 1.66 + void modifyLogin(in nsILoginInfo oldLogin, in nsISupports newLoginData); 1.67 + 1.68 + 1.69 + /** 1.70 + * Remove all logins known to login manager. 1.71 + * 1.72 + * The browser sanitization feature allows the user to clear any stored 1.73 + * passwords. This interface allows that to be done without getting each 1.74 + * login first (which might require knowing the master password). 1.75 + * 1.76 + */ 1.77 + void removeAllLogins(); 1.78 + 1.79 + 1.80 + /** 1.81 + * Fetch all logins in the login manager. An array is always returned; 1.82 + * if there are no logins the array is empty. 1.83 + * 1.84 + * @param count 1.85 + * The number of elements in the array. JS callers can simply use 1.86 + * the array's .length property and omit this param. 1.87 + * @param logins 1.88 + * An array of nsILoginInfo objects. 1.89 + * 1.90 + * NOTE: This can be called from JS as: 1.91 + * var logins = pwmgr.getAllLogins(); 1.92 + * (|logins| is an array). 1.93 + */ 1.94 + void getAllLogins([optional] out unsigned long count, 1.95 + [retval, array, size_is(count)] out nsILoginInfo logins); 1.96 + 1.97 + 1.98 + /** 1.99 + * Obtain a list of all hosts for which password saving is disabled. 1.100 + * 1.101 + * @param count 1.102 + * The number of elements in the array. JS callers can simply use 1.103 + * the array's .length property and omit this param. 1.104 + * @param hostnames 1.105 + * An array of hostname strings, in origin URL format without a 1.106 + * pathname. For example: "https://www.site.com". 1.107 + * 1.108 + * NOTE: This can be called from JS as: 1.109 + * var logins = pwmgr.getDisabledAllLogins(); 1.110 + */ 1.111 + void getAllDisabledHosts([optional] out unsigned long count, 1.112 + [retval, array, size_is(count)] out wstring hostnames); 1.113 + 1.114 + 1.115 + /** 1.116 + * Check to see if saving logins has been disabled for a host. 1.117 + * 1.118 + * @param aHost 1.119 + * The hostname to check. This argument should be in the origin 1.120 + * URL format, without a pathname. For example: "http://foo.com". 1.121 + */ 1.122 + boolean getLoginSavingEnabled(in AString aHost); 1.123 + 1.124 + 1.125 + /** 1.126 + * Disable (or enable) storing logins for the specified host. When 1.127 + * disabled, the login manager will not prompt to store logins for 1.128 + * that host. Existing logins are not affected. 1.129 + * 1.130 + * @param aHost 1.131 + * The hostname to set. This argument should be in the origin 1.132 + * URL format, without a pathname. For example: "http://foo.com". 1.133 + * @param isEnabled 1.134 + * Specify if saving logins should be enabled (true) or 1.135 + * disabled (false) 1.136 + */ 1.137 + void setLoginSavingEnabled(in AString aHost, in boolean isEnabled); 1.138 + 1.139 + 1.140 + /** 1.141 + * Search for logins matching the specified criteria. Called when looking 1.142 + * for logins that might be applicable to a form or authentication request. 1.143 + * 1.144 + * @param count 1.145 + * The number of elements in the array. JS callers can simply use 1.146 + * the array's .length property, and supply an dummy object for 1.147 + * this out param. For example: |findLogins({}, hostname, ...)| 1.148 + * @param aHostname 1.149 + * The hostname to restrict searches to, in URL format. For 1.150 + * example: "http://www.site.com". 1.151 + * To find logins for a given nsIURI, you would typically pass in 1.152 + * its prePath. 1.153 + * @param aActionURL 1.154 + * For form logins, this argument should be the URL to which the 1.155 + * form will be submitted. For protocol logins, specify null. 1.156 + * An empty string ("") will match any value (except null). 1.157 + * @param aHttpRealm 1.158 + * For protocol logins, this argument should be the HTTP Realm 1.159 + * for which the login applies. This is obtained from the 1.160 + * WWW-Authenticate header. See RFC2617. For form logins, 1.161 + * specify null. 1.162 + * An empty string ("") will match any value (except null). 1.163 + * @param logins 1.164 + * An array of nsILoginInfo objects. 1.165 + * 1.166 + * NOTE: This can be called from JS as: 1.167 + * var logins = pwmgr.findLogins({}, hostname, ...); 1.168 + * 1.169 + */ 1.170 + void findLogins(out unsigned long count, in AString aHostname, 1.171 + in AString aActionURL, in AString aHttpRealm, 1.172 + [retval, array, size_is(count)] out nsILoginInfo logins); 1.173 + 1.174 + 1.175 + /** 1.176 + * Search for logins matching the specified criteria, as with 1.177 + * findLogins(). This interface only returns the number of matching 1.178 + * logins (and not the logins themselves), which allows a caller to 1.179 + * check for logins without causing the user to be prompted for a master 1.180 + * password to decrypt the logins. 1.181 + * 1.182 + * @param aHostname 1.183 + * The hostname to restrict searches to. Specify an empty string 1.184 + * to match all hosts. A null value will not match any logins, and 1.185 + * will thus always return a count of 0. 1.186 + * @param aActionURL 1.187 + * The URL to which a form login will be submitted. To match any 1.188 + * form login, specify an empty string. To not match any form 1.189 + * login, specify null. 1.190 + * @param aHttpRealm 1.191 + * The HTTP Realm for which the login applies. To match logins for 1.192 + * any realm, specify an empty string. To not match logins for any 1.193 + * realm, specify null. 1.194 + */ 1.195 + unsigned long countLogins(in AString aHostname, in AString aActionURL, 1.196 + in AString aHttpRealm); 1.197 + 1.198 + 1.199 + /** 1.200 + * Generate results for a userfield autocomplete menu. 1.201 + * 1.202 + * NOTE: This interface is provided for use only by the FormFillController, 1.203 + * which calls it directly. This isn't really ideal, it should 1.204 + * probably be callback registered through the FFC. 1.205 + */ 1.206 + nsIAutoCompleteResult autoCompleteSearch(in AString aSearchString, 1.207 + in nsIAutoCompleteResult aPreviousResult, 1.208 + in nsIDOMHTMLInputElement aElement); 1.209 + 1.210 + /** 1.211 + * Fill a form with login information if we have it. This method will fill 1.212 + * aForm regardless of the signon.autofillForms preference. 1.213 + * 1.214 + * @param aForm 1.215 + * The form to fill 1.216 + * @return Success of attempt fill form 1.217 + */ 1.218 + boolean fillForm(in nsIDOMHTMLFormElement aForm); 1.219 + 1.220 + /** 1.221 + * Search for logins in the login manager. An array is always returned; 1.222 + * if there are no logins the array is empty. 1.223 + * 1.224 + * @param count 1.225 + * The number of elements in the array. JS callers can simply use 1.226 + * the array's .length property, and supply an dummy object for 1.227 + * this out param. For example: |searchLogins({}, matchData)| 1.228 + * @param matchData 1.229 + * The data used to search. This does not follow the same 1.230 + * requirements as findLogins for those fields. Wildcard matches are 1.231 + * simply not specified. 1.232 + * @param logins 1.233 + * An array of nsILoginInfo objects. 1.234 + * 1.235 + * NOTE: This can be called from JS as: 1.236 + * var logins = pwmgr.searchLogins({}, matchData); 1.237 + * (|logins| is an array). 1.238 + */ 1.239 + void searchLogins(out unsigned long count, in nsIPropertyBag matchData, 1.240 + [retval, array, size_is(count)] out nsILoginInfo logins); 1.241 + 1.242 + /** 1.243 + * True when a master password prompt is being displayed. 1.244 + */ 1.245 + readonly attribute boolean uiBusy; 1.246 + 1.247 + /** 1.248 + * True when the master password has already been entered, and so a caller 1.249 + * can ask for decrypted logins without triggering a prompt. 1.250 + */ 1.251 + readonly attribute boolean isLoggedIn; 1.252 +}; 1.253 + 1.254 +%{C++ 1.255 + 1.256 +#define NS_LOGINMANAGER_CONTRACTID "@mozilla.org/login-manager;1" 1.257 + 1.258 +%}