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

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

Issue 11415221: Add support for autofilling radio buttons and checkboxes. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: address comments Created 8 years 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: chrome/browser/autofill/autofill_xml_parser.cc
diff --git a/chrome/browser/autofill/autofill_xml_parser.cc b/chrome/browser/autofill/autofill_xml_parser.cc
index 92a1ede91c0f94dbc96794d4060b2c51af488145..c91c152296d9b1e661161a382b7a2671f6d61405 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 @@ void AutofillXmlParser::Error(buzz::XmlParseContext* context,
}
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),
experiment_id_(experiment_id) {
DCHECK(upload_required_);
@@ -52,19 +53,18 @@ void AutofillQueryXmlParser::StartElement(buzz::XmlParseContext* context,
// |attrs| is a NULL-terminated list of (attribute, value) pairs.
Ilya Sherman 2012/12/07 01:47:22 nit: Please add a similar comment above line 81 as
Raman Kakilate 2012/12/10 18:36:45 Done.
while (*attrs) {
- buzz::QName attribute_qname = context->ResolveQName(attrs[0], true);
+ buzz::QName attribute_qname = context->ResolveQName(*attrs, true);
+ attrs++;
Ilya Sherman 2012/12/07 01:47:22 nit: ++attrs
Raman Kakilate 2012/12/10 18:36:45 Done.
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 ++;
Ilya Sherman 2012/12/07 01:47:22 nit: ++attrs
Raman Kakilate 2012/12/10 18:36:45 Done.
}
} else if (element.compare("field") == 0) {
if (!attrs[0]) {
Ilya Sherman 2012/12/07 01:47:22 nit: *attrs
Raman Kakilate 2012/12/10 18:36:45 Done.
@@ -75,20 +75,28 @@ void AutofillQueryXmlParser::StartElement(buzz::XmlParseContext* context,
// 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();
-
- 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;
+ AutofillServerFieldInfo field_info;
+ field_info.field_type = UNKNOWN_TYPE;
+
+ while (*attrs) {
+ buzz::QName attribute_qname = context->ResolveQName(*attrs, true);
+ attrs++;
Ilya Sherman 2012/12/07 01:47:22 nit: ++attrs
Raman Kakilate 2012/12/10 18:36:45 Done.
+ const std::string& attribute_name = attribute_qname.LocalPart();
+ if (attribute_name.compare("autofilltype") == 0) {
Ilya Sherman 2012/12/07 01:47:22 nit: Can this be written as """if (attribute_name
Raman Kakilate 2012/12/10 18:36:45 There are more than few compare calls in this file
+ int value = GetIntValue(context, *attrs);
+ field_info.field_type = static_cast<AutofillFieldType>(value);
+ if (field_info.field_type < 0 ||
+ field_info.field_type > MAX_VALID_FIELD_TYPE)
+ 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.assign(*attrs);
Ilya Sherman 2012/12/07 01:47:22 nit: Can this be written as "field_info.default_va
Raman Kakilate 2012/12/10 18:36:45 Done.
}
+ attrs ++;
Ilya Sherman 2012/12/07 01:47:22 nit: ++attrs
Raman Kakilate 2012/12/10 18:36:45 Done.
}
- // Record this field type.
- field_types_->push_back(field_type);
+ // Record this field type, default value pair.
+ field_infos_->push_back(field_info);
}
}

Powered by Google App Engine
This is Rietveld 408576698