| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chrome/common/password_form_fill_data.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 "content/public/common/form_field.h" |
| 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPasswordFormData.h
" | |
| 10 #include "webkit/forms/form_field.h" | |
| 11 | 9 |
| 12 using WebKit::WebFormElement; | 10 namespace chrome { |
| 13 using WebKit::WebInputElement; | |
| 14 using WebKit::WebPasswordFormData; | |
| 15 | |
| 16 namespace webkit { | |
| 17 namespace forms { | |
| 18 | 11 |
| 19 PasswordFormFillData::PasswordFormFillData() : wait_for_username(false) { | 12 PasswordFormFillData::PasswordFormFillData() : wait_for_username(false) { |
| 20 } | 13 } |
| 21 | 14 |
| 22 PasswordFormFillData::~PasswordFormFillData() { | 15 PasswordFormFillData::~PasswordFormFillData() { |
| 23 } | 16 } |
| 24 | 17 |
| 25 scoped_ptr<PasswordForm> PasswordFormDomManager::CreatePasswordForm( | 18 void InitPasswordFormFillData( |
| 26 const WebFormElement& webform) { | 19 const content::PasswordForm& form_on_page, |
| 27 WebPasswordFormData web_password_form(webform); | 20 const content::PasswordFormMap& matches, |
| 28 if (web_password_form.isValid()) | 21 const content::PasswordForm* const preferred_match, |
| 29 return scoped_ptr<PasswordForm>(new PasswordForm(web_password_form)); | |
| 30 return scoped_ptr<PasswordForm>(); | |
| 31 } | |
| 32 | |
| 33 // static | |
| 34 void PasswordFormDomManager::InitFillData( | |
| 35 const PasswordForm& form_on_page, | |
| 36 const PasswordFormMap& matches, | |
| 37 const PasswordForm* const preferred_match, | |
| 38 bool wait_for_username_before_autofill, | 22 bool wait_for_username_before_autofill, |
| 39 PasswordFormFillData* result) { | 23 PasswordFormFillData* result) { |
| 40 // Note that many of the |FormField| members are not initialized for | 24 // Note that many of the |FormField| members are not initialized for |
| 41 // |username_field| and |password_field| because they are currently not used | 25 // |username_field| and |password_field| because they are currently not used |
| 42 // by the password autocomplete code. | 26 // by the password autocomplete code. |
| 43 FormField username_field; | 27 content::FormField username_field; |
| 44 username_field.name = form_on_page.username_element; | 28 username_field.name = form_on_page.username_element; |
| 45 username_field.value = preferred_match->username_value; | 29 username_field.value = preferred_match->username_value; |
| 46 FormField password_field; | 30 content::FormField password_field; |
| 47 password_field.name = form_on_page.password_element; | 31 password_field.name = form_on_page.password_element; |
| 48 password_field.value = preferred_match->password_value; | 32 password_field.value = preferred_match->password_value; |
| 49 | 33 |
| 50 // Fill basic form data. | 34 // Fill basic form data. |
| 51 result->basic_data.origin = form_on_page.origin; | 35 result->basic_data.origin = form_on_page.origin; |
| 52 result->basic_data.action = form_on_page.action; | 36 result->basic_data.action = form_on_page.action; |
| 53 result->basic_data.fields.push_back(username_field); | 37 result->basic_data.fields.push_back(username_field); |
| 54 result->basic_data.fields.push_back(password_field); | 38 result->basic_data.fields.push_back(password_field); |
| 55 result->wait_for_username = wait_for_username_before_autofill; | 39 result->wait_for_username = wait_for_username_before_autofill; |
| 56 | 40 |
| 57 // Copy additional username/value pairs. | 41 // Copy additional username/value pairs. |
| 58 PasswordFormMap::const_iterator iter; | 42 content::PasswordFormMap::const_iterator iter; |
| 59 for (iter = matches.begin(); iter != matches.end(); iter++) { | 43 for (iter = matches.begin(); iter != matches.end(); iter++) { |
| 60 if (iter->second != preferred_match) | 44 if (iter->second != preferred_match) |
| 61 result->additional_logins[iter->first] = iter->second->password_value; | 45 result->additional_logins[iter->first] = iter->second->password_value; |
| 62 } | 46 } |
| 63 } | 47 } |
| 64 | 48 |
| 65 } // namespace forms | 49 } // namespace chrome |
| 66 } // namespace webkit | |
| OLD | NEW |