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" | 27 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_fo
rmatter.h" |
28 | |
29 using ::i18n::addressinput::RegionDataConstants; | |
30 | 28 |
31 namespace autofill { | 29 namespace autofill { |
32 namespace { | 30 namespace { |
33 | 31 |
34 const base::string16::value_type kCreditCardPrefix[] = {'*', 0}; | 32 const base::string16::value_type kCreditCardPrefix[] = {'*', 0}; |
35 | 33 |
36 template<typename T> | 34 template<typename T> |
37 class FormGroupMatchesByGUIDFunctor { | 35 class FormGroupMatchesByGUIDFunctor { |
38 public: | 36 public: |
39 explicit FormGroupMatchesByGUIDFunctor(const std::string& guid) | 37 explicit FormGroupMatchesByGUIDFunctor(const std::string& guid) |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 AutofillProfile* profile = *iter; | 564 AutofillProfile* profile = *iter; |
567 | 565 |
568 // The value of the stored data for this field type in the |profile|. | 566 // The value of the stored data for this field type in the |profile|. |
569 std::vector<base::string16> multi_values; | 567 std::vector<base::string16> multi_values; |
570 profile->GetMultiInfo(type, app_locale_, &multi_values); | 568 profile->GetMultiInfo(type, app_locale_, &multi_values); |
571 | 569 |
572 // Names need to be in vertically compact form - i.e. a single line. Join | 570 // 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. | 571 // multi-line addresses into a single line, using a separator. |
574 // The separator is locale-specific. | 572 // The separator is locale-specific. |
575 base::string16 compact_separator = | 573 base::string16 compact_separator = |
576 base::UTF8ToUTF16(RegionDataConstants::GetLanguageCompactLineSeparator( | 574 base::UTF8ToUTF16(::i18n::addressinput::GetLineSeparatorForLanguage( |
577 profile->language_code())); | 575 profile->language_code())); |
578 for (size_t i = 0; i < multi_values.size(); ++i) { | 576 for (size_t i = 0; i < multi_values.size(); ++i) { |
579 // Create vertically compact form. | 577 // Create vertically compact form. |
580 base::ReplaceChars(multi_values[i], | 578 base::ReplaceChars(multi_values[i], |
581 base::ASCIIToUTF16("\n"), | 579 base::ASCIIToUTF16("\n"), |
582 compact_separator, | 580 compact_separator, |
583 &multi_values[i]); | 581 &multi_values[i]); |
584 if (!field_is_autofilled) { | 582 if (!field_is_autofilled) { |
585 // Suggest data that starts with what the user has typed. | 583 // Suggest data that starts with what the user has typed. |
586 if (!multi_values[i].empty() && | 584 if (!multi_values[i].empty() && |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 // Populates |auxiliary_profiles_|. | 1093 // Populates |auxiliary_profiles_|. |
1096 LoadAuxiliaryProfiles(record_metrics); | 1094 LoadAuxiliaryProfiles(record_metrics); |
1097 | 1095 |
1098 profiles_.insert(profiles_.end(), web_profiles_.begin(), web_profiles_.end()); | 1096 profiles_.insert(profiles_.end(), web_profiles_.begin(), web_profiles_.end()); |
1099 profiles_.insert( | 1097 profiles_.insert( |
1100 profiles_.end(), auxiliary_profiles_.begin(), auxiliary_profiles_.end()); | 1098 profiles_.end(), auxiliary_profiles_.begin(), auxiliary_profiles_.end()); |
1101 return profiles_; | 1099 return profiles_; |
1102 } | 1100 } |
1103 | 1101 |
1104 } // namespace autofill | 1102 } // namespace autofill |
OLD | NEW |