Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: components/autofill/core/browser/android/auxiliary_profiles_android.cc

Issue 22009003: [Autofill] Distinguish between native field types and potentially HTML field types. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/core/browser/android/auxiliary_profiles_android.h" 6 #include "components/autofill/core/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"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/scoped_vector.h" 13 #include "base/memory/scoped_vector.h"
14 #include "base/strings/string16.h" 14 #include "base/strings/string16.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "components/autofill/core/browser/android/auxiliary_profile_loader_andr oid.h" 17 #include "components/autofill/core/browser/android/auxiliary_profile_loader_andr oid.h"
18 #include "components/autofill/core/browser/autofill_profile.h" 18 #include "components/autofill/core/browser/autofill_profile.h"
19 #include "components/autofill/core/browser/autofill_type.h"
19 #include "components/autofill/core/browser/phone_number.h" 20 #include "components/autofill/core/browser/phone_number.h"
20 21
21 // Generates the autofill profile by accessing the Android 22 // Generates the autofill profile by accessing the Android
22 // ContactsContract.Profile API through PersonalAutofillPopulator via JNI. 23 // ContactsContract.Profile API through PersonalAutofillPopulator via JNI.
23 // The generated profile corresponds to the user's "ME" contact in the 24 // The generated profile corresponds to the user's "ME" contact in the
24 // "People" app. The caller passes a vector of profiles into the constructor 25 // "People" app. The caller passes a vector of profiles into the constructor
25 // then initiates a fetch using |GetContactsProfile()| method. This clears 26 // then initiates a fetch using |GetContactsProfile()| method. This clears
26 // any existing addresses. 27 // any existing addresses.
27 28
28 // Randomly generated guid. The Autofillprofile class requires a consistent 29 // Randomly generated guid. The Autofillprofile class requires a consistent
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 base::string16 region = profile_loader_.GetRegion(); 87 base::string16 region = profile_loader_.GetRegion();
87 base::string16 country = profile_loader_.GetCountry(); 88 base::string16 country = profile_loader_.GetCountry();
88 89
89 base::string16 street2 = CollapseAddress(post_office_box, neighborhood); 90 base::string16 street2 = CollapseAddress(post_office_box, neighborhood);
90 91
91 profile->SetRawInfo(ADDRESS_HOME_LINE1, street); 92 profile->SetRawInfo(ADDRESS_HOME_LINE1, street);
92 profile->SetRawInfo(ADDRESS_HOME_LINE2, street2); 93 profile->SetRawInfo(ADDRESS_HOME_LINE2, street2);
93 profile->SetRawInfo(ADDRESS_HOME_CITY, city); 94 profile->SetRawInfo(ADDRESS_HOME_CITY, city);
94 profile->SetRawInfo(ADDRESS_HOME_STATE, region); 95 profile->SetRawInfo(ADDRESS_HOME_STATE, region);
95 profile->SetRawInfo(ADDRESS_HOME_ZIP, postal_code); 96 profile->SetRawInfo(ADDRESS_HOME_ZIP, postal_code);
96 profile->SetInfo(ADDRESS_HOME_COUNTRY, country, app_locale_); 97 profile->SetInfo(AutofillType(ADDRESS_HOME_COUNTRY), country, app_locale_);
97 } 98 }
98 99
99 void AuxiliaryProfilesAndroid::LoadName(AutofillProfile* profile) { 100 void AuxiliaryProfilesAndroid::LoadName(AutofillProfile* profile) {
100 base::string16 first_name = profile_loader_.GetFirstName(); 101 base::string16 first_name = profile_loader_.GetFirstName();
101 base::string16 middle_name = profile_loader_.GetMiddleName(); 102 base::string16 middle_name = profile_loader_.GetMiddleName();
102 base::string16 last_name = profile_loader_.GetLastName(); 103 base::string16 last_name = profile_loader_.GetLastName();
103 104
104 profile->SetRawInfo(NAME_FIRST, first_name); 105 profile->SetRawInfo(NAME_FIRST, first_name);
105 profile->SetRawInfo(NAME_MIDDLE, middle_name); 106 profile->SetRawInfo(NAME_MIDDLE, middle_name);
106 profile->SetRawInfo(NAME_LAST, last_name); 107 profile->SetRawInfo(NAME_LAST, last_name);
107 } 108 }
108 109
109 void AuxiliaryProfilesAndroid::LoadEmailAddress(AutofillProfile* profile) { 110 void AuxiliaryProfilesAndroid::LoadEmailAddress(AutofillProfile* profile) {
110 std::vector<base::string16> emails; 111 std::vector<base::string16> emails;
111 profile_loader_.GetEmailAddresses(&emails); 112 profile_loader_.GetEmailAddresses(&emails);
112 profile->SetRawMultiInfo(EMAIL_ADDRESS, emails); 113 profile->SetRawMultiInfo(EMAIL_ADDRESS, emails);
113 } 114 }
114 115
115 void AuxiliaryProfilesAndroid::LoadPhoneNumbers(AutofillProfile* profile) { 116 void AuxiliaryProfilesAndroid::LoadPhoneNumbers(AutofillProfile* profile) {
116 std::vector<base::string16> phone_numbers; 117 std::vector<base::string16> phone_numbers;
117 profile_loader_.GetPhoneNumbers(&phone_numbers); 118 profile_loader_.GetPhoneNumbers(&phone_numbers);
118 profile->SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, phone_numbers); 119 profile->SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, phone_numbers);
119 } 120 }
120 121
121 } // namespace autofill 122 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/address_unittest.cc ('k') | components/autofill/core/browser/autofill_common_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698