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

Side by Side Diff: components/autofill/core/browser/autofill_xml_parser.cc

Issue 1474973002: Remove WebElementDescriptor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix BUILD files Created 5 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 unified diff | Download patch
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_xml_parser.h ('k') | components/autofill/core/browser/form_structure.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698