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