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 // Populates default autofill profile from user's own Android contact. | 5 // Populates default autofill profile from user's own Android contact. |
6 #include "components/autofill/browser/android/auxiliary_profiles_android.h" | 6 #include "components/autofill/browser/android/auxiliary_profiles_android.h" |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/guid.h" | 10 #include "base/guid.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 accumulator.push_back(neighborhood); | 42 accumulator.push_back(neighborhood); |
43 | 43 |
44 return JoinString(accumulator, ASCIIToUTF16(", ")); | 44 return JoinString(accumulator, ASCIIToUTF16(", ")); |
45 } | 45 } |
46 | 46 |
47 } // namespace | 47 } // namespace |
48 | 48 |
49 namespace autofill { | 49 namespace autofill { |
50 | 50 |
51 AuxiliaryProfilesAndroid::AuxiliaryProfilesAndroid( | 51 AuxiliaryProfilesAndroid::AuxiliaryProfilesAndroid( |
52 const AuxiliaryProfileLoaderAndroid& profileLoader) | 52 const AuxiliaryProfileLoaderAndroid& profileLoader, |
53 : profile_loader_(profileLoader) {} | 53 const std::string& app_locale) |
| 54 : profile_loader_(profileLoader), |
| 55 app_locale_(app_locale) {} |
54 | 56 |
55 AuxiliaryProfilesAndroid::~AuxiliaryProfilesAndroid() { | 57 AuxiliaryProfilesAndroid::~AuxiliaryProfilesAndroid() { |
56 } | 58 } |
57 | 59 |
58 scoped_ptr<AutofillProfile> AuxiliaryProfilesAndroid::LoadContactsProfile() { | 60 scoped_ptr<AutofillProfile> AuxiliaryProfilesAndroid::LoadContactsProfile() { |
59 scoped_ptr<AutofillProfile> profile(new AutofillProfile(kAndroidMeContactA)); | 61 scoped_ptr<AutofillProfile> profile(new AutofillProfile(kAndroidMeContactA)); |
60 LoadName(profile.get()); | 62 LoadName(profile.get()); |
61 LoadEmailAddress(profile.get()); | 63 LoadEmailAddress(profile.get()); |
62 LoadPhoneNumbers(profile.get()); | 64 LoadPhoneNumbers(profile.get()); |
63 | 65 |
(...skipping 16 matching lines...) Expand all Loading... |
80 string16 region = profile_loader_.GetRegion(); | 82 string16 region = profile_loader_.GetRegion(); |
81 string16 country = profile_loader_.GetCountry(); | 83 string16 country = profile_loader_.GetCountry(); |
82 | 84 |
83 string16 street2 = CollapseAddress(post_office_box, neighborhood); | 85 string16 street2 = CollapseAddress(post_office_box, neighborhood); |
84 | 86 |
85 profile->SetRawInfo(ADDRESS_HOME_LINE1, street); | 87 profile->SetRawInfo(ADDRESS_HOME_LINE1, street); |
86 profile->SetRawInfo(ADDRESS_HOME_LINE2, street2); | 88 profile->SetRawInfo(ADDRESS_HOME_LINE2, street2); |
87 profile->SetRawInfo(ADDRESS_HOME_CITY, city); | 89 profile->SetRawInfo(ADDRESS_HOME_CITY, city); |
88 profile->SetRawInfo(ADDRESS_HOME_STATE, region); | 90 profile->SetRawInfo(ADDRESS_HOME_STATE, region); |
89 profile->SetRawInfo(ADDRESS_HOME_ZIP, postal_code); | 91 profile->SetRawInfo(ADDRESS_HOME_ZIP, postal_code); |
90 profile->SetRawInfo(ADDRESS_HOME_COUNTRY, country); | 92 profile->SetInfo(ADDRESS_HOME_COUNTRY, country, app_locale_); |
91 } | 93 } |
92 | 94 |
93 void AuxiliaryProfilesAndroid::LoadName(AutofillProfile* profile) { | 95 void AuxiliaryProfilesAndroid::LoadName(AutofillProfile* profile) { |
94 string16 first_name = profile_loader_.GetFirstName(); | 96 string16 first_name = profile_loader_.GetFirstName(); |
95 string16 middle_name = profile_loader_.GetMiddleName(); | 97 string16 middle_name = profile_loader_.GetMiddleName(); |
96 string16 last_name = profile_loader_.GetLastName(); | 98 string16 last_name = profile_loader_.GetLastName(); |
97 | 99 |
98 profile->SetRawInfo(NAME_FIRST, first_name); | 100 profile->SetRawInfo(NAME_FIRST, first_name); |
99 profile->SetRawInfo(NAME_MIDDLE, middle_name); | 101 profile->SetRawInfo(NAME_MIDDLE, middle_name); |
100 profile->SetRawInfo(NAME_LAST, last_name); | 102 profile->SetRawInfo(NAME_LAST, last_name); |
101 } | 103 } |
102 | 104 |
103 void AuxiliaryProfilesAndroid::LoadEmailAddress(AutofillProfile* profile) { | 105 void AuxiliaryProfilesAndroid::LoadEmailAddress(AutofillProfile* profile) { |
104 std::vector<string16> emails; | 106 std::vector<string16> emails; |
105 profile_loader_.GetEmailAddresses(&emails); | 107 profile_loader_.GetEmailAddresses(&emails); |
106 profile->SetRawMultiInfo(EMAIL_ADDRESS, emails); | 108 profile->SetRawMultiInfo(EMAIL_ADDRESS, emails); |
107 } | 109 } |
108 | 110 |
109 void AuxiliaryProfilesAndroid::LoadPhoneNumbers(AutofillProfile* profile) { | 111 void AuxiliaryProfilesAndroid::LoadPhoneNumbers(AutofillProfile* profile) { |
110 std::vector<string16> phone_numbers; | 112 std::vector<string16> phone_numbers; |
111 profile_loader_.GetPhoneNumbers(&phone_numbers); | 113 profile_loader_.GetPhoneNumbers(&phone_numbers); |
112 profile->SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, phone_numbers); | 114 profile->SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, phone_numbers); |
113 } | 115 } |
114 | 116 |
115 } // namespace autofill | 117 } // namespace autofill |
OLD | NEW |