OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef WEBKIT_GLUE_PASSWORD_FORM_DOM_MANAGER_H_ | |
6 #define WEBKIT_GLUE_PASSWORD_FORM_DOM_MANAGER_H_ | |
7 | |
8 #include <map> | |
9 | |
10 #include "webkit/glue/form_data.h" | |
11 #include "webkit/glue/password_form.h" | |
12 #include "webkit/glue/webkit_glue_export.h" | |
13 | |
14 namespace WebKit { | |
15 class WebForm; | |
16 } | |
17 | |
18 namespace webkit_glue { | |
19 | |
20 // Structure used for autofilling password forms. | |
21 // basic_data identifies the HTML form on the page and preferred username/ | |
22 // password for login, while | |
23 // additional_logins is a list of other matching user/pass pairs for the form. | |
24 // wait_for_username tells us whether we need to wait for the user to enter | |
25 // a valid username before we autofill the password. By default, this is off | |
26 // unless the PasswordManager determined there is an additional risk | |
27 // associated with this form. This can happen, for example, if action URI's | |
28 // of the observed form and our saved representation don't match up. | |
29 struct WEBKIT_GLUE_EXPORT PasswordFormFillData { | |
30 typedef std::map<string16, string16> LoginCollection; | |
31 | |
32 FormData basic_data; | |
33 LoginCollection additional_logins; | |
34 bool wait_for_username; | |
35 PasswordFormFillData(); | |
36 ~PasswordFormFillData(); | |
37 }; | |
38 | |
39 class PasswordFormDomManager { | |
40 public: | |
41 // Create a PasswordForm from DOM form. Webkit doesn't allow storing | |
42 // custom metadata to DOM nodes, so we have to do this every time an event | |
43 // happens with a given form and compare against previously Create'd forms | |
44 // to identify..which sucks. | |
45 WEBKIT_GLUE_EXPORT static PasswordForm* CreatePasswordForm( | |
46 const WebKit::WebFormElement& form); | |
47 | |
48 // Create a FillData structure in preparation for autofilling a form, | |
49 // from basic_data identifying which form to fill, and a collection of | |
50 // matching stored logins to use as username/password values. | |
51 // preferred_match should equal (address) one of matches. | |
52 // wait_for_username_before_autofill is true if we should not autofill | |
53 // anything until the user typed in a valid username and blurred the field. | |
54 WEBKIT_GLUE_EXPORT static void InitFillData(const PasswordForm& form_on_page, | |
55 const PasswordFormMap& matches, | |
56 const PasswordForm* const preferred_match, | |
57 bool wait_for_username_before_autofill, | |
58 PasswordFormFillData* result); | |
59 private: | |
60 DISALLOW_IMPLICIT_CONSTRUCTORS(PasswordFormDomManager); | |
61 }; | |
62 | |
63 } // namespace webkit_glue | |
64 | |
65 #endif // WEBKIT_GLUE_PASSWORD_FORM_DOM_MANAGER_H__ | |
OLD | NEW |