summaryrefslogtreecommitdiffstats
path: root/webkit/glue
diff options
context:
space:
mode:
authortsepez@chromium.org <tsepez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-08 17:45:47 +0000
committertsepez@chromium.org <tsepez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-08 17:45:47 +0000
commit61265352c022321d94fc99f59a7dcdd837ee05c6 (patch)
tree85ab4e5c528ca1a63f9c75609f7f9ff9eda7621c /webkit/glue
parent368f3a7502802277d24d219c2ed0fdac09f36470 (diff)
downloadchromium_src-61265352c022321d94fc99f59a7dcdd837ee05c6.zip
chromium_src-61265352c022321d94fc99f59a7dcdd837ee05c6.tar.gz
chromium_src-61265352c022321d94fc99f59a7dcdd837ee05c6.tar.bz2
Convert autofill messages to use the new IPC macros. This requires
changing the FormField class to a struct with publically-visible members, which was what should have been done in the first place, instead of the trivial setters/getters which are accessed in various combinations independently of each other throughout the code. Review URL: http://codereview.chromium.org/6633001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77296 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r--webkit/glue/form_field.cc72
-rw-r--r--webkit/glue/form_field.h43
-rw-r--r--webkit/glue/webpasswordautocompletelistener_impl.cc14
3 files changed, 51 insertions, 78 deletions
diff --git a/webkit/glue/form_field.cc b/webkit/glue/form_field.cc
index 82cac6a..0de8446 100644
--- a/webkit/glue/form_field.cc
+++ b/webkit/glue/form_field.cc
@@ -20,41 +20,41 @@ using WebKit::WebVector;
namespace webkit_glue {
FormField::FormField()
- : max_length_(0),
- is_autofilled_(false) {
+ : 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),
- is_autofilled_(false) {
- name_ = element.nameForAutofill();
+ : max_length(0),
+ is_autofilled(false) {
+ name = element.nameForAutofill();
// TODO(jhawkins): Extract the field label. For now we just use the field
// name.
- label_ = name_;
+ label = name;
- form_control_type_ = element.formControlType();
- if (form_control_type_ == ASCIIToUTF16("text")) {
+ form_control_type = element.formControlType();
+ if (form_control_type == ASCIIToUTF16("text")) {
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")) {
+ 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();
+ value = select_element.value();
// For select-one elements copy option strings.
WebVector<WebElement> list_items = select_element.listItems();
- option_strings_.reserve(list_items.size());
+ option_strings.reserve(list_items.size());
for (size_t i = 0; i < list_items.size(); ++i) {
if (list_items[i].hasTagName("option"))
- option_strings_.push_back(list_items[i].to<WebOptionElement>().value());
+ option_strings.push_back(list_items[i].to<WebOptionElement>().value());
}
}
- TrimWhitespace(value_, TRIM_LEADING, &value_);
+ TrimWhitespace(value, TRIM_LEADING, &value);
}
FormField::FormField(const string16& label,
@@ -63,12 +63,12 @@ FormField::FormField(const string16& label,
const string16& form_control_type,
int max_length,
bool is_autofilled)
- : label_(label),
- name_(name),
- value_(value),
- form_control_type_(form_control_type),
- max_length_(max_length),
- is_autofilled_(is_autofilled) {
+ : label(label),
+ name(name),
+ value(value),
+ form_control_type(form_control_type),
+ max_length(max_length),
+ is_autofilled(is_autofilled) {
}
FormField::~FormField() {
@@ -77,10 +77,10 @@ FormField::~FormField() {
bool FormField::operator==(const FormField& field) const {
// A FormField stores a value, but the value is not part of the identity of
// the field, so we don't want to compare the values.
- return (label_ == field.label_ &&
- name_ == field.name_ &&
- form_control_type_ == field.form_control_type_ &&
- max_length_ == field.max_length_);
+ return (label == field.label &&
+ name == field.name &&
+ form_control_type == field.form_control_type &&
+ max_length == field.max_length);
}
bool FormField::operator!=(const FormField& field) const {
@@ -88,24 +88,24 @@ bool FormField::operator!=(const FormField& field) const {
}
bool FormField::StrictlyEqualsHack(const FormField& field) const {
- return (label_ == field.label_ &&
- name_ == field.name_ &&
- value_ == field.value_ &&
- form_control_type_ == field.form_control_type_ &&
- max_length_ == field.max_length_);
+ return (label == field.label &&
+ name == field.name &&
+ value == field.value &&
+ form_control_type == field.form_control_type &&
+ max_length == field.max_length);
}
std::ostream& operator<<(std::ostream& os, const FormField& field) {
return os
- << UTF16ToUTF8(field.label())
+ << UTF16ToUTF8(field.label)
<< " "
- << UTF16ToUTF8(field.name())
+ << UTF16ToUTF8(field.name)
<< " "
- << UTF16ToUTF8(field.value())
+ << UTF16ToUTF8(field.value)
<< " "
- << UTF16ToUTF8(field.form_control_type())
+ << UTF16ToUTF8(field.form_control_type)
<< " "
- << field.max_length();
+ << field.max_length;
}
} // namespace webkit_glue
diff --git a/webkit/glue/form_field.h b/webkit/glue/form_field.h
index 1874c44..c246091 100644
--- a/webkit/glue/form_field.h
+++ b/webkit/glue/form_field.h
@@ -13,8 +13,7 @@
namespace webkit_glue {
// Stores information about a field in a form.
-class FormField {
- public:
+struct FormField {
FormField();
explicit FormField(WebKit::WebFormControlElement element);
FormField(const string16& label,
@@ -25,31 +24,6 @@ class FormField {
bool is_autofilled);
virtual ~FormField();
- const string16& label() const { return label_; }
- const string16& name() const { return name_; }
- 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 {
- return option_strings_;
- }
-
- void set_label(const string16& label) { label_ = label; }
- void set_name(const string16& name) { name_ = name; }
- void set_value(const string16& value) { value_ = value; }
- void set_form_control_type(const string16& form_control_type) {
- 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;
- }
-
// Equality tests for identity which does not include |value_| or |size_|.
// Use |StrictlyEqualsHack| method to test all members.
// TODO(dhollowa): These operators need to be revised when we implement field
@@ -61,14 +35,13 @@ class FormField {
// TODO(dhollowa): This will be removed when we implement field ids.
bool StrictlyEqualsHack(const FormField& field) const;
- private:
- string16 label_;
- string16 name_;
- string16 value_;
- string16 form_control_type_;
- int max_length_;
- bool is_autofilled_;
- std::vector<string16> option_strings_;
+ string16 label;
+ string16 name;
+ string16 value;
+ string16 form_control_type;
+ int max_length;
+ bool is_autofilled;
+ std::vector<string16> option_strings;
};
// So we can compare FormFields with EXPECT_EQ().
diff --git a/webkit/glue/webpasswordautocompletelistener_impl.cc b/webkit/glue/webpasswordautocompletelistener_impl.cc
index 20ecf60..f584532 100644
--- a/webkit/glue/webpasswordautocompletelistener_impl.cc
+++ b/webkit/glue/webpasswordautocompletelistener_impl.cc
@@ -110,10 +110,10 @@ void WebPasswordAutocompleteListenerImpl::didBlurInputElement(
string16 user_input16 = user_input;
// If enabled, set the password field to match the current username.
- if (data_.basic_data.fields[0].value() == user_input16) {
- if (password_delegate_->IsValidValue(data_.basic_data.fields[1].value())) {
+ if (data_.basic_data.fields[0].value == user_input16) {
+ if (password_delegate_->IsValidValue(data_.basic_data.fields[1].value)) {
// Preferred username/login is selected.
- password_delegate_->SetValue(data_.basic_data.fields[1].value());
+ password_delegate_->SetValue(data_.basic_data.fields[1].value);
password_delegate_->SetAutofilled(true);
}
} else if (data_.additional_logins.find(user_input16) !=
@@ -160,8 +160,8 @@ void WebPasswordAutocompleteListenerImpl::performInlineAutocomplete(
// to simplify lookup and save string conversions (see SetValue) on each
// successful call to OnInlineAutocompleteNeeded.
if (TryToMatch(user_input16,
- data_.basic_data.fields[0].value(),
- data_.basic_data.fields[1].value())) {
+ data_.basic_data.fields[0].value,
+ data_.basic_data.fields[1].value)) {
return;
}
@@ -209,8 +209,8 @@ bool WebPasswordAutocompleteListenerImpl::TryToMatch(const string16& input,
void WebPasswordAutocompleteListenerImpl::GetSuggestions(
const string16& input, std::vector<string16>* suggestions) {
- if (StartsWith(data_.basic_data.fields[0].value(), input, false))
- suggestions->push_back(data_.basic_data.fields[0].value());
+ if (StartsWith(data_.basic_data.fields[0].value, input, false))
+ suggestions->push_back(data_.basic_data.fields[0].value);
for (PasswordFormFillData::LoginCollection::iterator it =
data_.additional_logins.begin();