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

Side by Side Diff: third_party/libaddressinput/chromium/chrome_address_validator.cc

Issue 2338283003: [Payments] Normalize addresses before passing them to merchants. (Closed)
Patch Set: Created 4 years, 3 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "third_party/libaddressinput/chromium/chrome_address_validator.h" 5 #include "third_party/libaddressinput/chromium/chrome_address_validator.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 105
106 if (focused_field == POSTAL_CODE || 106 if (focused_field == POSTAL_CODE ||
107 (focused_field >= ADMIN_AREA && focused_field <= DEPENDENT_LOCALITY)) { 107 (focused_field >= ADMIN_AREA && focused_field <= DEPENDENT_LOCALITY)) {
108 input_suggester_->GetSuggestions( 108 input_suggester_->GetSuggestions(
109 user_input, focused_field, suggestion_limit, suggestions); 109 user_input, focused_field, suggestion_limit, suggestions);
110 } 110 }
111 111
112 return SUCCESS; 112 return SUCCESS;
113 } 113 }
114 114
115 bool AddressValidator::CanonicalizeAdministrativeArea( 115 bool AddressValidator::NormalizeAddress(AddressData* address) const {
116 AddressData* address) const {
117 if (!supplier_->IsLoaded(address->region_code)) 116 if (!supplier_->IsLoaded(address->region_code))
118 return false; 117 return false;
119 118
120 // TODO: It would probably be beneficial to use the full canonicalization. 119 // TODO: It would probably be beneficial to use the full canonicalization.
121 AddressData tmp(*address); 120 AddressData tmp(*address);
122 normalizer_->Normalize(&tmp); 121 normalizer_->Normalize(&tmp);
123 address->administrative_area = tmp.administrative_area; 122 address->administrative_area = tmp.administrative_area;
123 address->locality = tmp.locality;
please use gerrit instead 2016/09/16 22:30:42 dedepdent_locality as well
sebsg 2016/09/22 19:50:41 Done.
124 124
125 return true; 125 return true;
126 } 126 }
127 127
128 AddressValidator::AddressValidator() 128 AddressValidator::AddressValidator()
129 : load_rules_listener_(NULL), weak_factory_(this) {} 129 : load_rules_listener_(NULL), weak_factory_(this) {}
130 130
131 base::TimeDelta AddressValidator::GetBaseRetryPeriod() const { 131 base::TimeDelta AddressValidator::GetBaseRetryPeriod() const {
132 return base::TimeDelta::FromSeconds(8); 132 return base::TimeDelta::FromSeconds(8);
133 } 133 }
(...skipping 19 matching lines...) Expand all
153 weak_factory_.GetWeakPtr(), region_code), 153 weak_factory_.GetWeakPtr(), region_code),
154 GetBaseRetryPeriod() * pow(2, attempts_number_[region_code]++)); 154 GetBaseRetryPeriod() * pow(2, attempts_number_[region_code]++));
155 } 155 }
156 156
157 void AddressValidator::RetryLoadRules(const std::string& region_code) { 157 void AddressValidator::RetryLoadRules(const std::string& region_code) {
158 // Do not reset retry count. 158 // Do not reset retry count.
159 supplier_->LoadRules(region_code, *rules_loaded_); 159 supplier_->LoadRules(region_code, *rules_loaded_);
160 } 160 }
161 161
162 } // namespace autofill 162 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698