OLD | NEW |
1 // Copyright (c) 2006-2008 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 #include "webkit/glue/password_form_dom_manager.h" | 5 #include "webkit/glue/password_form_dom_manager.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" | 8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" |
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPasswordFormData.h
" | 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPasswordFormData.h
" |
10 #include "webkit/glue/form_field.h" | 10 #include "webkit/glue/form_field.h" |
11 | 11 |
(...skipping 17 matching lines...) Expand all Loading... |
29 return NULL; | 29 return NULL; |
30 } | 30 } |
31 | 31 |
32 // static | 32 // static |
33 void PasswordFormDomManager::InitFillData( | 33 void PasswordFormDomManager::InitFillData( |
34 const PasswordForm& form_on_page, | 34 const PasswordForm& form_on_page, |
35 const PasswordFormMap& matches, | 35 const PasswordFormMap& matches, |
36 const PasswordForm* const preferred_match, | 36 const PasswordForm* const preferred_match, |
37 bool wait_for_username_before_autofill, | 37 bool wait_for_username_before_autofill, |
38 PasswordFormFillData* result) { | 38 PasswordFormFillData* result) { |
39 DCHECK(preferred_match); | 39 // Note that many of the |FormField| members are not initialized for |
| 40 // |username_field| and |password_field| because they are currently not used |
| 41 // by the password autocomplete code. |
| 42 FormField username_field; |
| 43 username_field.name = form_on_page.username_element; |
| 44 username_field.value = preferred_match->username_value; |
| 45 FormField password_field; |
| 46 password_field.name = form_on_page.password_element; |
| 47 password_field.value = preferred_match->password_value; |
| 48 |
40 // Fill basic form data. | 49 // Fill basic form data. |
41 result->basic_data.origin = form_on_page.origin; | 50 result->basic_data.origin = form_on_page.origin; |
42 result->basic_data.action = form_on_page.action; | 51 result->basic_data.action = form_on_page.action; |
43 // Three of the parameters below are set to default values because they are | 52 result->basic_data.fields.push_back(username_field); |
44 // currently not used by the password autocomplete code: | 53 result->basic_data.fields.push_back(password_field); |
45 // * The form control type is initialized to an empty string. | |
46 // * The field |max_length| is initialized to 0. | |
47 // * The field autofilled state is initialized to false. | |
48 result->basic_data.fields.push_back( | |
49 FormField(string16(), | |
50 form_on_page.username_element, | |
51 preferred_match->username_value, | |
52 string16(), | |
53 0, | |
54 false)); | |
55 result->basic_data.fields.push_back( | |
56 FormField(string16(), | |
57 form_on_page.password_element, | |
58 preferred_match->password_value, | |
59 string16(), | |
60 0, | |
61 false)); | |
62 result->wait_for_username = wait_for_username_before_autofill; | 54 result->wait_for_username = wait_for_username_before_autofill; |
63 | 55 |
64 // Copy additional username/value pairs. | 56 // Copy additional username/value pairs. |
65 PasswordFormMap::const_iterator iter; | 57 PasswordFormMap::const_iterator iter; |
66 for (iter = matches.begin(); iter != matches.end(); iter++) { | 58 for (iter = matches.begin(); iter != matches.end(); iter++) { |
67 if (iter->second != preferred_match) | 59 if (iter->second != preferred_match) |
68 result->additional_logins[iter->first] = iter->second->password_value; | 60 result->additional_logins[iter->first] = iter->second->password_value; |
69 } | 61 } |
70 } | 62 } |
71 | 63 |
72 } // namespace webkit_glue | 64 } // namespace webkit_glue |
OLD | NEW |