| Index: components/payments/payments_validators.cc
 | 
| diff --git a/third_party/WebKit/Source/modules/payments/PaymentsValidators.cpp b/components/payments/payments_validators.cc
 | 
| similarity index 56%
 | 
| copy from third_party/WebKit/Source/modules/payments/PaymentsValidators.cpp
 | 
| copy to components/payments/payments_validators.cc
 | 
| index 5b9ddaab2a0f31267e017f5d1d663c13540b8fdd..ddc943d3d2b25201dfc6aeff4eb58ea690ee15fa 100644
 | 
| --- a/third_party/WebKit/Source/modules/payments/PaymentsValidators.cpp
 | 
| +++ b/components/payments/payments_validators.cc
 | 
| @@ -2,23 +2,22 @@
 | 
|  // Use of this source code is governed by a BSD-style license that can be
 | 
|  // found in the LICENSE file.
 | 
|  
 | 
| -#include "modules/payments/PaymentsValidators.h"
 | 
| +#include "components/payments/payments_validators.h"
 | 
|  
 | 
| -#include "bindings/core/v8/ScriptRegexp.h"
 | 
| -#include "platform/weborigin/KURL.h"
 | 
| -#include "wtf/text/StringImpl.h"
 | 
| +#include "third_party/re2/src/re2/re2.h"
 | 
| +#include "url/gurl.h"
 | 
|  
 | 
| -namespace blink {
 | 
| +namespace payments {
 | 
|  
 | 
|  // We limit the maximum length of string to 2048 bytes for security reasons.
 | 
| -static const int maxiumStringLength = 2048;
 | 
| +static const int maximumStringLength = 2048;
 | 
|  
 | 
|  bool PaymentsValidators::isValidCurrencyCodeFormat(
 | 
| -    const String& code,
 | 
| -    const String& system,
 | 
| -    String* optionalErrorMessage) {
 | 
| +    const std::string& code,
 | 
| +    const std::string& system,
 | 
| +    std::string* optionalErrorMessage) {
 | 
|    if (system == "urn:iso:std:iso:4217") {
 | 
| -    if (ScriptRegexp("^[A-Z]{3}$", TextCaseSensitive).match(code) == 0)
 | 
| +    if (RE2::FullMatch(code, "[A-Z]{3}"))
 | 
|        return true;
 | 
|  
 | 
|      if (optionalErrorMessage)
 | 
| @@ -29,27 +28,25 @@ bool PaymentsValidators::isValidCurrencyCodeFormat(
 | 
|      return false;
 | 
|    }
 | 
|  
 | 
| -  if (!KURL(KURL(), system).isValid()) {
 | 
| +  if (code.size() > maximumStringLength) {
 | 
|      if (optionalErrorMessage)
 | 
| -      *optionalErrorMessage = "The currency system is not a valid URL";
 | 
| -
 | 
| +      *optionalErrorMessage =
 | 
| +          "The currency code should be at most 2048 characters long";
 | 
|      return false;
 | 
|    }
 | 
| -
 | 
| -  if (code.length() <= maxiumStringLength)
 | 
| -    return true;
 | 
| -
 | 
| -  if (optionalErrorMessage)
 | 
| -    *optionalErrorMessage =
 | 
| -        "The currency code should be at most 2048 characters long";
 | 
| -
 | 
| -  return false;
 | 
| +  if (!GURL(system).is_valid()) {
 | 
| +    if (optionalErrorMessage)
 | 
| +      *optionalErrorMessage =
 | 
| +          "The system should be a valid URL";
 | 
| +    return false;
 | 
| +  }
 | 
| +  return true;
 | 
|  }
 | 
|  
 | 
| -bool PaymentsValidators::isValidAmountFormat(const String& amount,
 | 
| -                                             String* optionalErrorMessage) {
 | 
| -  if (ScriptRegexp("^-?[0-9]+(\\.[0-9]+)?$", TextCaseSensitive).match(amount) ==
 | 
| -      0)
 | 
| +bool PaymentsValidators::isValidAmountFormat(
 | 
| +    const std::string& amount,
 | 
| +    std::string* optionalErrorMessage) {
 | 
| +  if (RE2::FullMatch(amount, "-?[0-9]+(\\.[0-9]+)?"))
 | 
|      return true;
 | 
|  
 | 
|    if (optionalErrorMessage)
 | 
| @@ -59,9 +56,9 @@ bool PaymentsValidators::isValidAmountFormat(const String& amount,
 | 
|  }
 | 
|  
 | 
|  bool PaymentsValidators::isValidCountryCodeFormat(
 | 
| -    const String& code,
 | 
| -    String* optionalErrorMessage) {
 | 
| -  if (ScriptRegexp("^[A-Z]{2}$", TextCaseSensitive).match(code) == 0)
 | 
| +    const std::string& code,
 | 
| +    std::string* optionalErrorMessage) {
 | 
| +  if (RE2::FullMatch(code, "[A-Z]{2}"))
 | 
|      return true;
 | 
|  
 | 
|    if (optionalErrorMessage)
 | 
| @@ -73,9 +70,9 @@ bool PaymentsValidators::isValidCountryCodeFormat(
 | 
|  }
 | 
|  
 | 
|  bool PaymentsValidators::isValidLanguageCodeFormat(
 | 
| -    const String& code,
 | 
| -    String* optionalErrorMessage) {
 | 
| -  if (ScriptRegexp("^([a-z]{2,3})?$", TextCaseSensitive).match(code) == 0)
 | 
| +    const std::string& code,
 | 
| +    std::string* optionalErrorMessage) {
 | 
| +  if (RE2::FullMatch(code, "([a-z]{2,3})?"))
 | 
|      return true;
 | 
|  
 | 
|    if (optionalErrorMessage)
 | 
| @@ -86,9 +83,10 @@ bool PaymentsValidators::isValidLanguageCodeFormat(
 | 
|    return false;
 | 
|  }
 | 
|  
 | 
| -bool PaymentsValidators::isValidScriptCodeFormat(const String& code,
 | 
| -                                                 String* optionalErrorMessage) {
 | 
| -  if (ScriptRegexp("^([A-Z][a-z]{3})?$", TextCaseSensitive).match(code) == 0)
 | 
| +bool PaymentsValidators::isValidScriptCodeFormat(
 | 
| +    const std::string& code,
 | 
| +    std::string* optionalErrorMessage) {
 | 
| +  if (RE2::FullMatch(code, "([A-Z][a-z]{3})?"))
 | 
|      return true;
 | 
|  
 | 
|    if (optionalErrorMessage)
 | 
| @@ -101,8 +99,8 @@ bool PaymentsValidators::isValidScriptCodeFormat(const String& code,
 | 
|  }
 | 
|  
 | 
|  bool PaymentsValidators::isValidShippingAddress(
 | 
| -    const mojom::blink::PaymentAddressPtr& address,
 | 
| -    String* optionalErrorMessage) {
 | 
| +    const blink::mojom::PaymentAddressPtr& address,
 | 
| +    std::string* optionalErrorMessage) {
 | 
|    if (!isValidCountryCodeFormat(address->country, optionalErrorMessage))
 | 
|      return false;
 | 
|  
 | 
| @@ -112,7 +110,7 @@ bool PaymentsValidators::isValidShippingAddress(
 | 
|    if (!isValidScriptCodeFormat(address->script_code, optionalErrorMessage))
 | 
|      return false;
 | 
|  
 | 
| -  if (address->language_code.isEmpty() && !address->script_code.isEmpty()) {
 | 
| +  if (address->language_code.empty() && !address->script_code.empty()) {
 | 
|      if (optionalErrorMessage)
 | 
|        *optionalErrorMessage =
 | 
|            "If language code is empty, then script code should also be empty";
 | 
| @@ -123,9 +121,10 @@ bool PaymentsValidators::isValidShippingAddress(
 | 
|    return true;
 | 
|  }
 | 
|  
 | 
| -bool PaymentsValidators::isValidErrorMsgFormat(const String& error,
 | 
| -                                               String* optionalErrorMessage) {
 | 
| -  if (error.length() <= maxiumStringLength)
 | 
| +bool PaymentsValidators::isValidErrorMsgFormat(
 | 
| +    const std::string& error,
 | 
| +    std::string* optionalErrorMessage) {
 | 
| +  if (error.length() <= maximumStringLength)
 | 
|      return true;
 | 
|  
 | 
|    if (optionalErrorMessage)
 | 
| @@ -135,4 +134,4 @@ bool PaymentsValidators::isValidErrorMsgFormat(const String& error,
 | 
|    return false;
 | 
|  }
 | 
|  
 | 
| -}  // namespace blink
 | 
| +}  // namespace payments
 | 
| 
 |