summaryrefslogtreecommitdiffstats
path: root/netwerk/base/nsIAuthPrompt.idl
blob: fbbac6ee9f4995051e1a631f7f100fc48e01eb0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"

interface nsIPrompt;

[scriptable, uuid(358089f9-ee4b-4711-82fd-bcd07fc62061)]
interface nsIAuthPrompt : nsISupports
{
    const uint32_t SAVE_PASSWORD_NEVER             = 0;
    const uint32_t SAVE_PASSWORD_FOR_SESSION       = 1;
    const uint32_t SAVE_PASSWORD_PERMANENTLY       = 2;

    /**
     * Puts up a text input dialog with OK and Cancel buttons.
     * Note: prompt uses separate args for the "in" and "out" values of the
     *       input field, whereas the other functions use a single inout arg.
     * @param  dialogText    The title for the dialog.
     * @param  text          The text to display in the dialog.
     * @param  passwordRealm The "realm" the password belongs to: e.g.
     *                       ldap://localhost/dc=test
     * @param  savePassword  One of the SAVE_PASSWORD_* options above.
     * @param  defaultText   The default text to display in the text input box.
     * @param  result        The value entered by the user if OK was
     *                       selected.
     * @return true for OK, false for Cancel
     */
    boolean prompt(in wstring dialogTitle,
                   in wstring text,
                   in wstring passwordRealm,
                   in uint32_t savePassword,
                   in wstring defaultText,
                   out wstring result);

    /**
     * Puts up a username/password dialog with OK and Cancel buttons.
     * @param  dialogText    The title for the dialog.
     * @param  text          The text to display in the dialog.
     * @param  passwordRealm The "realm" the password belongs to: e.g.
     *                       ldap://localhost/dc=test
     * @param  savePassword  One of the SAVE_PASSWORD_* options above.
     * @param  user          The username entered in the dialog.
     * @param  pwd           The password entered by the user if OK was
     *                       selected.
     * @return true for OK, false for Cancel
     */
    boolean promptUsernameAndPassword(in wstring dialogTitle,
                                      in wstring text,
                                      in wstring passwordRealm,
                                      in uint32_t savePassword,
                                      inout wstring user,
                                      inout wstring pwd);

    /**
     * Puts up an async username/password dialog with OK and Cancel buttons.
     * @param  dialogText    The title for the dialog.
     * @param  text          The text to display in the dialog.
     * @param  passwordRealm The "realm" the password belongs to: e.g.
     *                       ldap://localhost/dc=test
     * @param  savePassword  One of the SAVE_PASSWORD_* options above.
     * @param  user          The username entered in the dialog.
     * @param  pwd           The password entered by the user if OK was
     *                       selected.
     * @return promise resolving to true for OK, false for Cancel
     */
    Promise asyncPromptUsernameAndPassword(in wstring dialogTitle,
                                      in wstring text,
                                      in wstring passwordRealm,
                                      in uint32_t savePassword,
                                      inout wstring user,
                                      inout wstring pwd);

    /**
     * Puts up a password dialog with OK and Cancel buttons.
     * @param  dialogText    The title for the dialog.
     * @param  text          The text to display in the dialog.
     * @param  passwordRealm The "realm" the password belongs to: e.g.
     *                       ldap://localhost/dc=test. If a username is
     *                       specified (http://user@site.com) it will be used
     *                       when matching existing logins or saving new ones.
     *                       If no username is specified, only password-only
     *                       logins will be matched or saved.
     *                       Note: if a username is specified, the username
     *                       should be escaped.
     * @param  savePassword  One of the SAVE_PASSWORD_* options above.
     * @param  pwd           The password entered by the user if OK was
     *                       selected.
     * @return true for OK, false for Cancel
     */
    boolean promptPassword(in wstring dialogTitle,
                           in wstring text,
                           in wstring passwordRealm,
                           in uint32_t savePassword,
                           inout wstring pwd);

    /**
     * Puts up an async password dialog with OK and Cancel buttons.
     * @param  dialogText    The title for the dialog.
     * @param  text          The text to display in the dialog.
     * @param  passwordRealm The "realm" the password belongs to: e.g.
     *                       ldap://localhost/dc=test. If a username is
     *                       specified (http://user@site.com) it will be used
     *                       when matching existing logins or saving new ones.
     *                       If no username is specified, only password-only
     *                       logins will be matched or saved.
     *                       Note: if a username is specified, the username
     *                       should be escaped.
     * @param  savePassword  One of the SAVE_PASSWORD_* options above.
     * @param  pwd           The password entered by the user if OK was
     *                       selected.
     * @return promise resolving to true for OK, false for Cancel
     */
    Promise asyncPromptPassword(in wstring dialogTitle,
                           in wstring text,
                           in wstring passwordRealm,
                           in uint32_t savePassword,
                           inout wstring pwd);
};