Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Unified Diff: components/autofill/browser/autofill_xml_parser.cc

Issue 15487004: Autocheckout: parse multiple clicks setting in autofill response. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address Ilya's comments. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..455be902cee32949e21f92a2d6866034f535dfe5 100644
--- a/components/autofill/browser/autofill_xml_parser.cc
+++ b/components/autofill/browser/autofill_xml_parser.cc
@@ -122,31 +122,51 @@ 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) {
+ HandleClickElement(&page_meta_data_->click_elements_before_form_fill);
+ } else if (element.compare("click_elements_after_formfill") == 0) {
+ HandleClickElement(&page_meta_data_->click_elements_after_form_fill);
+ } else if (element.compare("web_element") == 0) {
+ ParseElementDescriptor(context, attrs, current_click_element_);
+ }
+}
+
+void AutofillQueryXmlParser::HandleClickElement(
+ std::vector<WebElementDescriptor>* click_elements) {
+ click_elements->push_back(WebElementDescriptor());
+ current_click_element_ = &click_elements->back();
+}
+
+WebElementDescriptor* AutofillQueryXmlParser::ParseElementDescriptor(
+ buzz::XmlParseContext* context,
+ const char* const* 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;
Evan Stade 2013/05/24 23:03:32 doesn't look like this return value is ever used?
benquan 2013/05/30 22:26:53 Done.
}
int AutofillQueryXmlParser::GetIntValue(buzz::XmlParseContext* context,
« no previous file with comments | « components/autofill/browser/autofill_xml_parser.h ('k') | components/autofill/browser/autofill_xml_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698