diff options
author | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-29 22:27:16 +0000 |
---|---|---|
committer | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-29 22:27:16 +0000 |
commit | 3bb80e49ebd2f095b829e27135962a0aa4591e87 (patch) | |
tree | cce992fadfc3f39a776154372e0d8cf38bdd416e /webkit/glue | |
parent | c8965289996843e686084e86036db4cfe5b1713f (diff) | |
download | chromium_src-3bb80e49ebd2f095b829e27135962a0aa4591e87.zip chromium_src-3bb80e49ebd2f095b829e27135962a0aa4591e87.tar.gz chromium_src-3bb80e49ebd2f095b829e27135962a0aa4591e87.tar.bz2 |
Once a form has been partially autofilled, autofill should only update fields one at a time.
BUG=63437, 62638
TEST=unit_tests --gtest_filter=AutoFillManagerTest.*
Review URL: http://codereview.chromium.org/5334005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67599 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r-- | webkit/glue/form_field.cc | 13 | ||||
-rw-r--r-- | webkit/glue/form_field.h | 7 | ||||
-rw-r--r-- | webkit/glue/password_form_dom_manager.cc | 16 | ||||
-rw-r--r-- | webkit/glue/webpasswordautocompletelistener_unittest.cc | 6 |
4 files changed, 28 insertions, 14 deletions
diff --git a/webkit/glue/form_field.cc b/webkit/glue/form_field.cc index ee28766..bcc9926 100644 --- a/webkit/glue/form_field.cc +++ b/webkit/glue/form_field.cc @@ -20,13 +20,15 @@ using WebKit::WebVector; namespace webkit_glue { FormField::FormField() - : max_length_(0) { + : max_length_(0), + is_autofilled_(false) { } // TODO(jhawkins): This constructor should probably be deprecated and the // functionality moved to FormManager. FormField::FormField(WebFormControlElement element) - : max_length_(0) { + : max_length_(0), + is_autofilled_(false) { name_ = element.nameForAutofill(); // TODO(jhawkins): Extract the field label. For now we just use the field @@ -38,6 +40,7 @@ FormField::FormField(WebFormControlElement element) const WebInputElement& input_element = element.toConst<WebInputElement>(); value_ = input_element.value(); max_length_ = input_element.size(); + is_autofilled_ = input_element.isAutofilled(); } else if (form_control_type_ == ASCIIToUTF16("select-one")) { WebSelectElement select_element = element.to<WebSelectElement>(); value_ = select_element.value(); @@ -58,12 +61,14 @@ FormField::FormField(const string16& label, const string16& name, const string16& value, const string16& form_control_type, - int max_length) + int max_length, + bool is_autofilled) : label_(label), name_(name), value_(value), form_control_type_(form_control_type), - max_length_(max_length) { + max_length_(max_length), + is_autofilled_(is_autofilled) { } FormField::~FormField() { diff --git a/webkit/glue/form_field.h b/webkit/glue/form_field.h index 0a22ea6..23b7380 100644 --- a/webkit/glue/form_field.h +++ b/webkit/glue/form_field.h @@ -21,7 +21,8 @@ class FormField { const string16& name, const string16& value, const string16& form_control_type, - int max_length); + int max_length, + bool is_autofilled); virtual ~FormField(); const string16& label() const { return label_; } @@ -29,6 +30,8 @@ class FormField { const string16& value() const { return value_; } const string16& form_control_type() const { return form_control_type_; } int max_length() const { return max_length_; } + bool is_autofilled() const { return is_autofilled_; } + // Returns option string for elements for which they make sense (select-one, // for example) for the rest of elements return an empty array. const std::vector<string16>& option_strings() const { @@ -42,6 +45,7 @@ class FormField { form_control_type_ = form_control_type; } void set_max_length(int max_length) { max_length_ = max_length; } + void set_autofilled(bool is_autofilled) { is_autofilled_ = is_autofilled; } void set_option_strings(const std::vector<string16>& strings) { option_strings_ = strings; } @@ -63,6 +67,7 @@ class FormField { string16 value_; string16 form_control_type_; int max_length_; + bool is_autofilled_; std::vector<string16> option_strings_; }; diff --git a/webkit/glue/password_form_dom_manager.cc b/webkit/glue/password_form_dom_manager.cc index adbb8dd..97f3eef 100644 --- a/webkit/glue/password_form_dom_manager.cc +++ b/webkit/glue/password_form_dom_manager.cc @@ -40,23 +40,25 @@ void PasswordFormDomManager::InitFillData( // Fill basic form data. result->basic_data.origin = form_on_page.origin; result->basic_data.action = form_on_page.action; - // TODO(jhawkins): Is it right to use an empty string for the form control - // type? I don't think the password autocomplete really cares, but we should - // correct this anyway. - // TODO(dhollowa): Similarly, |size| ideally should be set from the form - // control itself. But it is currently unused. + // Three of the parameters below are set to default values because they are + // currently not used by the password autocomplete code: + // * The form control type is initialized to an empty string. + // * The field |max_length| is initialized to 0. + // * The field autofilled state is initialized to false. result->basic_data.fields.push_back( FormField(string16(), form_on_page.username_element, preferred_match->username_value, string16(), - 0)); + 0, + false)); result->basic_data.fields.push_back( FormField(string16(), form_on_page.password_element, preferred_match->password_value, string16(), - 0)); + 0, + false)); result->wait_for_username = wait_for_username_before_autofill; // Copy additional username/value pairs. diff --git a/webkit/glue/webpasswordautocompletelistener_unittest.cc b/webkit/glue/webpasswordautocompletelistener_unittest.cc index 5de593c..2eeb890 100644 --- a/webkit/glue/webpasswordautocompletelistener_unittest.cc +++ b/webkit/glue/webpasswordautocompletelistener_unittest.cc @@ -104,12 +104,14 @@ class PasswordManagerAutocompleteTests : public testing::Test { string16(), username1_, string16(), - 0)); + 0, + false)); data_.basic_data.fields.push_back(FormField(string16(), string16(), password1_, string16(), - 0)); + 0, + false)); data_.additional_logins[username2_] = password2_; username_delegate_ = new TestWebInputElementDelegate(); |