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/autofill_field.h" | 5 #include "components/autofill/core/browser/autofill_field.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/i18n/string_search.h" | 8 #include "base/i18n/string_search.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
11 #include "base/sha1.h" | 11 #include "base/sha1.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/string_split.h" | 13 #include "base/strings/string_split.h" |
14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "components/autofill/core/browser/autofill_country.h" | 16 #include "components/autofill/core/browser/autofill_country.h" |
17 #include "components/autofill/core/browser/autofill_type.h" | 17 #include "components/autofill/core/browser/autofill_type.h" |
18 #include "components/autofill/core/browser/credit_card.h" | 18 #include "components/autofill/core/browser/credit_card.h" |
19 #include "components/autofill/core/browser/phone_number.h" | 19 #include "components/autofill/core/browser/phone_number.h" |
20 #include "components/autofill/core/browser/state_names.h" | 20 #include "components/autofill/core/browser/state_names.h" |
21 #include "components/autofill/core/common/autofill_l10n_util.h" | 21 #include "components/autofill/core/common/autofill_l10n_util.h" |
22 #include "components/autofill/core/common/autofill_switches.h" | 22 #include "components/autofill/core/common/autofill_switches.h" |
| 23 #include "components/autofill/core/common/autofill_util.h" |
23 #include "grit/components_strings.h" | 24 #include "grit/components_strings.h" |
24 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_da
ta.h" | 25 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_da
ta.h" |
25 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_fo
rmatter.h" | 26 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_fo
rmatter.h" |
26 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
27 | 28 |
28 using ::i18n::addressinput::AddressData; | 29 using ::i18n::addressinput::AddressData; |
29 using ::i18n::addressinput::GetStreetAddressLinesAsSingleLine; | 30 using ::i18n::addressinput::GetStreetAddressLinesAsSingleLine; |
30 using base::ASCIIToUTF16; | 31 using base::ASCIIToUTF16; |
31 using base::StringToInt; | 32 using base::StringToInt; |
32 | 33 |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 } | 494 } |
494 | 495 |
495 // static | 496 // static |
496 bool AutofillField::FillFormField(const AutofillField& field, | 497 bool AutofillField::FillFormField(const AutofillField& field, |
497 const base::string16& value, | 498 const base::string16& value, |
498 const std::string& address_language_code, | 499 const std::string& address_language_code, |
499 const std::string& app_locale, | 500 const std::string& app_locale, |
500 FormFieldData* field_data) { | 501 FormFieldData* field_data) { |
501 AutofillType type = field.Type(); | 502 AutofillType type = field.Type(); |
502 | 503 |
| 504 // Don't fill if autocomplete=off is set on |field| on desktop for non credit |
| 505 // card related fields. |
| 506 if (!field.should_autocomplete && IsDesktopPlatform() && |
| 507 (type.group() != CREDIT_CARD)) { |
| 508 return false; |
| 509 } |
| 510 |
503 if (type.GetStorableType() == PHONE_HOME_NUMBER) { | 511 if (type.GetStorableType() == PHONE_HOME_NUMBER) { |
504 FillPhoneNumberField(field, value, field_data); | 512 FillPhoneNumberField(field, value, field_data); |
505 return true; | 513 return true; |
506 } else if (field_data->form_control_type == "select-one") { | 514 } else if (field_data->form_control_type == "select-one") { |
507 return FillSelectControl(type, value, app_locale, field_data); | 515 return FillSelectControl(type, value, app_locale, field_data); |
508 } else if (field_data->form_control_type == "month") { | 516 } else if (field_data->form_control_type == "month") { |
509 return FillMonthControl(value, field_data); | 517 return FillMonthControl(value, field_data); |
510 } else if (type.GetStorableType() == ADDRESS_HOME_STREET_ADDRESS) { | 518 } else if (type.GetStorableType() == ADDRESS_HOME_STREET_ADDRESS) { |
511 FillStreetAddress(value, address_language_code, field_data); | 519 FillStreetAddress(value, address_language_code, field_data); |
512 return true; | 520 return true; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 if (compare.StringsEqual(value_stripped, option_contents)) { | 573 if (compare.StringsEqual(value_stripped, option_contents)) { |
566 if (index) | 574 if (index) |
567 *index = i; | 575 *index = i; |
568 return true; | 576 return true; |
569 } | 577 } |
570 } | 578 } |
571 return false; | 579 return false; |
572 } | 580 } |
573 | 581 |
574 } // namespace autofill | 582 } // namespace autofill |
OLD | NEW |