OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/autofill/core/browser/autofill_xml_parser.h" | 5 #include "components/autofill/core/browser/autofill_xml_parser.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 field_info.default_value = *attrs; | 93 field_info.default_value = *attrs; |
94 } | 94 } |
95 ++attrs; | 95 ++attrs; |
96 } | 96 } |
97 | 97 |
98 // Record this field type, default value pair. | 98 // Record this field type, default value pair. |
99 field_infos_->push_back(field_info); | 99 field_infos_->push_back(field_info); |
100 } | 100 } |
101 } | 101 } |
102 | 102 |
103 void AutofillQueryXmlParser::ParseElementDescriptor( | |
104 buzz::XmlParseContext* context, | |
105 const char* const* attrs, | |
106 WebElementDescriptor* element_descriptor) { | |
107 // If both id and css_selector are set, the first one to appear will take | |
108 // precedence. | |
109 // |attrs| is a NULL-terminated list of (attribute, value) pairs. | |
110 while (*attrs) { | |
111 buzz::QName attribute_qname = context->ResolveQName(*attrs, true); | |
112 ++attrs; | |
113 const std::string& attribute_name = attribute_qname.LocalPart(); | |
114 buzz::QName value_qname = context->ResolveQName(*attrs, true); | |
115 ++attrs; | |
116 const std::string& attribute_value = value_qname.LocalPart(); | |
117 if (attribute_name.compare("id") == 0 && !attribute_value.empty()) { | |
118 element_descriptor->retrieval_method = WebElementDescriptor::ID; | |
119 element_descriptor->descriptor = attribute_value; | |
120 break; | |
121 } else if (attribute_name.compare("css_selector") == 0 && | |
122 !attribute_value.empty()) { | |
123 element_descriptor->retrieval_method = WebElementDescriptor::CSS_SELECTOR; | |
124 element_descriptor->descriptor = attribute_value; | |
125 break; | |
126 } | |
127 } | |
128 } | |
129 | |
130 int AutofillQueryXmlParser::GetIntValue(buzz::XmlParseContext* context, | 103 int AutofillQueryXmlParser::GetIntValue(buzz::XmlParseContext* context, |
131 const char* attribute) { | 104 const char* attribute) { |
132 int value = 0; | 105 int value = 0; |
133 if (!base::StringToInt(attribute, &value)) { | 106 if (!base::StringToInt(attribute, &value)) { |
134 context->RaiseError(XML_ERROR_SYNTAX); | 107 context->RaiseError(XML_ERROR_SYNTAX); |
135 return 0; | 108 return 0; |
136 } | 109 } |
137 return value; | 110 return value; |
138 } | 111 } |
139 | 112 |
(...skipping 30 matching lines...) Expand all Loading... |
170 const char* attribute) { | 143 const char* attribute) { |
171 double value = 0; | 144 double value = 0; |
172 if (!base::StringToDouble(attribute, &value)) { | 145 if (!base::StringToDouble(attribute, &value)) { |
173 context->RaiseError(XML_ERROR_SYNTAX); | 146 context->RaiseError(XML_ERROR_SYNTAX); |
174 return 0.0; | 147 return 0.0; |
175 } | 148 } |
176 return value; | 149 return value; |
177 } | 150 } |
178 | 151 |
179 } // namespace autofill | 152 } // namespace autofill |
OLD | NEW |