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

Side by Side Diff: components/autofill/core/browser/phone_number.cc

Issue 1821053002: [Autofill] Disambiguate similar types before uploading. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits Created 4 years, 9 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
« no previous file with comments | « components/autofill/core/browser/personal_data_manager_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "components/autofill/core/browser/phone_number.h" 5 #include "components/autofill/core/browser/phone_number.h"
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "components/autofill/core/browser/autofill_country.h" 10 #include "components/autofill/core/browser/autofill_country.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 if (matching_types->find(PHONE_HOME_WHOLE_NUMBER) == matching_types->end()) { 182 if (matching_types->find(PHONE_HOME_WHOLE_NUMBER) == matching_types->end()) {
183 base::string16 whole_number = 183 base::string16 whole_number =
184 GetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER), app_locale); 184 GetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER), app_locale);
185 if (!whole_number.empty()) { 185 if (!whole_number.empty()) {
186 base::string16 normalized_number = 186 base::string16 normalized_number =
187 i18n::NormalizePhoneNumber(text, GetRegion(*profile_, app_locale)); 187 i18n::NormalizePhoneNumber(text, GetRegion(*profile_, app_locale));
188 if (normalized_number == whole_number) 188 if (normalized_number == whole_number)
189 matching_types->insert(PHONE_HOME_WHOLE_NUMBER); 189 matching_types->insert(PHONE_HOME_WHOLE_NUMBER);
190 } 190 }
191 } 191 }
192
193 // If both PHONE_HOME_CITY_AND_NUMBER and PHONE_HOME_WHOLE_NUMBER are matched,
194 // it means there is no country code in the profile's phone number. In that
195 // case, we should only return PHONE_HOME_CITY_AND_NUMBER because it's more
196 // precise.
197 ServerFieldTypeSet::iterator whole_number_iterator =
198 matching_types->find(PHONE_HOME_WHOLE_NUMBER);
199 if (whole_number_iterator != matching_types->end() &&
200 matching_types->find(PHONE_HOME_CITY_AND_NUMBER) !=
201 matching_types->end()) {
202 matching_types->erase(whole_number_iterator);
203 }
204 } 192 }
205 193
206 void PhoneNumber::UpdateCacheIfNeeded(const std::string& app_locale) const { 194 void PhoneNumber::UpdateCacheIfNeeded(const std::string& app_locale) const {
207 std::string region = GetRegion(*profile_, app_locale); 195 std::string region = GetRegion(*profile_, app_locale);
208 if (!number_.empty() && cached_parsed_phone_.region() != region) 196 if (!number_.empty() && cached_parsed_phone_.region() != region)
209 cached_parsed_phone_ = i18n::PhoneObject(number_, region); 197 cached_parsed_phone_ = i18n::PhoneObject(number_, region);
210 } 198 }
211 199
212 PhoneNumber::PhoneCombineHelper::PhoneCombineHelper() { 200 PhoneNumber::PhoneCombineHelper::PhoneCombineHelper() {
213 } 201 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 248
261 return i18n::ConstructPhoneNumber( 249 return i18n::ConstructPhoneNumber(
262 country_, city_, phone_, GetRegion(profile, app_locale), value); 250 country_, city_, phone_, GetRegion(profile, app_locale), value);
263 } 251 }
264 252
265 bool PhoneNumber::PhoneCombineHelper::IsEmpty() const { 253 bool PhoneNumber::PhoneCombineHelper::IsEmpty() const {
266 return phone_.empty() && whole_number_.empty(); 254 return phone_.empty() && whole_number_.empty();
267 } 255 }
268 256
269 } // namespace autofill 257 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/personal_data_manager_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698