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

Unified Diff: components/autofill/core/browser/autofill_data_util.cc

Issue 2829903004: Reland: Normalize shipping address for merchant on Desktop. (Closed)
Patch Set: Make android code use the new impl Created 3 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: components/autofill/core/browser/autofill_data_util.cc
diff --git a/components/autofill/core/browser/autofill_data_util.cc b/components/autofill/core/browser/autofill_data_util.cc
index f55ec9068c50c8a04a02587a1910cff55dea3ced..d7fff0d9e486cec37aa8f6ea20da0641c17f6eb2 100644
--- a/components/autofill/core/browser/autofill_data_util.cc
+++ b/components/autofill/core/browser/autofill_data_util.cc
@@ -14,6 +14,7 @@
#include "components/autofill/core/browser/field_types.h"
#include "components/grit/components_scaled_resources.h"
#include "third_party/icu/source/common/unicode/uscript.h"
+#include "third_party/re2/src/re2/re2.h"
namespace autofill {
namespace data_util {
@@ -419,5 +420,16 @@ const char* GetCardTypeForBasicCardPaymentType(
return kGenericPaymentRequestData.card_type;
}
+bool IsValidCountryCode(const std::string& country_code) {
+ if (country_code.size() != 2)
+ return false;
+
+ return re2::RE2::FullMatch(country_code, "^[A-Z]{2}$");
+}
+
+bool IsValidCountryCode(const base::string16& country_code) {
+ return IsValidCountryCode(base::UTF16ToUTF8(country_code));
+}
+
} // namespace data_util
} // namespace autofill
« no previous file with comments | « components/autofill/core/browser/autofill_data_util.h ('k') | components/autofill/core/browser/autofill_data_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698