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

Unified Diff: third_party/WebKit/Source/modules/payments/PaymentsValidators.cpp

Issue 1937783002: Provide shipping in PaymentRequest response (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 4 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/WebKit/Source/modules/payments/PaymentsValidators.cpp
diff --git a/third_party/WebKit/Source/modules/payments/PaymentsValidators.cpp b/third_party/WebKit/Source/modules/payments/PaymentsValidators.cpp
index e57a9a4637cb2da2ea444b5f841395fbb8ad05a5..cc6b0cf139657cf52e7fc7eeb226ca79b5aff939 100644
--- a/third_party/WebKit/Source/modules/payments/PaymentsValidators.cpp
+++ b/third_party/WebKit/Source/modules/payments/PaymentsValidators.cpp
@@ -64,4 +64,25 @@ bool PaymentsValidators::isValidScriptCodeFormat(const String& code, String* opt
return false;
}
+bool PaymentsValidators::isValidShippingAddress(const mojom::blink::ShippingAddressPtr& address, String* optionalErrorMessage)
+{
+ if (!isValidRegionCodeFormat(address->region_code, optionalErrorMessage))
+ return false;
+
+ if (!isValidLanguageCodeFormat(address->language_code, optionalErrorMessage))
+ return false;
+
+ if (!isValidScriptCodeFormat(address->script_code, optionalErrorMessage))
+ return false;
+
+ if (address->language_code.isEmpty() && !address->script_code.isEmpty()) {
+ if (optionalErrorMessage)
+ *optionalErrorMessage = "If language code is empty, then script code should also be empty";
+
+ return false;
+ }
+
+ return true;
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698