Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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)) |
|
please use gerrit instead
2016/09/23 09:04:41
If you expose supplier_->IsLoaded(region_code) thr
sebsg
2016/09/27 18:48:38
Done.
| |
| 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; | |
| 124 address->dependent_locality = tmp.dependent_locality; | |
|
please use gerrit instead
2016/09/23 09:04:41
You can simplify lines 119-124 now:
normalizer_->
sebsg
2016/09/27 18:48:38
Done.
| |
| 124 | 125 |
| 125 return true; | 126 return true; |
| 126 } | 127 } |
| 127 | 128 |
| 128 AddressValidator::AddressValidator() | 129 AddressValidator::AddressValidator() |
| 129 : load_rules_listener_(NULL), weak_factory_(this) {} | 130 : load_rules_listener_(NULL), weak_factory_(this) {} |
| 130 | 131 |
| 131 base::TimeDelta AddressValidator::GetBaseRetryPeriod() const { | 132 base::TimeDelta AddressValidator::GetBaseRetryPeriod() const { |
| 132 return base::TimeDelta::FromSeconds(8); | 133 return base::TimeDelta::FromSeconds(8); |
| 133 } | 134 } |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 153 weak_factory_.GetWeakPtr(), region_code), | 154 weak_factory_.GetWeakPtr(), region_code), |
| 154 GetBaseRetryPeriod() * pow(2, attempts_number_[region_code]++)); | 155 GetBaseRetryPeriod() * pow(2, attempts_number_[region_code]++)); |
| 155 } | 156 } |
| 156 | 157 |
| 157 void AddressValidator::RetryLoadRules(const std::string& region_code) { | 158 void AddressValidator::RetryLoadRules(const std::string& region_code) { |
| 158 // Do not reset retry count. | 159 // Do not reset retry count. |
| 159 supplier_->LoadRules(region_code, *rules_loaded_); | 160 supplier_->LoadRules(region_code, *rules_loaded_); |
| 160 } | 161 } |
| 161 | 162 |
| 162 } // namespace autofill | 163 } // namespace autofill |
| OLD | NEW |