diff options
Diffstat (limited to 'chrome/browser/autofill/form_structure.cc')
-rw-r--r-- | chrome/browser/autofill/form_structure.cc | 55 |
1 files changed, 50 insertions, 5 deletions
diff --git a/chrome/browser/autofill/form_structure.cc b/chrome/browser/autofill/form_structure.cc index b5b2db7..0eab86b 100644 --- a/chrome/browser/autofill/form_structure.cc +++ b/chrome/browser/autofill/form_structure.cc @@ -107,7 +107,7 @@ bool FormStructure::EncodeUploadRequest(bool auto_fill_used, std::string* encoded_xml) const { DCHECK(encoded_xml); encoded_xml->clear(); - bool auto_fillable = IsAutoFillable(false); + bool auto_fillable = IsAutoFillable(); DCHECK(auto_fillable); // Caller should've checked for search pages. if (!auto_fillable) return false; @@ -232,6 +232,8 @@ void FormStructure::ParseQueryResponse(const std::string& response_xml, form->UpdateAutoFillCount(); } + + return; } std::string FormStructure::FormSignature() const { @@ -245,11 +247,11 @@ std::string FormStructure::FormSignature() const { return Hash64Bit(form_string); } -bool FormStructure::IsAutoFillable(bool require_method_post) const { +bool FormStructure::IsAutoFillable() const { if (autofill_count() < kRequiredFillableFields) return false; - return ShouldBeParsed(require_method_post); + return ShouldBeParsed(); } bool FormStructure::HasAutoFillableValues() const { @@ -266,6 +268,46 @@ bool FormStructure::HasAutoFillableValues() const { return false; } +// TODO(jhawkins): Cache this result. +bool FormStructure::HasBillingFields() const { + for (std::vector<AutoFillField*>::const_iterator iter = begin(); + iter != end(); ++iter) { + if (!*iter) + return false; + + AutoFillField* field = *iter; + if (!field) + continue; + + AutoFillType type(field->type()); + if (type.group() == AutoFillType::ADDRESS_BILLING || + type.group() == AutoFillType::CREDIT_CARD) + return true; + } + + return false; +} + +// TODO(jhawkins): Cache this result. +bool FormStructure::HasNonBillingFields() const { + for (std::vector<AutoFillField*>::const_iterator iter = begin(); + iter != end(); ++iter) { + if (!*iter) + return false; + + AutoFillField* field = *iter; + if (!field) + continue; + + AutoFillType type(field->type()); + if (type.group() != AutoFillType::ADDRESS_BILLING && + type.group() != AutoFillType::CREDIT_CARD) + return true; + } + + return false; +} + void FormStructure::UpdateAutoFillCount() { autofill_count_ = 0; for (std::vector<AutoFillField*>::const_iterator iter = begin(); @@ -276,7 +318,7 @@ void FormStructure::UpdateAutoFillCount() { } } -bool FormStructure::ShouldBeParsed(bool require_method_post) const { +bool FormStructure::ShouldBeParsed() const { if (field_count() < kRequiredFillableFields) return false; @@ -286,7 +328,10 @@ bool FormStructure::ShouldBeParsed(bool require_method_post) const { if (target_url_.path() == "/search") return false; - return !require_method_post || (method_ == POST); + if (method_ == GET) + return false; + + return true; } void FormStructure::set_possible_types(int index, const FieldTypeSet& types) { |