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