Extracting advance element details from Autofill server XML response.


BUG=


Review URL: https://chromiumcodereview.appspot.com/12051017

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178625 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/autofill/autofill_xml_parser.cc b/chrome/browser/autofill/autofill_xml_parser.cc
index b2e4c04c..ea1a605 100644
--- a/chrome/browser/autofill/autofill_xml_parser.cc
+++ b/chrome/browser/autofill/autofill_xml_parser.cc
@@ -15,6 +15,8 @@
     : succeeded_(true) {
 }
 
+AutofillXmlParser::~AutofillXmlParser() {}
+
 void AutofillXmlParser::CharacterData(
     buzz::XmlParseContext* context, const char* text, int len) {
 }
@@ -41,6 +43,8 @@
   DCHECK(experiment_id_);
 }
 
+AutofillQueryXmlParser::~AutofillQueryXmlParser() {}
+
 void AutofillQueryXmlParser::StartElement(buzz::XmlParseContext* context,
                                           const char* name,
                                           const char** attrs) {
@@ -112,6 +116,32 @@
         total_pages_ = GetIntValue(context, *attrs);
       ++attrs;
     }
+  } 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()) {
+        proceed_element_descriptor_.reset(new autofill::WebElementDescriptor());
+        proceed_element_descriptor_->retrieval_method =
+            autofill::WebElementDescriptor::ID;
+        proceed_element_descriptor_->descriptor = attribute_value;
+        break;
+      } else if (attribute_name.compare("css_selector") == 0 &&
+                 !attribute_value.empty()) {
+        proceed_element_descriptor_.reset(new autofill::WebElementDescriptor());
+        proceed_element_descriptor_->retrieval_method =
+            autofill::WebElementDescriptor::CSS_SELECTOR;
+        proceed_element_descriptor_->descriptor = attribute_value;
+        break;
+      }
+    }
   }
 }