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_util.h" | 16 #include "base/strings/string_util.h" |
17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
18 #include "components/autofill/core/browser/autofill-inl.h" | 18 #include "components/autofill/core/browser/autofill-inl.h" |
19 #include "components/autofill/core/browser/autofill_country.h" | 19 #include "components/autofill/core/browser/autofill_country.h" |
20 #include "components/autofill/core/browser/autofill_field.h" | 20 #include "components/autofill/core/browser/autofill_field.h" |
21 #include "components/autofill/core/browser/form_structure.h" | 21 #include "components/autofill/core/browser/form_structure.h" |
22 #include "components/autofill/core/browser/personal_data_manager_observer.h" | 22 #include "components/autofill/core/browser/personal_data_manager_observer.h" |
23 #include "components/autofill/core/browser/phone_number.h" | 23 #include "components/autofill/core/browser/phone_number.h" |
24 #include "components/autofill/core/browser/phone_number_i18n.h" | 24 #include "components/autofill/core/browser/phone_number_i18n.h" |
25 #include "components/autofill/core/browser/validation.h" | 25 #include "components/autofill/core/browser/validation.h" |
26 #include "components/autofill/core/common/autofill_pref_names.h" | 26 #include "components/autofill/core/common/autofill_pref_names.h" |
27 #include "third_party/libaddressinput/chromium/cpp/src/region_data_constants.h" | |
28 | |
29 using ::i18n::addressinput::RegionDataConstants; | |
27 | 30 |
28 namespace autofill { | 31 namespace autofill { |
29 namespace { | 32 namespace { |
30 | 33 |
31 const base::string16::value_type kCreditCardPrefix[] = {'*', 0}; | 34 const base::string16::value_type kCreditCardPrefix[] = {'*', 0}; |
32 | 35 |
33 template<typename T> | 36 template<typename T> |
34 class FormGroupMatchesByGUIDFunctor { | 37 class FormGroupMatchesByGUIDFunctor { |
35 public: | 38 public: |
36 explicit FormGroupMatchesByGUIDFunctor(const std::string& guid) | 39 explicit FormGroupMatchesByGUIDFunctor(const std::string& guid) |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
559 const std::vector<AutofillProfile*>& profiles = GetProfiles(true); | 562 const std::vector<AutofillProfile*>& profiles = GetProfiles(true); |
560 std::vector<AutofillProfile*> matched_profiles; | 563 std::vector<AutofillProfile*> matched_profiles; |
561 for (std::vector<AutofillProfile*>::const_iterator iter = profiles.begin(); | 564 for (std::vector<AutofillProfile*>::const_iterator iter = profiles.begin(); |
562 iter != profiles.end(); ++iter) { | 565 iter != profiles.end(); ++iter) { |
563 AutofillProfile* profile = *iter; | 566 AutofillProfile* profile = *iter; |
564 | 567 |
565 // The value of the stored data for this field type in the |profile|. | 568 // The value of the stored data for this field type in the |profile|. |
566 std::vector<base::string16> multi_values; | 569 std::vector<base::string16> multi_values; |
567 profile->GetMultiInfo(type, app_locale_, &multi_values); | 570 profile->GetMultiInfo(type, app_locale_, &multi_values); |
568 | 571 |
572 // Names need to be in vertically compact form - i.e. a single line. Join | |
573 // multi-line addresses into a single line, using a separator. | |
574 // The separator is locale-specific. | |
575 base::string16 compact_separator = | |
576 base::UTF8ToUTF16(RegionDataConstants::GetLanguageCompactLineSeparator( | |
577 profile->language_code())); | |
569 for (size_t i = 0; i < multi_values.size(); ++i) { | 578 for (size_t i = 0; i < multi_values.size(); ++i) { |
579 // Create vertically compact form. | |
580 base::ReplaceChars(multi_values[i], | |
581 base::UTF8ToUTF16("\n"), | |
Evan Stade
2014/07/10 20:25:03
nit: ASCIIToUTF16
groby-ooo-7-16
2014/07/11 19:30:30
Done.
| |
582 compact_separator, | |
583 &multi_values[i]); | |
570 if (!field_is_autofilled) { | 584 if (!field_is_autofilled) { |
571 // Suggest data that starts with what the user has typed. | 585 // Suggest data that starts with what the user has typed. |
572 if (!multi_values[i].empty() && | 586 if (!multi_values[i].empty() && |
573 StartsWith(multi_values[i], field_contents, false) && | 587 StartsWith(multi_values[i], field_contents, false) && |
574 (filter.is_null() || filter.Run(*profile))) { | 588 (filter.is_null() || filter.Run(*profile))) { |
575 matched_profiles.push_back(profile); | 589 matched_profiles.push_back(profile); |
576 values->push_back(multi_values[i]); | 590 values->push_back(multi_values[i]); |
577 guid_pairs->push_back(GUIDPair(profile->guid(), i)); | 591 guid_pairs->push_back(GUIDPair(profile->guid(), i)); |
578 } | 592 } |
579 } else { | 593 } else { |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1081 // Populates |auxiliary_profiles_|. | 1095 // Populates |auxiliary_profiles_|. |
1082 LoadAuxiliaryProfiles(record_metrics); | 1096 LoadAuxiliaryProfiles(record_metrics); |
1083 | 1097 |
1084 profiles_.insert(profiles_.end(), web_profiles_.begin(), web_profiles_.end()); | 1098 profiles_.insert(profiles_.end(), web_profiles_.begin(), web_profiles_.end()); |
1085 profiles_.insert( | 1099 profiles_.insert( |
1086 profiles_.end(), auxiliary_profiles_.begin(), auxiliary_profiles_.end()); | 1100 profiles_.end(), auxiliary_profiles_.begin(), auxiliary_profiles_.end()); |
1087 return profiles_; | 1101 return profiles_; |
1088 } | 1102 } |
1089 | 1103 |
1090 } // namespace autofill | 1104 } // namespace autofill |
OLD | NEW |