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