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/form_structure.h" | 5 #include "components/autofill/core/browser/form_structure.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <utility> | 10 #include <utility> |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 } | 265 } |
266 | 266 |
267 std::string StripDigitsIfRequired(const base::string16& input) { | 267 std::string StripDigitsIfRequired(const base::string16& input) { |
268 std::string return_string = base::UTF16ToUTF8(input); | 268 std::string return_string = base::UTF16ToUTF8(input); |
269 | 269 |
270 re2::RE2::GlobalReplace(&return_string, re2::RE2(kIgnorePatternInFieldName), | 270 re2::RE2::GlobalReplace(&return_string, re2::RE2(kIgnorePatternInFieldName), |
271 std::string()); | 271 std::string()); |
272 return return_string; | 272 return return_string; |
273 } | 273 } |
274 | 274 |
| 275 std::ostream& operator<<( |
| 276 std::ostream& out, |
| 277 const autofill::AutofillQueryResponseContents& response) { |
| 278 out << "upload_required: " << response.upload_required(); |
| 279 for (const auto& field : response.field()) { |
| 280 out << "\nautofill_type: " << field.autofill_type(); |
| 281 } |
| 282 return out; |
| 283 } |
| 284 |
275 } // namespace | 285 } // namespace |
276 | 286 |
277 FormStructure::FormStructure(const FormData& form) | 287 FormStructure::FormStructure(const FormData& form) |
278 : form_name_(form.name), | 288 : form_name_(form.name), |
279 source_url_(form.origin), | 289 source_url_(form.origin), |
280 target_url_(form.action), | 290 target_url_(form.action), |
281 autofill_count_(0), | 291 autofill_count_(0), |
282 active_field_count_(0), | 292 active_field_count_(0), |
283 upload_required_(USE_UPLOAD_RATES), | 293 upload_required_(USE_UPLOAD_RATES), |
284 has_author_specified_types_(false), | 294 has_author_specified_types_(false), |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 const std::vector<FormStructure*>& forms, | 436 const std::vector<FormStructure*>& forms, |
427 rappor::RapporService* rappor_service) { | 437 rappor::RapporService* rappor_service) { |
428 AutofillMetrics::LogServerQueryMetric( | 438 AutofillMetrics::LogServerQueryMetric( |
429 AutofillMetrics::QUERY_RESPONSE_RECEIVED); | 439 AutofillMetrics::QUERY_RESPONSE_RECEIVED); |
430 | 440 |
431 // Parse the response. | 441 // Parse the response. |
432 AutofillQueryResponseContents response; | 442 AutofillQueryResponseContents response; |
433 if (!response.ParseFromString(payload)) | 443 if (!response.ParseFromString(payload)) |
434 return; | 444 return; |
435 | 445 |
| 446 VLOG(1) << "Autofill query response was successfully parsed:\n" << response; |
| 447 |
436 AutofillMetrics::LogServerQueryMetric(AutofillMetrics::QUERY_RESPONSE_PARSED); | 448 AutofillMetrics::LogServerQueryMetric(AutofillMetrics::QUERY_RESPONSE_PARSED); |
437 | 449 |
438 bool heuristics_detected_fillable_field = false; | 450 bool heuristics_detected_fillable_field = false; |
439 bool query_response_overrode_heuristics = false; | 451 bool query_response_overrode_heuristics = false; |
440 | 452 |
441 // Copy the field types into the actual form. | 453 // Copy the field types into the actual form. |
442 auto current_field = response.field().begin(); | 454 auto current_field = response.field().begin(); |
443 for (FormStructure* form : forms) { | 455 for (FormStructure* form : forms) { |
444 form->upload_required_ = | 456 form->upload_required_ = |
445 response.upload_required() ? UPLOAD_REQUIRED : UPLOAD_NOT_REQUIRED; | 457 response.upload_required() ? UPLOAD_REQUIRED : UPLOAD_NOT_REQUIRED; |
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1223 else | 1235 else |
1224 field->set_section(field->section() + "-default"); | 1236 field->set_section(field->section() + "-default"); |
1225 } | 1237 } |
1226 } | 1238 } |
1227 | 1239 |
1228 bool FormStructure::ShouldSkipField(const FormFieldData& field) const { | 1240 bool FormStructure::ShouldSkipField(const FormFieldData& field) const { |
1229 return field.is_checkable; | 1241 return field.is_checkable; |
1230 } | 1242 } |
1231 | 1243 |
1232 } // namespace autofill | 1244 } // namespace autofill |
OLD | NEW |