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

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

Issue 2026353002: [Autofill] Credit Card Assist Infobar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleaning Created 4 years, 4 months 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/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 <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 std::ostream& operator<<( 283 std::ostream& operator<<(
284 std::ostream& out, 284 std::ostream& out,
285 const autofill::AutofillQueryResponseContents& response) { 285 const autofill::AutofillQueryResponseContents& response) {
286 out << "upload_required: " << response.upload_required(); 286 out << "upload_required: " << response.upload_required();
287 for (const auto& field : response.field()) { 287 for (const auto& field : response.field()) {
288 out << "\nautofill_type: " << field.autofill_type(); 288 out << "\nautofill_type: " << field.autofill_type();
289 } 289 }
290 return out; 290 return out;
291 } 291 }
292 292
293 bool IsCreditCardExpirationType(ServerFieldType type) {
294 return type == CREDIT_CARD_EXP_MONTH ||
295 type == CREDIT_CARD_EXP_2_DIGIT_YEAR ||
296 type == CREDIT_CARD_EXP_4_DIGIT_YEAR ||
297 type == CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR ||
298 type == CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR;
299 }
300
293 } // namespace 301 } // namespace
294 302
295 FormStructure::FormStructure(const FormData& form) 303 FormStructure::FormStructure(const FormData& form)
296 : form_name_(form.name), 304 : form_name_(form.name),
297 source_url_(form.origin), 305 source_url_(form.origin),
298 target_url_(form.action), 306 target_url_(form.action),
299 autofill_count_(0), 307 autofill_count_(0),
300 active_field_count_(0), 308 active_field_count_(0),
301 upload_required_(USE_UPLOAD_RATES), 309 upload_required_(USE_UPLOAD_RATES),
302 has_author_specified_types_(false), 310 has_author_specified_types_(false),
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 return base::Uint64ToString(FormSignature64Bit()); 578 return base::Uint64ToString(FormSignature64Bit());
571 } 579 }
572 580
573 bool FormStructure::IsAutofillable() const { 581 bool FormStructure::IsAutofillable() const {
574 if (autofill_count() < kRequiredFieldsForPredictionRoutines) 582 if (autofill_count() < kRequiredFieldsForPredictionRoutines)
575 return false; 583 return false;
576 584
577 return ShouldBeParsed(); 585 return ShouldBeParsed();
578 } 586 }
579 587
588 bool FormStructure::IsCompleteCreditCardForm() const {
589 bool found_cc_number = false;
590 bool found_cc_expiration = false;
591 for (const AutofillField* field : fields_) {
592 ServerFieldType type = field->Type().GetStorableType();
593 if (!found_cc_expiration && IsCreditCardExpirationType(type)) {
594 found_cc_expiration = true;
595 } else if (!found_cc_number && type == CREDIT_CARD_NUMBER) {
596 found_cc_number = true;
597 }
598 if (found_cc_expiration && found_cc_number)
599 return true;
600 }
601 return false;
602 }
603
580 void FormStructure::UpdateAutofillCount() { 604 void FormStructure::UpdateAutofillCount() {
581 autofill_count_ = 0; 605 autofill_count_ = 0;
582 for (const AutofillField* field : *this) { 606 for (const AutofillField* field : *this) {
583 if (field && field->IsFieldFillable()) 607 if (field && field->IsFieldFillable())
584 ++autofill_count_; 608 ++autofill_count_;
585 } 609 }
586 } 610 }
587 611
588 bool FormStructure::ShouldBeParsed() const { 612 bool FormStructure::ShouldBeParsed() const {
589 if (active_field_count() < kRequiredFieldsForPredictionRoutines && 613 if (active_field_count() < kRequiredFieldsForPredictionRoutines &&
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
1357 filtered_strings[0].at(prefix_len)) { 1381 filtered_strings[0].at(prefix_len)) {
1358 // Mismatch found. 1382 // Mismatch found.
1359 return filtered_strings[i].substr(0, prefix_len); 1383 return filtered_strings[i].substr(0, prefix_len);
1360 } 1384 }
1361 } 1385 }
1362 } 1386 }
1363 return filtered_strings[0]; 1387 return filtered_strings[0];
1364 } 1388 }
1365 1389
1366 } // namespace autofill 1390 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/form_structure.h ('k') | components/autofill/core/browser/form_structure_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698