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
7interface nsIAutoCompletePopup;
8
9webidl Document;
10webidl Element;
11webidl Event;
12webidl HTMLInputElement;
13
14/*
15 * nsIFormFillController is an interface for controlling form fill behavior
16 * on HTML documents.  Any number of docShells can be controller concurrently.
17 * While a docShell is attached, all HTML documents that are loaded within it
18 * will have a focus listener attached that will listen for when a text input
19 * is focused.  When this happens, the input will be bound to the
20 * global nsIAutoCompleteController service.
21 */
22
23[scriptable, uuid(07f0a0dc-f6e9-4cdd-a55f-56d770523a4c)]
24interface nsIFormFillController : nsISupports
25{
26  /*
27   * The input element the form fill controller is currently bound to.
28   */
29  readonly attribute HTMLInputElement focusedInput;
30
31  /*
32   * Whether the autocomplete popup on a password field was automatically opened
33   * by the form fill controller (upon focus).
34   */
35  readonly attribute boolean passwordPopupAutomaticallyOpened;
36
37  /*
38   * Start controlling form fill behavior for the given document
39   *
40   * @param document - The document to attach to
41   * @param popup - The popup to show when autocomplete results are available
42   */
43  [can_run_script]
44  void attachToDocument(in Document document, in nsIAutoCompletePopup popup);
45  [can_run_script]
46  void attachPopupElementToDocument(in Document document, in Element popup);
47
48  /*
49   * Stop controlling form fill behavior for the given browser
50   *
51   * @param document - The document to detach from
52   */
53  [can_run_script] void detachFromDocument(in Document document);
54
55  /*
56   * Mark the specified <input> element as being managed by password manager.
57   * Autocomplete requests will be handed off to the password manager, and will
58   * not be stored in form history.
59   *
60   * @param aInput - The HTML <input> element to tag
61   */
62  [can_run_script] void markAsLoginManagerField(in HTMLInputElement aInput);
63
64  /*
65   * Mark the specified <input> element as being managed by a form autofill component.
66   * Autocomplete requests will be handed off to the autofill component.
67   *
68   * @param aInput - The HTML <input> element to mark
69   */
70  [can_run_script] void markAsAutofillField(in HTMLInputElement aInput);
71
72  /*
73   * Open the autocomplete popup, if possible.
74   */
75  [can_run_script] void showPopup();
76
77  [can_run_script] void handleFormEvent(in Event aEvent);
78};
79