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 #include "webkit/forms/password_form_dom_manager.h" | 5 #include "webkit/forms/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/forms/form_field.h" | 10 #include "webkit/forms/form_field.h" |
(...skipping 19 matching lines...) Expand all Loading... | |
30 return NULL; | 30 return NULL; |
31 } | 31 } |
32 | 32 |
33 // static | 33 // static |
34 void PasswordFormDomManager::InitFillData( | 34 void PasswordFormDomManager::InitFillData( |
35 const PasswordForm& form_on_page, | 35 const PasswordForm& form_on_page, |
36 const PasswordFormMap& matches, | 36 const PasswordFormMap& matches, |
37 const PasswordForm* const preferred_match, | 37 const PasswordForm* const preferred_match, |
38 bool wait_for_username_before_autofill, | 38 bool wait_for_username_before_autofill, |
39 PasswordFormFillData* result) { | 39 PasswordFormFillData* result) { |
40 // Note that many of the |FormField| members are not initialized for | |
41 // |username_field| and |password_field| because they are currently not used | |
42 // by the password autocomplete code. | |
43 FormField username_field; | |
44 username_field.name = form_on_page.username_element; | |
45 username_field.value = preferred_match->username_value; | |
46 FormField password_field; | |
47 password_field.name = form_on_page.password_element; | |
48 password_field.value = preferred_match->password_value; | |
49 | 40 |
50 // Fill basic form data. | 41 // Fill basic form data. |
51 result->basic_data.origin = form_on_page.origin; | 42 result->basic_data.origin = form_on_page.origin; |
52 result->basic_data.action = form_on_page.action; | 43 result->basic_data.action = form_on_page.action; |
53 result->basic_data.fields.push_back(username_field); | 44 result->wait_for_username = wait_for_username_before_autofill; |
45 | |
46 // Note that many of the |FormField| members are not initialized for | |
47 // |username_field| and |password_field| because they are currently not used | |
48 // by the password autocomplete code. | |
49 FormField password_field; | |
50 password_field.name = form_on_page.password_element; | |
51 password_field.value = preferred_match->password_value; | |
54 result->basic_data.fields.push_back(password_field); | 52 result->basic_data.fields.push_back(password_field); |
55 result->wait_for_username = wait_for_username_before_autofill; | 53 |
54 // If username_element is empty string, | |
55 // we suppose that there isn't any username field and don't set the username. | |
56 string16 none_username; | |
57 if (form_on_page.username_element != none_username) { | |
Ilya Sherman
2012/03/27 00:15:28
nit: This would be a little clearer if written as
Yumikiyo Osanai
2012/03/27 22:59:28
Done.
| |
58 FormField username_field; | |
59 username_field.name = form_on_page.username_element; | |
60 username_field.value = preferred_match->username_value; | |
61 result->basic_data.fields.push_back(username_field); | |
62 } | |
56 | 63 |
57 // Copy additional username/value pairs. | 64 // Copy additional username/value pairs. |
58 PasswordFormMap::const_iterator iter; | 65 PasswordFormMap::const_iterator iter; |
59 for (iter = matches.begin(); iter != matches.end(); iter++) { | 66 for (iter = matches.begin(); iter != matches.end(); iter++) { |
60 if (iter->second != preferred_match) | 67 if (iter->second != preferred_match) |
61 result->additional_logins[iter->first] = iter->second->password_value; | 68 result->additional_logins[iter->first] = iter->second->password_value; |
62 } | 69 } |
63 } | 70 } |
64 | 71 |
65 } // namespace forms | 72 } // namespace forms |
66 } // namespace webkit | 73 } // namespace webkit |
OLD | NEW |