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

Unified Diff: third_party/libaddressinput/chromium/cpp/src/rule.cc

Issue 237693002: requestAutocomplete should not unlatinize administrative region names. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Canonicalize latinized name without unlatinizing it. Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: third_party/libaddressinput/chromium/cpp/src/rule.cc
diff --git a/third_party/libaddressinput/chromium/cpp/src/rule.cc b/third_party/libaddressinput/chromium/cpp/src/rule.cc
index 791ac9eca651bbba4d68945ffad93ffaafe454c4..dadc1e82a7329fec631ae4b8f265fcb57ae3da3e 100644
--- a/third_party/libaddressinput/chromium/cpp/src/rule.cc
+++ b/third_party/libaddressinput/chromium/cpp/src/rule.cc
@@ -376,7 +376,10 @@ int Rule::GetInvalidFieldMessageId(AddressField field) const {
}
bool Rule::CanonicalizeSubKey(const std::string& user_input,
+ bool canonicalize_latin_name,
Evan Stade 2014/04/16 21:55:46 |canonicalize_latin_name| is not quite optimal imo
please use gerrit instead 2014/04/16 22:53:27 Done.
std::string* sub_key) const {
+ assert(sub_key != NULL);
+
if (sub_keys_.empty()) {
*sub_key = user_input;
return true;
@@ -384,12 +387,15 @@ bool Rule::CanonicalizeSubKey(const std::string& user_input,
return GetMatchingSubKey(user_input, sub_keys_, sub_key) ||
GetMatchingSubKey(user_input, sub_names_, sub_key) ||
- GetMatchingSubKey(user_input, sub_lnames_, sub_key);
+ (canonicalize_latin_name &&
+ GetMatchingSubKey(user_input, sub_lnames_, sub_key)) ||
+ GetMatchingValue(user_input, sub_lnames_, sub_key);
}
bool Rule::GetMatchingSubKey(const std::string& target,
Evan Stade 2014/04/16 21:55:46 seems like GetMatchingSubKey and GetMatchingValue
please use gerrit instead 2014/04/16 22:53:27 Done.
const std::vector<std::string>& values,
std::string* sub_key) const {
+ assert(sub_key != NULL);
for (size_t i = 0; i < values.size(); ++i) {
if (LooseStringCompare(values[i], target)) {
*sub_key = sub_keys_[i];
@@ -399,5 +405,18 @@ bool Rule::GetMatchingSubKey(const std::string& target,
return false;
}
+bool Rule::GetMatchingValue(const std::string& target,
+ const std::vector<std::string>& values,
+ std::string* value) const {
+ assert(value != NULL);
+ for (size_t i = 0; i < values.size(); ++i) {
+ if (LooseStringCompare(values[i], target)) {
+ *value = values[i];
+ return true;
+ }
+ }
+ return false;
+}
+
} // namespace addressinput
} // namespace i18n

Powered by Google App Engine
This is Rietveld 408576698