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