Chromium Code Reviews| 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/personal_data_manager.h" | 5 #include "components/autofill/core/browser/personal_data_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <iterator> | 9 #include <iterator> |
| 10 | 10 |
| 11 #include "base/i18n/timezone.h" | 11 #include "base/i18n/timezone.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
| 15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/strings/string_split.h" | |
| 16 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 18 #include "components/autofill/core/browser/autofill-inl.h" | 19 #include "components/autofill/core/browser/autofill-inl.h" |
| 19 #include "components/autofill/core/browser/autofill_country.h" | 20 #include "components/autofill/core/browser/autofill_country.h" |
| 20 #include "components/autofill/core/browser/autofill_field.h" | 21 #include "components/autofill/core/browser/autofill_field.h" |
| 21 #include "components/autofill/core/browser/form_structure.h" | 22 #include "components/autofill/core/browser/form_structure.h" |
| 22 #include "components/autofill/core/browser/personal_data_manager_observer.h" | 23 #include "components/autofill/core/browser/personal_data_manager_observer.h" |
| 23 #include "components/autofill/core/browser/phone_number.h" | 24 #include "components/autofill/core/browser/phone_number.h" |
| 24 #include "components/autofill/core/browser/phone_number_i18n.h" | 25 #include "components/autofill/core/browser/phone_number_i18n.h" |
| 25 #include "components/autofill/core/browser/validation.h" | 26 #include "components/autofill/core/browser/validation.h" |
| 26 #include "components/autofill/core/common/autofill_pref_names.h" | 27 #include "components/autofill/core/common/autofill_pref_names.h" |
| 28 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre ss_ui.h" | |
| 27 | 29 |
| 28 namespace autofill { | 30 namespace autofill { |
| 29 namespace { | 31 namespace { |
| 30 | 32 |
| 31 const base::string16::value_type kCreditCardPrefix[] = {'*', 0}; | 33 const base::string16::value_type kCreditCardPrefix[] = {'*', 0}; |
| 32 | 34 |
| 33 template<typename T> | 35 template<typename T> |
| 34 class FormGroupMatchesByGUIDFunctor { | 36 class FormGroupMatchesByGUIDFunctor { |
| 35 public: | 37 public: |
| 36 explicit FormGroupMatchesByGUIDFunctor(const std::string& guid) | 38 explicit FormGroupMatchesByGUIDFunctor(const std::string& guid) |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 626 | 628 |
| 627 if (!field_is_autofilled) { | 629 if (!field_is_autofilled) { |
| 628 AutofillProfile::CreateInferredLabels( | 630 AutofillProfile::CreateInferredLabels( |
| 629 matched_profiles, &other_field_types, | 631 matched_profiles, &other_field_types, |
| 630 type.GetStorableType(), 1, labels); | 632 type.GetStorableType(), 1, labels); |
| 631 } else { | 633 } else { |
| 632 // No sub-labels for previously filled fields. | 634 // No sub-labels for previously filled fields. |
| 633 labels->resize(values->size()); | 635 labels->resize(values->size()); |
| 634 } | 636 } |
| 635 | 637 |
| 638 // Names need to be in vertically compact form - i.e. a single line. Join | |
| 639 // multi-line names into a single line, using a separator. | |
| 640 // The separator is locale-specific. | |
| 641 base::string16 compact_separator = base::UTF8ToUTF16( | |
| 642 ::i18n::addressinput::GetCompactAddressLinesSeparator(app_locale_)); | |
| 643 for (size_t i = 0; i < values->size(); ++i) { | |
| 644 std::vector<base::string16> lines; | |
| 645 base::SplitString((*values)[i], '\n', &lines); | |
| 646 (*values)[i] = (JoinString(lines, compact_separator)); | |
|
Evan Stade
2014/05/14 02:36:36
you'll have to move this to ~L581 and do the opera
Evan Stade
2014/05/22 18:14:23
^
groby-ooo-7-16
2014/05/22 22:54:46
Done.
| |
| 647 } | |
| 648 | |
| 636 // No icons for profile suggestions. | 649 // No icons for profile suggestions. |
| 637 icons->resize(values->size()); | 650 icons->resize(values->size()); |
| 638 } | 651 } |
| 639 | 652 |
| 640 void PersonalDataManager::GetCreditCardSuggestions( | 653 void PersonalDataManager::GetCreditCardSuggestions( |
| 641 const AutofillType& type, | 654 const AutofillType& type, |
| 642 const base::string16& field_contents, | 655 const base::string16& field_contents, |
| 643 std::vector<base::string16>* values, | 656 std::vector<base::string16>* values, |
| 644 std::vector<base::string16>* labels, | 657 std::vector<base::string16>* labels, |
| 645 std::vector<base::string16>* icons, | 658 std::vector<base::string16>* icons, |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1072 | 1085 |
| 1073 return std::string(); | 1086 return std::string(); |
| 1074 } | 1087 } |
| 1075 | 1088 |
| 1076 void PersonalDataManager::EnabledPrefChanged() { | 1089 void PersonalDataManager::EnabledPrefChanged() { |
| 1077 default_country_code_.clear(); | 1090 default_country_code_.clear(); |
| 1078 NotifyPersonalDataChanged(); | 1091 NotifyPersonalDataChanged(); |
| 1079 } | 1092 } |
| 1080 | 1093 |
| 1081 } // namespace autofill | 1094 } // namespace autofill |
| OLD | NEW |