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/autofill_field.cc

Issue 1583563003: [Autofill] Parse forms that have autocomplete attributes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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/autofill_field.h" 5 #include "components/autofill/core/browser/autofill_field.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/i18n/string_search.h" 10 #include "base/i18n/string_search.h"
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 base::string16 stripped_value; 416 base::string16 stripped_value;
417 base::RemoveChars(value, base::kWhitespaceUTF16, &stripped_value); 417 base::RemoveChars(value, base::kWhitespaceUTF16, &stripped_value);
418 return stripped_value; 418 return stripped_value;
419 } 419 }
420 420
421 } // namespace 421 } // namespace
422 422
423 AutofillField::AutofillField() 423 AutofillField::AutofillField()
424 : server_type_(NO_SERVER_DATA), 424 : server_type_(NO_SERVER_DATA),
425 heuristic_type_(UNKNOWN_TYPE), 425 heuristic_type_(UNKNOWN_TYPE),
426 html_type_(HTML_TYPE_UNKNOWN), 426 html_type_(HTML_TYPE_UNSPECIFIED),
427 html_mode_(HTML_MODE_NONE), 427 html_mode_(HTML_MODE_NONE),
428 phone_part_(IGNORED), 428 phone_part_(IGNORED),
429 credit_card_number_offset_(0), 429 credit_card_number_offset_(0),
430 previously_autofilled_(false) { 430 previously_autofilled_(false) {}
431 }
432 431
433 AutofillField::AutofillField(const FormFieldData& field, 432 AutofillField::AutofillField(const FormFieldData& field,
434 const base::string16& unique_name) 433 const base::string16& unique_name)
435 : FormFieldData(field), 434 : FormFieldData(field),
436 unique_name_(unique_name), 435 unique_name_(unique_name),
437 server_type_(NO_SERVER_DATA), 436 server_type_(NO_SERVER_DATA),
438 heuristic_type_(UNKNOWN_TYPE), 437 heuristic_type_(UNKNOWN_TYPE),
439 html_type_(HTML_TYPE_UNKNOWN), 438 html_type_(HTML_TYPE_UNSPECIFIED),
440 html_mode_(HTML_MODE_NONE), 439 html_mode_(HTML_MODE_NONE),
441 phone_part_(IGNORED), 440 phone_part_(IGNORED),
442 credit_card_number_offset_(0), 441 credit_card_number_offset_(0),
443 previously_autofilled_(false) { 442 previously_autofilled_(false) {}
444 }
445 443
446 AutofillField::~AutofillField() {} 444 AutofillField::~AutofillField() {}
447 445
448 void AutofillField::set_heuristic_type(ServerFieldType type) { 446 void AutofillField::set_heuristic_type(ServerFieldType type) {
449 if (type >= 0 && type < MAX_VALID_FIELD_TYPE && 447 if (type >= 0 && type < MAX_VALID_FIELD_TYPE &&
450 type != FIELD_WITH_DEFAULT_VALUE) { 448 type != FIELD_WITH_DEFAULT_VALUE) {
451 heuristic_type_ = type; 449 heuristic_type_ = type;
452 } else { 450 } else {
453 NOTREACHED(); 451 NOTREACHED();
454 // This case should not be reachable; but since this has potential 452 // This case should not be reachable; but since this has potential
(...skipping 16 matching lines...) Expand all
471 469
472 if (type == HTML_TYPE_TEL_LOCAL_PREFIX) 470 if (type == HTML_TYPE_TEL_LOCAL_PREFIX)
473 phone_part_ = PHONE_PREFIX; 471 phone_part_ = PHONE_PREFIX;
474 else if (type == HTML_TYPE_TEL_LOCAL_SUFFIX) 472 else if (type == HTML_TYPE_TEL_LOCAL_SUFFIX)
475 phone_part_ = PHONE_SUFFIX; 473 phone_part_ = PHONE_SUFFIX;
476 else 474 else
477 phone_part_ = IGNORED; 475 phone_part_ = IGNORED;
478 } 476 }
479 477
480 AutofillType AutofillField::Type() const { 478 AutofillType AutofillField::Type() const {
481 if (html_type_ != HTML_TYPE_UNKNOWN) 479 if (html_type_ != HTML_TYPE_UNSPECIFIED)
482 return AutofillType(html_type_, html_mode_); 480 return AutofillType(html_type_, html_mode_);
483 481
484 if (server_type_ != NO_SERVER_DATA) { 482 if (server_type_ != NO_SERVER_DATA) {
485 // See http://crbug.com/429236 for background on why we might not always 483 // See http://crbug.com/429236 for background on why we might not always
486 // believe the server. 484 // believe the server.
487 // See http://crbug.com/441488 for potential improvements to the server 485 // See http://crbug.com/441488 for potential improvements to the server
488 // which may obviate the need for this logic. 486 // which may obviate the need for this logic.
489 bool believe_server = 487 bool believe_server =
490 !(server_type_ == NAME_FULL && heuristic_type_ == CREDIT_CARD_NAME) && 488 !(server_type_ == NAME_FULL && heuristic_type_ == CREDIT_CARD_NAME) &&
491 !(server_type_ == CREDIT_CARD_NAME && heuristic_type_ == NAME_FULL) && 489 !(server_type_ == CREDIT_CARD_NAME && heuristic_type_ == NAME_FULL) &&
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 if (compare.StringsEqual(value_stripped, option_contents)) { 592 if (compare.StringsEqual(value_stripped, option_contents)) {
595 if (index) 593 if (index)
596 *index = i; 594 *index = i;
597 return true; 595 return true;
598 } 596 }
599 } 597 }
600 return false; 598 return false;
601 } 599 }
602 600
603 } // namespace autofill 601 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698