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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (C) 2013 Google Inc. 1 // Copyright (C) 2013 Google Inc.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 case DEPENDENT_LOCALITY: 369 case DEPENDENT_LOCALITY:
370 return IDS_LIBADDRESSINPUT_I18N_INVALID_DEPENDENT_LOCALITY_LABEL; 370 return IDS_LIBADDRESSINPUT_I18N_INVALID_DEPENDENT_LOCALITY_LABEL;
371 case POSTAL_CODE: 371 case POSTAL_CODE:
372 return invalid_postal_code_message_id_; 372 return invalid_postal_code_message_id_;
373 default: 373 default:
374 return IDS_LIBADDRESSINPUT_I18N_INVALID_ENTRY; 374 return IDS_LIBADDRESSINPUT_I18N_INVALID_ENTRY;
375 } 375 }
376 } 376 }
377 377
378 bool Rule::CanonicalizeSubKey(const std::string& user_input, 378 bool Rule::CanonicalizeSubKey(const std::string& user_input,
379 bool canonicalize_latin_name,
379 std::string* sub_key) const { 380 std::string* sub_key) const {
380 if (sub_keys_.empty()) { 381 if (sub_keys_.empty()) {
381 *sub_key = user_input; 382 *sub_key = user_input;
382 return true; 383 return true;
383 } 384 }
384 385
385 return GetMatchingSubKey(user_input, sub_keys_, sub_key) || 386 return GetMatchingSubKey(user_input, sub_keys_, sub_key) ||
386 GetMatchingSubKey(user_input, sub_names_, sub_key) || 387 GetMatchingSubKey(user_input, sub_names_, sub_key) ||
387 GetMatchingSubKey(user_input, sub_lnames_, sub_key); 388 GetMatchingSubKey(user_input, sub_lnames_,
389 canonicalize_latin_name ? sub_key : NULL);
388 } 390 }
389 391
390 bool Rule::GetMatchingSubKey(const std::string& target, 392 bool Rule::GetMatchingSubKey(const std::string& target,
391 const std::vector<std::string>& values, 393 const std::vector<std::string>& values,
392 std::string* sub_key) const { 394 std::string* sub_key) const {
393 for (size_t i = 0; i < values.size(); ++i) { 395 for (size_t i = 0; i < values.size(); ++i) {
394 if (LooseStringCompare(values[i], target)) { 396 if (LooseStringCompare(values[i], target)) {
395 *sub_key = sub_keys_[i]; 397 if (sub_key != NULL) {
398 *sub_key = sub_keys_[i];
399 }
396 return true; 400 return true;
397 } 401 }
398 } 402 }
399 return false; 403 return false;
400 } 404 }
401 405
402 } // namespace addressinput 406 } // namespace addressinput
403 } // namespace i18n 407 } // namespace i18n
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698