OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/form_structure.h" | 5 #include "chrome/browser/autofill/form_structure.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/sha1.h" | 9 #include "base/sha1.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 return false; | 185 return false; |
186 | 186 |
187 // Obtain the XML structure as a string. | 187 // Obtain the XML structure as a string. |
188 *encoded_xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; | 188 *encoded_xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; |
189 *encoded_xml += autofil_request_xml.Str().c_str(); | 189 *encoded_xml += autofil_request_xml.Str().c_str(); |
190 | 190 |
191 return true; | 191 return true; |
192 } | 192 } |
193 | 193 |
194 // static | 194 // static |
195 void FormStructure::ParseQueryResponse(const std::string& response_xml, | 195 void FormStructure::ParseQueryResponse( |
196 const std::vector<FormStructure*>& forms, | 196 const std::string& response_xml, |
197 UploadRequired* upload_required) { | 197 const std::vector<FormStructure*>& forms, |
198 autofill_metrics::LogServerQueryMetric( | 198 UploadRequired* upload_required, |
199 autofill_metrics::QUERY_RESPONSE_RECEIVED); | 199 const AutoFillServerQueryMetricLogger& server_query_metric_logger) { |
| 200 server_query_metric_logger.Log( |
| 201 AutoFillServerQueryMetricLogger::QUERY_RESPONSE_RECEIVED); |
200 | 202 |
201 // Parse the field types from the server response to the query. | 203 // Parse the field types from the server response to the query. |
202 std::vector<AutoFillFieldType> field_types; | 204 std::vector<AutoFillFieldType> field_types; |
203 AutoFillQueryXmlParser parse_handler(&field_types, upload_required); | 205 AutoFillQueryXmlParser parse_handler(&field_types, upload_required); |
204 buzz::XmlParser parser(&parse_handler); | 206 buzz::XmlParser parser(&parse_handler); |
205 parser.Parse(response_xml.c_str(), response_xml.length(), true); | 207 parser.Parse(response_xml.c_str(), response_xml.length(), true); |
206 if (!parse_handler.succeeded()) | 208 if (!parse_handler.succeeded()) |
207 return; | 209 return; |
208 | 210 |
209 autofill_metrics::LogServerQueryMetric( | 211 server_query_metric_logger.Log( |
210 autofill_metrics::QUERY_RESPONSE_PARSED); | 212 AutoFillServerQueryMetricLogger::QUERY_RESPONSE_PARSED); |
211 | 213 |
212 bool heuristics_detected_fillable_field = false; | 214 bool heuristics_detected_fillable_field = false; |
213 bool query_response_overrode_heuristics = false; | 215 bool query_response_overrode_heuristics = false; |
214 | 216 |
215 // Copy the field types into the actual form. | 217 // Copy the field types into the actual form. |
216 std::vector<AutoFillFieldType>::iterator current_type = field_types.begin(); | 218 std::vector<AutoFillFieldType>::iterator current_type = field_types.begin(); |
217 for (std::vector<FormStructure*>::const_iterator iter = forms.begin(); | 219 for (std::vector<FormStructure*>::const_iterator iter = forms.begin(); |
218 iter != forms.end(); ++iter) { | 220 iter != forms.end(); ++iter) { |
219 FormStructure* form = *iter; | 221 FormStructure* form = *iter; |
220 | 222 |
(...skipping 22 matching lines...) Expand all Loading... |
243 AutoFillType autofill_type((*field)->type()); | 245 AutoFillType autofill_type((*field)->type()); |
244 if (autofill_type.group() == AutoFillType::CREDIT_CARD) | 246 if (autofill_type.group() == AutoFillType::CREDIT_CARD) |
245 form->has_credit_card_field_ = true; | 247 form->has_credit_card_field_ = true; |
246 if (autofill_type.field_type() != UNKNOWN_TYPE) | 248 if (autofill_type.field_type() != UNKNOWN_TYPE) |
247 form->has_autofillable_field_ = true; | 249 form->has_autofillable_field_ = true; |
248 } | 250 } |
249 | 251 |
250 form->UpdateAutoFillCount(); | 252 form->UpdateAutoFillCount(); |
251 } | 253 } |
252 | 254 |
253 autofill_metrics::ServerQueryMetricType metric_type; | 255 AutoFillServerQueryMetricLogger::Metric metric; |
254 if (query_response_overrode_heuristics) { | 256 if (query_response_overrode_heuristics) { |
255 if (heuristics_detected_fillable_field) { | 257 if (heuristics_detected_fillable_field) { |
256 metric_type = autofill_metrics::QUERY_RESPONSE_OVERRODE_LOCAL_HEURISTICS; | 258 metric = AutoFillServerQueryMetricLogger:: |
| 259 QUERY_RESPONSE_OVERRODE_LOCAL_HEURISTICS; |
257 } else { | 260 } else { |
258 metric_type = autofill_metrics::QUERY_RESPONSE_WITH_NO_LOCAL_HEURISTICS; | 261 metric = AutoFillServerQueryMetricLogger:: |
| 262 QUERY_RESPONSE_WITH_NO_LOCAL_HEURISTICS; |
259 } | 263 } |
260 } else { | 264 } else { |
261 metric_type = autofill_metrics::QUERY_RESPONSE_MATCHED_LOCAL_HEURISTICS; | 265 metric = AutoFillServerQueryMetricLogger:: |
| 266 QUERY_RESPONSE_MATCHED_LOCAL_HEURISTICS; |
262 } | 267 } |
263 autofill_metrics::LogServerQueryMetric(metric_type); | 268 server_query_metric_logger.Log(metric); |
264 } | 269 } |
265 | 270 |
266 std::string FormStructure::FormSignature() const { | 271 std::string FormStructure::FormSignature() const { |
267 std::string form_string = target_url_.scheme() + | 272 std::string form_string = target_url_.scheme() + |
268 "://" + | 273 "://" + |
269 target_url_.host() + | 274 target_url_.host() + |
270 "&" + | 275 "&" + |
271 UTF16ToUTF8(form_name_) + | 276 UTF16ToUTF8(form_name_) + |
272 form_signature_field_names_; | 277 form_signature_field_names_; |
273 | 278 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 } else { | 430 } else { |
426 buzz::XmlElement *field_element = new buzz::XmlElement( | 431 buzz::XmlElement *field_element = new buzz::XmlElement( |
427 buzz::QName(kXMLElementField)); | 432 buzz::QName(kXMLElementField)); |
428 field_element->SetAttr(buzz::QName(kAttributeSignature), | 433 field_element->SetAttr(buzz::QName(kAttributeSignature), |
429 field->FieldSignature()); | 434 field->FieldSignature()); |
430 encompassing_xml_element->AddElement(field_element); | 435 encompassing_xml_element->AddElement(field_element); |
431 } | 436 } |
432 } | 437 } |
433 return true; | 438 return true; |
434 } | 439 } |
OLD | NEW |