Browser changes for supporting checkable elements
This change is part of r176189, which was rolledback. Regression was finally identified to have been caused by renderer changes (parts of which are committed, and the regressing parts have been commented out), this CL only has browser side changes. When I have solution to stop regressing my renderer side changes, will submit it along with test data changes.
BUG=157636
Review URL: https://chromiumcodereview.appspot.com/12018004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178022 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/autofill/autofill_xml_parser.cc b/chrome/browser/autofill/autofill_xml_parser.cc
index 425185b7..b2e4c04c 100644
--- a/chrome/browser/autofill/autofill_xml_parser.cc
+++ b/chrome/browser/autofill/autofill_xml_parser.cc
@@ -8,6 +8,7 @@
#include <string.h>
#include "base/logging.h"
+#include "chrome/browser/autofill/autofill_server_field_info.h"
#include "third_party/libjingle/source/talk/xmllite/qname.h"
AutofillXmlParser::AutofillXmlParser()
@@ -28,10 +29,10 @@
}
AutofillQueryXmlParser::AutofillQueryXmlParser(
- std::vector<AutofillFieldType>* field_types,
+ std::vector<AutofillServerFieldInfo>* field_infos,
UploadRequired* upload_required,
std::string* experiment_id)
- : field_types_(field_types),
+ : field_infos_(field_infos),
upload_required_(upload_required),
current_page_number_(-1),
total_pages_(-1),
@@ -54,22 +55,21 @@
// |attrs| is a NULL-terminated list of (attribute, value) pairs.
while (*attrs) {
- buzz::QName attribute_qname = context->ResolveQName(attrs[0], true);
+ buzz::QName attribute_qname = context->ResolveQName(*attrs, true);
+ ++attrs;
const std::string& attribute_name = attribute_qname.LocalPart();
if (attribute_name.compare("uploadrequired") == 0) {
- if (strcmp(attrs[1], "true") == 0)
+ if (strcmp(*attrs, "true") == 0)
*upload_required_ = UPLOAD_REQUIRED;
- else if (strcmp(attrs[1], "false") == 0)
+ else if (strcmp(*attrs, "false") == 0)
*upload_required_ = UPLOAD_NOT_REQUIRED;
} else if (attribute_name.compare("experimentid") == 0) {
- *experiment_id_ = attrs[1];
+ *experiment_id_ = *attrs;
}
-
- // Advance to the next (attribute, value) pair.
- attrs += 2;
+ ++attrs;
}
} else if (element.compare("field") == 0) {
- if (!attrs[0]) {
+ if (!*attrs) {
// Missing the "autofilltype" attribute, abort.
context->RaiseError(XML_ERROR_ABORTED);
return;
@@ -77,20 +77,29 @@
// Determine the field type from the attribute value. There should be one
// attribute (autofilltype) with an integer value.
- AutofillFieldType field_type = UNKNOWN_TYPE;
- buzz::QName attribute_qname = context->ResolveQName(attrs[0], true);
- const std::string& attribute_name = attribute_qname.LocalPart();
+ AutofillServerFieldInfo field_info;
+ field_info.field_type = UNKNOWN_TYPE;
- if (attribute_name.compare("autofilltype") == 0) {
- int value = GetIntValue(context, attrs[1]);
- field_type = static_cast<AutofillFieldType>(value);
- if (field_type < 0 || field_type > MAX_VALID_FIELD_TYPE) {
- field_type = NO_SERVER_DATA;
+ // |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("autofilltype") == 0) {
+ int value = GetIntValue(context, *attrs);
+ if (value >= 0 && value < MAX_VALID_FIELD_TYPE)
+ field_info.field_type = static_cast<AutofillFieldType>(value);
+ else
+ field_info.field_type = NO_SERVER_DATA;
+ } else if (field_info.field_type == FIELD_WITH_DEFAULT_VALUE &&
+ attribute_name.compare("defaultvalue") == 0) {
+ field_info.default_value = *attrs;
}
+ ++attrs;
}
- // Record this field type.
- field_types_->push_back(field_type);
+ // Record this field type, default value pair.
+ field_infos_->push_back(field_info);
} else if (element.compare("autofill_flow") == 0) {
// |attrs| is a NULL-terminated list of (attribute, value) pairs.
while (*attrs) {