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 "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
8 #include "bindings/core/v8/ScriptPromiseResolver.h" | 8 #include "bindings/core/v8/ScriptPromiseResolver.h" |
9 #include "bindings/core/v8/ScriptState.h" | 9 #include "bindings/core/v8/ScriptState.h" |
10 #include "bindings/core/v8/V8StringResource.h" | 10 #include "bindings/core/v8/V8StringResource.h" |
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 DCHECK(!m_completeResolver); | 810 DCHECK(!m_completeResolver); |
811 | 811 |
812 String errorMessage; | 812 String errorMessage; |
813 if (!PaymentsValidators::isValidShippingAddress(address, &errorMessage)) { | 813 if (!PaymentsValidators::isValidShippingAddress(address, &errorMessage)) { |
814 m_showResolver->reject(DOMException::create(SyntaxError, errorMessage)); | 814 m_showResolver->reject(DOMException::create(SyntaxError, errorMessage)); |
815 clearResolversAndCloseMojoConnection(); | 815 clearResolversAndCloseMojoConnection(); |
816 return; | 816 return; |
817 } | 817 } |
818 | 818 |
819 m_shippingAddress = new PaymentAddress(std::move(address)); | 819 m_shippingAddress = new PaymentAddress(std::move(address)); |
820 PaymentRequestUpdateEvent* event = | 820 PaymentRequestUpdateEvent* event = PaymentRequestUpdateEvent::create( |
821 PaymentRequestUpdateEvent::create(EventTypeNames::shippingaddresschange); | 821 getExecutionContext(), EventTypeNames::shippingaddresschange); |
822 event->setTarget(this); | 822 event->setTarget(this); |
823 event->setPaymentDetailsUpdater(this); | 823 event->setPaymentDetailsUpdater(this); |
824 bool success = getExecutionContext()->getEventQueue()->enqueueEvent(event); | 824 bool success = getExecutionContext()->getEventQueue()->enqueueEvent(event); |
825 DCHECK(success); | 825 DCHECK(success); |
826 ALLOW_UNUSED_LOCAL(success); | 826 ALLOW_UNUSED_LOCAL(success); |
827 } | 827 } |
828 | 828 |
829 void PaymentRequest::OnShippingOptionChange(const String& shippingOptionId) { | 829 void PaymentRequest::OnShippingOptionChange(const String& shippingOptionId) { |
830 DCHECK(m_showResolver); | 830 DCHECK(m_showResolver); |
831 DCHECK(!m_completeResolver); | 831 DCHECK(!m_completeResolver); |
832 m_shippingOption = shippingOptionId; | 832 m_shippingOption = shippingOptionId; |
833 PaymentRequestUpdateEvent* event = | 833 PaymentRequestUpdateEvent* event = PaymentRequestUpdateEvent::create( |
834 PaymentRequestUpdateEvent::create(EventTypeNames::shippingoptionchange); | 834 getExecutionContext(), EventTypeNames::shippingoptionchange); |
835 event->setTarget(this); | 835 event->setTarget(this); |
836 event->setPaymentDetailsUpdater(this); | 836 event->setPaymentDetailsUpdater(this); |
837 bool success = getExecutionContext()->getEventQueue()->enqueueEvent(event); | 837 bool success = getExecutionContext()->getEventQueue()->enqueueEvent(event); |
838 DCHECK(success); | 838 DCHECK(success); |
839 ALLOW_UNUSED_LOCAL(success); | 839 ALLOW_UNUSED_LOCAL(success); |
840 } | 840 } |
841 | 841 |
842 void PaymentRequest::OnPaymentResponse(PaymentResponsePtr response) { | 842 void PaymentRequest::OnPaymentResponse(PaymentResponsePtr response) { |
843 DCHECK(m_showResolver); | 843 DCHECK(m_showResolver); |
844 DCHECK(!m_completeResolver); | 844 DCHECK(!m_completeResolver); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 m_completeResolver.clear(); | 997 m_completeResolver.clear(); |
998 m_showResolver.clear(); | 998 m_showResolver.clear(); |
999 m_abortResolver.clear(); | 999 m_abortResolver.clear(); |
1000 m_canMakePaymentResolver.clear(); | 1000 m_canMakePaymentResolver.clear(); |
1001 if (m_clientBinding.is_bound()) | 1001 if (m_clientBinding.is_bound()) |
1002 m_clientBinding.Close(); | 1002 m_clientBinding.Close(); |
1003 m_paymentProvider.reset(); | 1003 m_paymentProvider.reset(); |
1004 } | 1004 } |
1005 | 1005 |
1006 } // namespace blink | 1006 } // namespace blink |
OLD | NEW |