| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/payments/PaymentRequest.h" | 5 #include "modules/payments/PaymentRequest.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include "bindings/core/v8/ExceptionState.h" | 9 #include "bindings/core/v8/ExceptionState.h" |
| 10 #include "bindings/core/v8/ScriptPromiseResolver.h" | 10 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 125 |
| 126 // If the website does not call complete() 60 seconds after show() has been | 126 // If the website does not call complete() 60 seconds after show() has been |
| 127 // resolved, then behave as if the website called complete("fail"). | 127 // resolved, then behave as if the website called complete("fail"). |
| 128 static const int completeTimeoutSeconds = 60; | 128 static const int completeTimeoutSeconds = 60; |
| 129 | 129 |
| 130 // Validates ShippingOption or PaymentItem, which happen to have identical | 130 // Validates ShippingOption or PaymentItem, which happen to have identical |
| 131 // fields, except for "id", which is present only in ShippingOption. | 131 // fields, except for "id", which is present only in ShippingOption. |
| 132 template <typename T> | 132 template <typename T> |
| 133 void validateShippingOptionOrPaymentItem(const T& item, | 133 void validateShippingOptionOrPaymentItem(const T& item, |
| 134 ExceptionState& exceptionState) { | 134 ExceptionState& exceptionState) { |
| 135 /* DO NOT SUBMIT - merge conflict marker. |
| 136 * Please spell |hasLabel| and |label| below. */ |
| 135 if (!item.hasLabel() || item.label().isEmpty()) { | 137 if (!item.hasLabel() || item.label().isEmpty()) { |
| 136 exceptionState.throwTypeError("Item label required"); | 138 exceptionState.throwTypeError("Item label required"); |
| 137 return; | 139 return; |
| 138 } | 140 } |
| 139 | 141 |
| 142 /* DO NOT SUBMIT - merge conflict marker. |
| 143 * Please spell |hasAmount| below. */ |
| 140 if (!item.hasAmount()) { | 144 if (!item.hasAmount()) { |
| 141 exceptionState.throwTypeError("Currency amount required"); | 145 exceptionState.throwTypeError("Currency amount required"); |
| 142 return; | 146 return; |
| 143 } | 147 } |
| 144 | 148 |
| 149 /* DO NOT SUBMIT - merge conflict marker. |
| 150 * Please spell |amount| below. */ |
| 145 if (!item.amount().hasCurrency()) { | 151 if (!item.amount().hasCurrency()) { |
| 146 exceptionState.throwTypeError("Currency code required"); | 152 exceptionState.throwTypeError("Currency code required"); |
| 147 return; | 153 return; |
| 148 } | 154 } |
| 149 | 155 |
| 150 if (!item.amount().hasValue()) { | 156 if (!item.amount().hasValue()) { |
| 151 exceptionState.throwTypeError("Currency value required"); | 157 exceptionState.throwTypeError("Currency value required"); |
| 152 return; | 158 return; |
| 153 } | 159 } |
| 154 | 160 |
| 155 String errorMessage; | 161 String errorMessage; |
| 156 if (!PaymentsValidators::isValidCurrencyCodeFormat( | 162 if (!PaymentsValidators::isValidCurrencyCodeFormat( |
| 163 /* DO NOT SUBMIT - merge conflict marker. |
| 164 * Please spell |amount| in the *2* places on the line below. */ |
| 157 item.amount().currency(), item.amount().currencySystem(), | 165 item.amount().currency(), item.amount().currencySystem(), |
| 158 &errorMessage)) { | 166 &errorMessage)) { |
| 159 exceptionState.throwTypeError(errorMessage); | 167 exceptionState.throwTypeError(errorMessage); |
| 160 return; | 168 return; |
| 161 } | 169 } |
| 162 | 170 |
| 171 /* DO NOT SUBMIT - merge conflict marker. |
| 172 * Please spell |amount| below. */ |
| 163 if (!PaymentsValidators::isValidAmountFormat(item.amount().value(), | 173 if (!PaymentsValidators::isValidAmountFormat(item.amount().value(), |
| 164 &errorMessage)) { | 174 &errorMessage)) { |
| 165 exceptionState.throwTypeError(errorMessage); | 175 exceptionState.throwTypeError(errorMessage); |
| 166 return; | 176 return; |
| 167 } | 177 } |
| 168 } | 178 } |
| 169 | 179 |
| 170 void validateAndConvertDisplayItems(const HeapVector<PaymentItem>& input, | 180 void validateAndConvertDisplayItems(const HeapVector<PaymentItem>& input, |
| 171 Vector<PaymentItemPtr>& output, | 181 Vector<PaymentItemPtr>& output, |
| 172 ExceptionState& exceptionState) { | 182 ExceptionState& exceptionState) { |
| (...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1072 m_completeResolver.clear(); | 1082 m_completeResolver.clear(); |
| 1073 m_showResolver.clear(); | 1083 m_showResolver.clear(); |
| 1074 m_abortResolver.clear(); | 1084 m_abortResolver.clear(); |
| 1075 m_canMakePaymentResolver.clear(); | 1085 m_canMakePaymentResolver.clear(); |
| 1076 if (m_clientBinding.is_bound()) | 1086 if (m_clientBinding.is_bound()) |
| 1077 m_clientBinding.Close(); | 1087 m_clientBinding.Close(); |
| 1078 m_paymentProvider.reset(); | 1088 m_paymentProvider.reset(); |
| 1079 } | 1089 } |
| 1080 | 1090 |
| 1081 } // namespace blink | 1091 } // namespace blink |
| OLD | NEW |