| Index: components/autofill/browser/autofill_xml_parser.cc
|
| diff --git a/components/autofill/browser/autofill_xml_parser.cc b/components/autofill/browser/autofill_xml_parser.cc
|
| index a4672182d43464408b1de8690b662d68c904db86..3aa1ac2253e5311d0784f47e6005a3eb12614008 100644
|
| --- a/components/autofill/browser/autofill_xml_parser.cc
|
| +++ b/components/autofill/browser/autofill_xml_parser.cc
|
| @@ -8,7 +8,6 @@
|
| #include <string.h>
|
|
|
| #include "base/logging.h"
|
| -#include "components/autofill/browser/autocheckout_page_meta_data.h"
|
| #include "components/autofill/browser/autofill_server_field_info.h"
|
| #include "third_party/libjingle/source/talk/xmllite/qname.h"
|
|
|
| @@ -122,31 +121,69 @@ void AutofillQueryXmlParser::StartElement(buzz::XmlParseContext* context,
|
| }
|
| } else if (element.compare("page_advance_button") == 0) {
|
| // |attrs| is a NULL-terminated list of (attribute, value) pairs.
|
| - // If both id and css_selector are set, the first one to appear will take
|
| - // precedence.
|
| - while (*attrs) {
|
| - buzz::QName attribute_qname = context->ResolveQName(*attrs, true);
|
| - ++attrs;
|
| - const std::string& attribute_name = attribute_qname.LocalPart();
|
| - buzz::QName value_qname = context->ResolveQName(*attrs, true);
|
| - ++attrs;
|
| - const std::string& attribute_value = value_qname.LocalPart();
|
| - if (attribute_name.compare("id") == 0 && !attribute_value.empty()) {
|
| - page_meta_data_->proceed_element_descriptor.retrieval_method =
|
| - autofill::WebElementDescriptor::ID;
|
| - page_meta_data_->proceed_element_descriptor.descriptor =
|
| - attribute_value;
|
| - break;
|
| - } else if (attribute_name.compare("css_selector") == 0 &&
|
| - !attribute_value.empty()) {
|
| - page_meta_data_->proceed_element_descriptor.retrieval_method =
|
| - autofill::WebElementDescriptor::CSS_SELECTOR;
|
| - page_meta_data_->proceed_element_descriptor.descriptor =
|
| - attribute_value;
|
| - break;
|
| - }
|
| + page_meta_data_->proceed_element_descriptor = WebElementDescriptor();
|
| + ParseElementDescriptor(context,
|
| + attrs,
|
| + &page_meta_data_->proceed_element_descriptor);
|
| + } else if (element.compare("click_elements_before_formfill") == 0) {
|
| + ParseClickElement(context,
|
| + attrs,
|
| + &page_meta_data_->click_elements_before_formfill);
|
| + } else if (element.compare("click_elements_after_formfill") == 0) {
|
| + ParseClickElement(context,
|
| + attrs,
|
| + &page_meta_data_->click_elements_after_formfill);
|
| + } else if (element.compare("web_element") == 0) {
|
| + ParseElementDescriptor(context,
|
| + attrs,
|
| + ¤t_click_element_->web_element);
|
| + }
|
| +}
|
| +
|
| +void AutofillQueryXmlParser::ParseClickElement(
|
| + buzz::XmlParseContext* context,
|
| + const char** attrs,
|
| + std::vector<AutocheckoutPageMetaData::ClickElement>* click_elements) {
|
| + click_elements->push_back(AutocheckoutPageMetaData::ClickElement());
|
| + current_click_element_ = &click_elements->back();
|
| +
|
| + // |attrs| is a NULL-terminated list of (attribute, value) pairs.
|
| + while (*attrs) {
|
| + buzz::QName attribute_qname = context->ResolveQName(*attrs, true);
|
| + ++attrs;
|
| + const std::string& attribute_name = attribute_qname.LocalPart();
|
| + if (attribute_name.compare("wait_time_ms") == 0)
|
| + current_click_element_->wait_time_ms = GetIntValue(context, *attrs);
|
| + ++attrs;
|
| + }
|
| +}
|
| +
|
| +WebElementDescriptor* AutofillQueryXmlParser::ParseElementDescriptor(
|
| + buzz::XmlParseContext* context,
|
| + const char** attrs,
|
| + WebElementDescriptor* element_descriptor) {
|
| + // If both id and css_selector are set, the first one to appear will take
|
| + // precedence.
|
| + while (*attrs) {
|
| + buzz::QName attribute_qname = context->ResolveQName(*attrs, true);
|
| + ++attrs;
|
| + const std::string& attribute_name = attribute_qname.LocalPart();
|
| + buzz::QName value_qname = context->ResolveQName(*attrs, true);
|
| + ++attrs;
|
| + const std::string& attribute_value = value_qname.LocalPart();
|
| + if (attribute_name.compare("id") == 0 && !attribute_value.empty()) {
|
| + element_descriptor->retrieval_method = autofill::WebElementDescriptor::ID;
|
| + element_descriptor->descriptor = attribute_value;
|
| + break;
|
| + } else if (attribute_name.compare("css_selector") == 0 &&
|
| + !attribute_value.empty()) {
|
| + element_descriptor->retrieval_method =
|
| + autofill::WebElementDescriptor::CSS_SELECTOR;
|
| + element_descriptor->descriptor = attribute_value;
|
| + break;
|
| }
|
| }
|
| + return element_descriptor;
|
| }
|
|
|
| int AutofillQueryXmlParser::GetIntValue(buzz::XmlParseContext* context,
|
|
|