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 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 571 const std::vector<AutofillProfile*>& profiles = GetProfiles(); | 573 const std::vector<AutofillProfile*>& profiles = GetProfiles(); |
| 572 std::vector<AutofillProfile*> matched_profiles; | 574 std::vector<AutofillProfile*> matched_profiles; |
| 573 for (std::vector<AutofillProfile*>::const_iterator iter = profiles.begin(); | 575 for (std::vector<AutofillProfile*>::const_iterator iter = profiles.begin(); |
| 574 iter != profiles.end(); ++iter) { | 576 iter != profiles.end(); ++iter) { |
| 575 AutofillProfile* profile = *iter; | 577 AutofillProfile* profile = *iter; |
| 576 | 578 |
| 577 // The value of the stored data for this field type in the |profile|. | 579 // The value of the stored data for this field type in the |profile|. |
| 578 std::vector<base::string16> multi_values; | 580 std::vector<base::string16> multi_values; |
| 579 profile->GetMultiInfo(type, app_locale_, &multi_values); | 581 profile->GetMultiInfo(type, app_locale_, &multi_values); |
| 580 | 582 |
| 583 // Names need to be in vertically compact form - i.e. a single line. Join | |
| 584 // multi-line names into a single line, using a separator. | |
|
Ilya Sherman
2014/05/23 10:05:05
nit: "names" -> "addresses"?
groby-ooo-7-16
2014/07/10 02:59:14
Done.
| |
| 585 // The separator is locale-specific. | |
| 586 base::string16 compact_separator = base::UTF8ToUTF16( | |
| 587 ::i18n::addressinput::GetCompactAddressLinesSeparator(app_locale_)); | |
|
Evan Stade
2014/05/22 23:41:28
not |app_locale_|. profile->language_code().
groby-ooo-7-16
2014/07/10 02:59:14
Done.
| |
| 588 | |
| 581 for (size_t i = 0; i < multi_values.size(); ++i) { | 589 for (size_t i = 0; i < multi_values.size(); ++i) { |
| 590 // Create vertically compact form. | |
| 591 std::vector<base::string16> lines; | |
| 592 base::SplitString((*values)[i], '\n', &lines); | |
| 593 (*values)[i] = JoinString(lines, compact_separator); | |
| 594 | |
| 582 if (!field_is_autofilled) { | 595 if (!field_is_autofilled) { |
| 583 // Suggest data that starts with what the user has typed. | 596 // Suggest data that starts with what the user has typed. |
| 584 if (!multi_values[i].empty() && | 597 if (!multi_values[i].empty() && |
| 585 StartsWith(multi_values[i], field_contents, false) && | 598 StartsWith(multi_values[i], field_contents, false) && |
| 586 (filter.is_null() || filter.Run(*profile))) { | 599 (filter.is_null() || filter.Run(*profile))) { |
| 587 matched_profiles.push_back(profile); | 600 matched_profiles.push_back(profile); |
| 588 values->push_back(multi_values[i]); | 601 values->push_back(multi_values[i]); |
| 589 guid_pairs->push_back(GUIDPair(profile->guid(), i)); | 602 guid_pairs->push_back(GUIDPair(profile->guid(), i)); |
| 590 } | 603 } |
| 591 } else { | 604 } else { |
| (...skipping 480 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 |