OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/autofill/autofill_xml_parser.h" | 5 #include "chrome/browser/autofill/autofill_xml_parser.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 15 matching lines...) Expand all Loading... | |
26 XML_Error error_code) { | 26 XML_Error error_code) { |
27 succeeded_ = false; | 27 succeeded_ = false; |
28 } | 28 } |
29 | 29 |
30 AutofillQueryXmlParser::AutofillQueryXmlParser( | 30 AutofillQueryXmlParser::AutofillQueryXmlParser( |
31 std::vector<AutofillFieldType>* field_types, | 31 std::vector<AutofillFieldType>* field_types, |
32 UploadRequired* upload_required, | 32 UploadRequired* upload_required, |
33 std::string* experiment_id) | 33 std::string* experiment_id) |
34 : field_types_(field_types), | 34 : field_types_(field_types), |
35 upload_required_(upload_required), | 35 upload_required_(upload_required), |
36 page_number_(-1), total_pages_(-1), | |
ahutter
2012/12/17 17:35:39
separate lines.
Raman Kakilate
2013/01/10 00:54:40
Done.
| |
36 experiment_id_(experiment_id) { | 37 experiment_id_(experiment_id) { |
37 DCHECK(upload_required_); | 38 DCHECK(upload_required_); |
38 DCHECK(experiment_id_); | 39 DCHECK(experiment_id_); |
39 } | 40 } |
40 | 41 |
41 void AutofillQueryXmlParser::StartElement(buzz::XmlParseContext* context, | 42 void AutofillQueryXmlParser::StartElement(buzz::XmlParseContext* context, |
42 const char* name, | 43 const char* name, |
43 const char** attrs) { | 44 const char** attrs) { |
44 buzz::QName qname = context->ResolveQName(name, false); | 45 buzz::QName qname = context->ResolveQName(name, false); |
45 const std::string& element = qname.LocalPart(); | 46 const std::string& element = qname.LocalPart(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 if (attribute_name.compare("autofilltype") == 0) { | 83 if (attribute_name.compare("autofilltype") == 0) { |
83 int value = GetIntValue(context, attrs[1]); | 84 int value = GetIntValue(context, attrs[1]); |
84 field_type = static_cast<AutofillFieldType>(value); | 85 field_type = static_cast<AutofillFieldType>(value); |
85 if (field_type < 0 || field_type > MAX_VALID_FIELD_TYPE) { | 86 if (field_type < 0 || field_type > MAX_VALID_FIELD_TYPE) { |
86 field_type = NO_SERVER_DATA; | 87 field_type = NO_SERVER_DATA; |
87 } | 88 } |
88 } | 89 } |
89 | 90 |
90 // Record this field type. | 91 // Record this field type. |
91 field_types_->push_back(field_type); | 92 field_types_->push_back(field_type); |
93 } else if (element.compare("wallet_data") == 0) { | |
94 // |attrs| is a NULL-terminated list of (attribute, value) pairs. | |
95 while (*attrs) { | |
96 buzz::QName attribute_qname = context->ResolveQName(*attrs, true); | |
97 ++attrs; | |
98 const std::string& attribute_name = attribute_qname.LocalPart(); | |
99 if (attribute_name.compare("page_no") == 0) { | |
ahutter
2012/12/17 17:35:39
Can't you use == instead of compare?
Raman Kakilate
2013/01/10 00:54:40
being consistent with other uses in the file.
| |
100 page_number_ = GetIntValue(context, *attrs); | |
101 } else if (attribute_name.compare("total_pages") == 0) { | |
102 total_pages_ = GetIntValue(context, *attrs); | |
103 } | |
104 ++attrs; | |
105 } | |
92 } | 106 } |
93 } | 107 } |
94 | 108 |
95 int AutofillQueryXmlParser::GetIntValue(buzz::XmlParseContext* context, | 109 int AutofillQueryXmlParser::GetIntValue(buzz::XmlParseContext* context, |
96 const char* attribute) { | 110 const char* attribute) { |
97 char* attr_end = NULL; | 111 char* attr_end = NULL; |
98 int value = strtol(attribute, &attr_end, 10); | 112 int value = strtol(attribute, &attr_end, 10); |
99 if (attr_end != NULL && attr_end == attribute) { | 113 if (attr_end != NULL && attr_end == attribute) { |
100 context->RaiseError(XML_ERROR_SYNTAX); | 114 context->RaiseError(XML_ERROR_SYNTAX); |
101 return 0; | 115 return 0; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 double AutofillUploadXmlParser::GetDoubleValue(buzz::XmlParseContext* context, | 149 double AutofillUploadXmlParser::GetDoubleValue(buzz::XmlParseContext* context, |
136 const char* attribute) { | 150 const char* attribute) { |
137 char* attr_end = NULL; | 151 char* attr_end = NULL; |
138 double value = strtod(attribute, &attr_end); | 152 double value = strtod(attribute, &attr_end); |
139 if (attr_end != NULL && attr_end == attribute) { | 153 if (attr_end != NULL && attr_end == attribute) { |
140 context->RaiseError(XML_ERROR_SYNTAX); | 154 context->RaiseError(XML_ERROR_SYNTAX); |
141 return 0.0; | 155 return 0.0; |
142 } | 156 } |
143 return value; | 157 return value; |
144 } | 158 } |
OLD | NEW |