Changeset 206977 in webkit
- Timestamp:
- Oct 9, 2016 7:14:05 PM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r206976 r206977 1 2016-10-09 Darin Adler <darin@apple.com> 2 3 Move ApplePaySession from legacy to new DOM exceptions 4 https://bugs.webkit.org/show_bug.cgi?id=163191 5 6 Reviewed by Sam Weinig. 7 8 * Modules/applepay/ApplePaySession.cpp: 9 (WebCore::ApplePaySession::create): Use ExceptionOr. 10 (WebCore::ApplePaySession::ApplePaySession): Moved initialization 11 of two of the data members to class definition. 12 (WebCore::ApplePaySession::supportsVersion): Use ExceptionOr. 13 (WebCore::ApplePaySession::canMakePayments): Ditto. 14 (WebCore::ApplePaySession::canMakePaymentsWithActiveCard): Ditto. 15 (WebCore::ApplePaySession::openPaymentSetup): Ditto. 16 (WebCore::ApplePaySession::begin): Ditto. 17 (WebCore::ApplePaySession::abort): Ditto. 18 (WebCore::ApplePaySession::completeMerchantValidation): Ditto. 19 (WebCore::ApplePaySession::completeShippingMethodSelection): Ditto. 20 (WebCore::ApplePaySession::completeShippingContactSelection): Ditto. 21 (WebCore::ApplePaySession::completePaymentMethodSelection): Ditto. 22 (WebCore::ApplePaySession::completePayment): Ditto. 23 (WebCore::ApplePaySession::validateMerchant): Use auto and get instead of 24 using a RefPtr type and * for event dispatching. 25 (WebCore::ApplePaySession::didAuthorizePayment): Ditto. 26 (WebCore::ApplePaySession::didSelectShippingMethod): Ditto. 27 (WebCore::ApplePaySession::didSelectShippingContact): Ditto. 28 (WebCore::ApplePaySession::didSelectPaymentMethod): Ditto. 29 (WebCore::ApplePaySession::didCancelPayment): Ditto. 30 (WebCore::ApplePaySession::paymentCoordinator): Moved dereferencing 31 inside the downcast. 32 33 * Modules/applepay/ApplePaySession.h: Updated for changes above. 34 35 * Modules/applepay/ApplePaySession.idl: Use MayThrowException. 36 37 * bindings/js/JSApplePaySessionCustom.cpp: 38 (WebCore::JSApplePaySession::completeShippingMethodSelection): 39 Use propagateException. 40 (WebCore::JSApplePaySession::completeShippingContactSelection): Ditto. 41 (WebCore::JSApplePaySession::completePaymentMethodSelection): Ditto. 42 43 * bindings/js/JSDOMBinding.h: Added implementation of toJSBoolean. 44 45 * bindings/scripts/CodeGeneratorJS.pm: 46 (GenerateConstructorDefinition): Generate the different arguments for 47 toJSNewlyCreated when ConstructorMayThrowException is specified that 48 activate the version of that function that handles exceptions. 49 50 * bindings/scripts/IDLAttributes.txt: Added ConstructorMayThrowException. 51 1 52 2016-10-09 Darin Adler <darin@apple.com> 2 53 -
trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp
r206881 r206977 636 636 } 637 637 638 RefPtr<ApplePaySession> ApplePaySession::create(Document& document, unsigned version, const Dictionary& dictionary, ExceptionCode& ec)638 ExceptionOr<Ref<ApplePaySession>> ApplePaySession::create(Document& document, unsigned version, const Dictionary& dictionary) 639 639 { 640 640 DOMWindow& window = *document.domWindow(); … … 643 643 if (!canCallApplePaySessionAPIs(document, errorMessage)) { 644 644 window.printErrorMessage(errorMessage); 645 ec = INVALID_ACCESS_ERR; 646 return nullptr; 645 return Exception { INVALID_ACCESS_ERR }; 647 646 } 648 647 649 648 if (!ScriptController::processingUserGesture()) { 650 649 window.printErrorMessage("Must create a new ApplePaySession from a user gesture handler."); 651 ec = INVALID_ACCESS_ERR; 652 return nullptr; 650 return Exception { INVALID_ACCESS_ERR }; 653 651 } 654 652 … … 657 655 if (!version || !paymentCoordinator.supportsVersion(version)) { 658 656 window.printErrorMessage(makeString("\"" + String::number(version), "\" is not a supported version.")); 659 ec = INVALID_ACCESS_ERR; 660 return nullptr; 657 return Exception { INVALID_ACCESS_ERR }; 661 658 } 662 659 663 660 auto paymentRequest = createPaymentRequest(version, window, dictionary); 664 if (!paymentRequest) { 665 ec = TYPE_MISMATCH_ERR; 666 return nullptr; 667 } 668 669 if (!PaymentRequestValidator(window).validate(*paymentRequest)) { 670 ec = INVALID_ACCESS_ERR; 671 return nullptr; 672 } 673 674 return adoptRef(new ApplePaySession(document, WTFMove(*paymentRequest))); 661 if (!paymentRequest) 662 return Exception { TYPE_MISMATCH_ERR }; 663 664 if (!PaymentRequestValidator(window).validate(*paymentRequest)) 665 return Exception { INVALID_ACCESS_ERR }; 666 667 return adoptRef(*new ApplePaySession(document, WTFMove(*paymentRequest))); 675 668 } 676 669 677 670 ApplePaySession::ApplePaySession(Document& document, PaymentRequest&& paymentRequest) 678 671 : ActiveDOMObject(&document) 679 , m_state(State::Idle)680 , m_merchantValidationState(MerchantValidationState::Idle)681 672 , m_paymentRequest(WTFMove(paymentRequest)) 682 673 { … … 688 679 } 689 680 690 bool ApplePaySession::supportsVersion(ScriptExecutionContext& scriptExecutionContext, unsigned version, ExceptionCode& ec) 691 { 692 if (!version) { 693 ec = INVALID_ACCESS_ERR; 694 return false; 695 } 681 ExceptionOr<bool> ApplePaySession::supportsVersion(ScriptExecutionContext& scriptExecutionContext, unsigned version) 682 { 683 if (!version) 684 return Exception { INVALID_ACCESS_ERR }; 696 685 697 686 auto& document = downcast<Document>(scriptExecutionContext); … … 701 690 if (!canCallApplePaySessionAPIs(document, errorMessage)) { 702 691 window.printErrorMessage(errorMessage); 703 ec = INVALID_ACCESS_ERR; 704 return false; 705 } 706 707 auto& paymentCoordinator = document.frame()->mainFrame().paymentCoordinator(); 708 return paymentCoordinator.supportsVersion(version); 692 return Exception { INVALID_ACCESS_ERR }; 693 } 694 695 return document.frame()->mainFrame().paymentCoordinator().supportsVersion(version); 709 696 } 710 697 … … 718 705 } 719 706 720 bool ApplePaySession::canMakePayments(ScriptExecutionContext& scriptExecutionContext, ExceptionCode& ec)707 ExceptionOr<bool> ApplePaySession::canMakePayments(ScriptExecutionContext& scriptExecutionContext) 721 708 { 722 709 auto& document = downcast<Document>(scriptExecutionContext); … … 726 713 if (!canCallApplePaySessionAPIs(document, errorMessage)) { 727 714 window.printErrorMessage(errorMessage); 728 ec = INVALID_ACCESS_ERR; 729 return false; 730 } 731 732 auto& paymentCoordinator = document.frame()->mainFrame().paymentCoordinator(); 733 return paymentCoordinator.canMakePayments(); 734 } 735 736 void ApplePaySession::canMakePaymentsWithActiveCard(ScriptExecutionContext& scriptExecutionContext, const String& merchantIdentifier, Ref<DeferredPromise>&& passedPromise, ExceptionCode& ec) 715 return Exception { INVALID_ACCESS_ERR }; 716 } 717 718 return document.frame()->mainFrame().paymentCoordinator().canMakePayments(); 719 } 720 721 ExceptionOr<void> ApplePaySession::canMakePaymentsWithActiveCard(ScriptExecutionContext& scriptExecutionContext, const String& merchantIdentifier, Ref<DeferredPromise>&& passedPromise) 737 722 { 738 723 auto& document = downcast<Document>(scriptExecutionContext); … … 742 727 if (!canCallApplePaySessionAPIs(document, errorMessage)) { 743 728 window.printErrorMessage(errorMessage); 744 ec = INVALID_ACCESS_ERR; 745 return; 729 return Exception { INVALID_ACCESS_ERR }; 746 730 } 747 731 … … 754 738 promise->resolve(canMakePayments); 755 739 }); 756 return ;740 return { }; 757 741 } 758 742 … … 762 746 promise->resolve(canMakePayments); 763 747 }); 764 } 765 766 void ApplePaySession::openPaymentSetup(ScriptExecutionContext& scriptExecutionContext, const String& merchantIdentifier, Ref<DeferredPromise>&& passedPromise, ExceptionCode& ec) 748 return { }; 749 } 750 751 ExceptionOr<void> ApplePaySession::openPaymentSetup(ScriptExecutionContext& scriptExecutionContext, const String& merchantIdentifier, Ref<DeferredPromise>&& passedPromise) 767 752 { 768 753 auto& document = downcast<Document>(scriptExecutionContext); … … 772 757 if (!canCallApplePaySessionAPIs(document, errorMessage)) { 773 758 window.printErrorMessage(errorMessage); 774 ec = INVALID_ACCESS_ERR; 775 return; 759 return Exception { INVALID_ACCESS_ERR }; 776 760 } 777 761 778 762 if (!ScriptController::processingUserGesture()) { 779 763 window.printErrorMessage("Must call ApplePaySession.openPaymentSetup from a user gesture handler."); 780 ec = INVALID_ACCESS_ERR; 781 return; 764 return Exception { INVALID_ACCESS_ERR }; 782 765 } 783 766 … … 788 771 promise->resolve(result); 789 772 }); 790 } 791 792 void ApplePaySession::begin(ExceptionCode& ec) 773 774 return { }; 775 } 776 777 ExceptionOr<void> ApplePaySession::begin() 793 778 { 794 779 auto& document = *downcast<Document>(scriptExecutionContext()); … … 797 782 if (!canBegin()) { 798 783 window.printErrorMessage("Payment session is already active."); 799 ec = INVALID_ACCESS_ERR; 800 return; 784 return Exception { INVALID_ACCESS_ERR }; 801 785 } 802 786 803 787 if (paymentCoordinator().hasActiveSession()) { 804 788 window.printErrorMessage("Page already has an active payment session."); 805 806 ec = INVALID_ACCESS_ERR; 807 return; 789 return Exception { INVALID_ACCESS_ERR }; 808 790 } 809 791 … … 814 796 if (!paymentCoordinator().beginPaymentSession(*this, document.url(), linkIconURLs, m_paymentRequest)) { 815 797 window.printErrorMessage("There is already has an active payment session."); 816 817 ec = INVALID_ACCESS_ERR; 818 return; 798 return Exception { INVALID_ACCESS_ERR }; 819 799 } 820 800 … … 822 802 823 803 setPendingActivity(this); 824 } 825 826 void ApplePaySession::abort(ExceptionCode& ec) 827 { 828 if (!canAbort()) { 829 ec = INVALID_ACCESS_ERR; 830 return;831 }804 805 return { }; 806 } 807 808 ExceptionOr<void> ApplePaySession::abort() 809 { 810 if (!canAbort()) 811 return Exception { INVALID_ACCESS_ERR }; 832 812 833 813 m_state = State::Aborted; … … 835 815 836 816 didReachFinalState(); 837 } 838 839 void ApplePaySession::completeMerchantValidation(const Dictionary& merchantSessionDictionary, ExceptionCode& ec) 840 { 841 if (!canCompleteMerchantValidation()) { 842 ec = INVALID_ACCESS_ERR; 843 return; 844 } 845 846 if (!merchantSessionDictionary.initializerObject()) { 847 ec = TypeError; 848 return; 849 } 817 818 return { }; 819 } 820 821 ExceptionOr<void> ApplePaySession::completeMerchantValidation(const Dictionary& merchantSessionDictionary) 822 { 823 if (!canCompleteMerchantValidation()) 824 return Exception { INVALID_ACCESS_ERR }; 825 826 if (!merchantSessionDictionary.initializerObject()) 827 return Exception { TypeError }; 850 828 851 829 auto& document = *downcast<Document>(scriptExecutionContext()); … … 856 834 if (!merchantSession) { 857 835 window.printErrorMessage(errorMessage); 858 ec = INVALID_ACCESS_ERR; 859 return; 836 return Exception { INVALID_ACCESS_ERR }; 860 837 } 861 838 862 839 m_merchantValidationState = MerchantValidationState::ValidationComplete; 863 840 paymentCoordinator().completeMerchantValidation(*merchantSession); 864 } 865 841 842 return { }; 843 } 866 844 867 845 static Optional<PaymentAuthorizationStatus> toPaymentAuthorizationStatus(unsigned short status) … … 897 875 } 898 876 899 void ApplePaySession::completeShippingMethodSelection(unsigned short status, const Dictionary& newTotalDictionary, const ArrayValue& newLineItemsArray, ExceptionCode& ec) 900 { 901 if (!canCompleteShippingMethodSelection()) { 902 ec = INVALID_ACCESS_ERR; 903 return; 904 } 877 ExceptionOr<void> ApplePaySession::completeShippingMethodSelection(unsigned short status, const Dictionary& newTotalDictionary, const ArrayValue& newLineItemsArray) 878 { 879 if (!canCompleteShippingMethodSelection()) 880 return Exception { INVALID_ACCESS_ERR }; 905 881 906 882 auto authorizationStatus = toPaymentAuthorizationStatus(status); 907 if (!authorizationStatus) { 908 ec = INVALID_ACCESS_ERR; 909 return; 910 } 883 if (!authorizationStatus) 884 return Exception { INVALID_ACCESS_ERR }; 911 885 912 886 auto& window = *downcast<Document>(scriptExecutionContext())->domWindow(); 913 887 auto newTotal = createLineItem(window, newTotalDictionary); 914 if (!newTotal) { 915 ec = INVALID_ACCESS_ERR; 916 return; 917 } 918 919 if (!PaymentRequestValidator(window).validateTotal(*newTotal)) { 920 ec = INVALID_ACCESS_ERR; 921 return; 922 } 888 if (!newTotal) 889 return Exception { INVALID_ACCESS_ERR }; 890 891 if (!PaymentRequestValidator(window).validateTotal(*newTotal)) 892 return Exception { INVALID_ACCESS_ERR }; 923 893 924 894 auto newLineItems = createLineItems(window, newLineItemsArray); 925 if (!newLineItems) { 926 ec = INVALID_ACCESS_ERR; 927 return; 928 } 895 if (!newLineItems) 896 return Exception { INVALID_ACCESS_ERR }; 929 897 930 898 m_state = State::Active; … … 933 901 totalAndLineItems.lineItems = *newLineItems; 934 902 paymentCoordinator().completeShippingMethodSelection(*authorizationStatus, totalAndLineItems); 935 } 936 937 void ApplePaySession::completeShippingContactSelection(unsigned short status, const ArrayValue& newShippingMethodsArray, const Dictionary& newTotalDictionary, const ArrayValue& newLineItemsArray, ExceptionCode& ec) 938 { 939 if (!canCompleteShippingContactSelection()) { 940 ec = INVALID_ACCESS_ERR; 941 return;942 }903 904 return { }; 905 } 906 907 ExceptionOr<void> ApplePaySession::completeShippingContactSelection(unsigned short status, const ArrayValue& newShippingMethodsArray, const Dictionary& newTotalDictionary, const ArrayValue& newLineItemsArray) 908 { 909 if (!canCompleteShippingContactSelection()) 910 return Exception { INVALID_ACCESS_ERR }; 943 911 944 912 auto authorizationStatus = toPaymentAuthorizationStatus(status); 945 if (!authorizationStatus) { 946 ec = INVALID_ACCESS_ERR; 947 return; 948 } 913 if (!authorizationStatus) 914 return Exception { INVALID_ACCESS_ERR }; 949 915 950 916 auto& window = *downcast<Document>(scriptExecutionContext())->domWindow(); 951 917 952 918 auto newShippingMethods = createShippingMethods(window, newShippingMethodsArray); 953 if (!newShippingMethods) { 954 ec = INVALID_ACCESS_ERR; 955 return; 956 } 919 if (!newShippingMethods) 920 return Exception { INVALID_ACCESS_ERR }; 957 921 958 922 auto newTotal = createLineItem(window, newTotalDictionary); 959 if (!newTotal) { 960 ec = INVALID_ACCESS_ERR; 961 return; 962 } 963 964 if (!PaymentRequestValidator(window).validateTotal(*newTotal)) { 965 ec = INVALID_ACCESS_ERR; 966 return; 967 } 923 if (!newTotal) 924 return Exception { INVALID_ACCESS_ERR }; 925 926 if (!PaymentRequestValidator(window).validateTotal(*newTotal)) 927 return Exception { INVALID_ACCESS_ERR }; 968 928 969 929 auto newLineItems = createLineItems(window, newLineItemsArray); 970 if (!newLineItems) { 971 ec = INVALID_ACCESS_ERR; 972 return; 973 } 930 if (!newLineItems) 931 return Exception { INVALID_ACCESS_ERR }; 974 932 975 933 m_state = State::Active; … … 978 936 totalAndLineItems.lineItems = *newLineItems; 979 937 paymentCoordinator().completeShippingContactSelection(*authorizationStatus, *newShippingMethods, totalAndLineItems); 980 } 981 982 void ApplePaySession::completePaymentMethodSelection(const Dictionary& newTotalDictionary, const ArrayValue& newLineItemsArray, ExceptionCode& ec) 983 { 984 if (!canCompletePaymentMethodSelection()) { 985 ec = INVALID_ACCESS_ERR; 986 return;987 }988 989 auto& window = *downcast<Document>( scriptExecutionContext())->domWindow();938 939 return { }; 940 } 941 942 ExceptionOr<void> ApplePaySession::completePaymentMethodSelection(const Dictionary& newTotalDictionary, const ArrayValue& newLineItemsArray) 943 { 944 if (!canCompletePaymentMethodSelection()) 945 return Exception { INVALID_ACCESS_ERR }; 946 947 auto& window = *downcast<Document>(*scriptExecutionContext()).domWindow(); 990 948 auto newTotal = createLineItem(window, newTotalDictionary); 991 if (!newTotal) { 992 ec = INVALID_ACCESS_ERR; 993 return; 994 } 995 996 if (!PaymentRequestValidator(window).validateTotal(*newTotal)) { 997 ec = INVALID_ACCESS_ERR; 998 return; 999 } 949 if (!newTotal) 950 return Exception { INVALID_ACCESS_ERR }; 951 952 if (!PaymentRequestValidator(window).validateTotal(*newTotal)) 953 return Exception { INVALID_ACCESS_ERR }; 1000 954 1001 955 auto newLineItems = createLineItems(window, newLineItemsArray); 1002 if (!newLineItems) { 1003 ec = INVALID_ACCESS_ERR; 1004 return; 1005 } 956 if (!newLineItems) 957 return Exception { INVALID_ACCESS_ERR }; 1006 958 1007 959 m_state = State::Active; … … 1010 962 totalAndLineItems.lineItems = *newLineItems; 1011 963 paymentCoordinator().completePaymentMethodSelection(totalAndLineItems); 1012 } 1013 1014 void ApplePaySession::completePayment(unsigned short status, ExceptionCode& ec) 1015 { 1016 if (!canCompletePayment()) { 1017 ec = INVALID_ACCESS_ERR; 1018 return;1019 }964 965 return { }; 966 } 967 968 ExceptionOr<void> ApplePaySession::completePayment(unsigned short status) 969 { 970 if (!canCompletePayment()) 971 return Exception { INVALID_ACCESS_ERR }; 1020 972 1021 973 auto authorizationStatus = toPaymentAuthorizationStatus(status); 1022 if (!authorizationStatus) { 1023 ec = INVALID_ACCESS_ERR; 1024 return; 1025 } 974 if (!authorizationStatus) 975 return Exception { INVALID_ACCESS_ERR }; 1026 976 1027 977 paymentCoordinator().completePaymentSession(*authorizationStatus); … … 1029 979 if (!isFinalStateStatus(*authorizationStatus)) { 1030 980 m_state = State::Active; 1031 return ;981 return { }; 1032 982 } 1033 983 1034 984 m_state = State::Completed; 1035 985 unsetPendingActivity(this); 986 return { }; 1036 987 } 1037 988 … … 1054 1005 m_merchantValidationState = MerchantValidationState::ValidatingMerchant; 1055 1006 1056 RefPtr<ApplePayValidateMerchantEvent>event = ApplePayValidateMerchantEvent::create(eventNames().validatemerchantEvent, validationURL);1057 dispatchEvent( *event);1007 auto event = ApplePayValidateMerchantEvent::create(eventNames().validatemerchantEvent, validationURL); 1008 dispatchEvent(event.get()); 1058 1009 } 1059 1010 … … 1064 1015 m_state = State::Authorized; 1065 1016 1066 RefPtr<ApplePayPaymentAuthorizedEvent>event = ApplePayPaymentAuthorizedEvent::create(eventNames().paymentauthorizedEvent, payment);1067 dispatchEvent( *event);1017 auto event = ApplePayPaymentAuthorizedEvent::create(eventNames().paymentauthorizedEvent, payment); 1018 dispatchEvent(event.get()); 1068 1019 } 1069 1020 … … 1078 1029 1079 1030 m_state = State::ShippingMethodSelected; 1080 RefPtr<ApplePayShippingMethodSelectedEvent>event = ApplePayShippingMethodSelectedEvent::create(eventNames().shippingmethodselectedEvent, shippingMethod);1081 dispatchEvent( *event);1031 auto event = ApplePayShippingMethodSelectedEvent::create(eventNames().shippingmethodselectedEvent, shippingMethod); 1032 dispatchEvent(event.get()); 1082 1033 } 1083 1034 … … 1092 1043 1093 1044 m_state = State::ShippingContactSelected; 1094 RefPtr<ApplePayShippingContactSelectedEvent>event = ApplePayShippingContactSelectedEvent::create(eventNames().shippingcontactselectedEvent, shippingContact);1095 dispatchEvent( *event);1045 auto event = ApplePayShippingContactSelectedEvent::create(eventNames().shippingcontactselectedEvent, shippingContact); 1046 dispatchEvent(event.get()); 1096 1047 } 1097 1048 … … 1106 1057 1107 1058 m_state = State::PaymentMethodSelected; 1108 RefPtr<ApplePayPaymentMethodSelectedEvent>event = ApplePayPaymentMethodSelectedEvent::create(eventNames().paymentmethodselectedEvent, paymentMethod);1109 dispatchEvent( *event);1059 auto event = ApplePayPaymentMethodSelectedEvent::create(eventNames().paymentmethodselectedEvent, paymentMethod); 1060 dispatchEvent(event.get()); 1110 1061 } 1111 1062 … … 1116 1067 m_state = State::Canceled; 1117 1068 1118 RefPtr<Event>event = Event::create(eventNames().cancelEvent, false, false);1119 dispatchEvent( *event);1069 auto event = Event::create(eventNames().cancelEvent, false, false); 1070 dispatchEvent(event.get()); 1120 1071 1121 1072 didReachFinalState(); … … 1158 1109 PaymentCoordinator& ApplePaySession::paymentCoordinator() const 1159 1110 { 1160 return downcast<Document>( scriptExecutionContext())->frame()->mainFrame().paymentCoordinator();1111 return downcast<Document>(*scriptExecutionContext()).frame()->mainFrame().paymentCoordinator(); 1161 1112 } 1162 1113 -
trunk/Source/WebCore/Modules/applepay/ApplePaySession.h
r206252 r206977 30 30 #include "ActiveDOMObject.h" 31 31 #include "EventTarget.h" 32 #include "Exception Code.h"32 #include "ExceptionOr.h" 33 33 #include "PaymentRequest.h" 34 34 #include <wtf/Ref.h> … … 49 49 class ApplePaySession final : public RefCounted<ApplePaySession>, public ActiveDOMObject, public EventTargetWithInlineData { 50 50 public: 51 static RefPtr<ApplePaySession> create(Document&, unsigned version, const Dictionary&, ExceptionCode&);51 static ExceptionOr<Ref<ApplePaySession>> create(Document&, unsigned version, const Dictionary&); 52 52 virtual ~ApplePaySession(); 53 53 … … 62 62 static const unsigned short STATUS_PIN_LOCKOUT = 7; 63 63 64 static bool supportsVersion(ScriptExecutionContext&, unsigned version, ExceptionCode&);65 static bool canMakePayments(ScriptExecutionContext&, ExceptionCode&);66 static void canMakePaymentsWithActiveCard(ScriptExecutionContext&, const String& merchantIdentifier, Ref<DeferredPromise>&&, ExceptionCode&);67 static void openPaymentSetup(ScriptExecutionContext&, const String& merchantIdentifier, Ref<DeferredPromise>&&, ExceptionCode&);64 static ExceptionOr<bool> supportsVersion(ScriptExecutionContext&, unsigned version); 65 static ExceptionOr<bool> canMakePayments(ScriptExecutionContext&); 66 static ExceptionOr<void> canMakePaymentsWithActiveCard(ScriptExecutionContext&, const String& merchantIdentifier, Ref<DeferredPromise>&&); 67 static ExceptionOr<void> openPaymentSetup(ScriptExecutionContext&, const String& merchantIdentifier, Ref<DeferredPromise>&&); 68 68 69 void begin(ExceptionCode&);70 void abort(ExceptionCode&);71 void completeMerchantValidation(const Dictionary& merchantSessionDictionary, ExceptionCode&);72 void completeShippingMethodSelection(unsigned short status, const Dictionary& newTotal, const ArrayValue& newLineItems, ExceptionCode&);73 void completeShippingContactSelection(unsigned short status, const ArrayValue& newShippingMethods, const Dictionary& newTotal, const ArrayValue& newLineItems, ExceptionCode&);74 void completePaymentMethodSelection(const Dictionary& newTotal, const ArrayValue& newLineItems, ExceptionCode&);75 void completePayment(unsigned short status, ExceptionCode&);69 ExceptionOr<void> begin(); 70 ExceptionOr<void> abort(); 71 ExceptionOr<void> completeMerchantValidation(const Dictionary& merchantSessionDictionary); 72 ExceptionOr<void> completeShippingMethodSelection(unsigned short status, const Dictionary& newTotal, const ArrayValue& newLineItems); 73 ExceptionOr<void> completeShippingContactSelection(unsigned short status, const ArrayValue& newShippingMethods, const Dictionary& newTotal, const ArrayValue& newLineItems); 74 ExceptionOr<void> completePaymentMethodSelection(const Dictionary& newTotal, const ArrayValue& newLineItems); 75 ExceptionOr<void> completePayment(unsigned short status); 76 76 77 77 const PaymentRequest& paymentRequest() const { return m_paymentRequest; } … … 127 127 Aborted, 128 128 Canceled, 129 } m_state ;129 } m_state { State::Idle }; 130 130 131 131 enum class MerchantValidationState { … … 133 133 ValidatingMerchant, 134 134 ValidationComplete, 135 } m_merchantValidationState ;135 } m_merchantValidationState { MerchantValidationState::Idle }; 136 136 137 137 const PaymentRequest m_paymentRequest; -
trunk/Source/WebCore/Modules/applepay/ApplePaySession.idl
r206723 r206977 29 29 Constructor(unsigned long version, Dictionary paymentRequest), 30 30 ConstructorCallWith=Document, 31 ConstructorMayThrow LegacyException,31 ConstructorMayThrowException, 32 32 EnabledBySetting=ApplePay, 33 33 ] interface ApplePaySession : EventTarget { … … 41 41 const unsigned short STATUS_PIN_LOCKOUT = 7; 42 42 43 [CallWith=ScriptExecutionContext, MayThrow LegacyException] static boolean supportsVersion(unsigned long version);44 [CallWith=ScriptExecutionContext, MayThrow LegacyException] static boolean canMakePayments();45 [CallWith=ScriptExecutionContext, MayThrow LegacyException] static Promise canMakePaymentsWithActiveCard(DOMString merchantIdentifier);46 [CallWith=ScriptExecutionContext, MayThrow LegacyException] static Promise openPaymentSetup(DOMString merchantIdentifier);43 [CallWith=ScriptExecutionContext, MayThrowException] static boolean supportsVersion(unsigned long version); 44 [CallWith=ScriptExecutionContext, MayThrowException] static boolean canMakePayments(); 45 [CallWith=ScriptExecutionContext, MayThrowException] static Promise canMakePaymentsWithActiveCard(DOMString merchantIdentifier); 46 [CallWith=ScriptExecutionContext, MayThrowException] static Promise openPaymentSetup(DOMString merchantIdentifier); 47 47 48 [MayThrow LegacyException] void begin();49 [MayThrow LegacyException] void abort();50 [MayThrow LegacyException] void completeMerchantValidation(Dictionary merchantSession);51 [Custom, MayThrow LegacyException] void completeShippingMethodSelection(unsigned short status, Dictionary newTotal, sequence<Dictionary> newLineItems);52 [Custom, MayThrow LegacyException] void completeShippingContactSelection(unsigned short status, sequence<Dictionary> newShippingMethods, Dictionary newTotal, sequence<Dictionary> newLineItems);53 [Custom, MayThrow LegacyException] void completePaymentMethodSelection(Dictionary newTotal, sequence<Dictionary> newLineItems);54 [MayThrow LegacyException] void completePayment(unsigned short status);48 [MayThrowException] void begin(); 49 [MayThrowException] void abort(); 50 [MayThrowException] void completeMerchantValidation(Dictionary merchantSession); 51 [Custom, MayThrowException] void completeShippingMethodSelection(unsigned short status, Dictionary newTotal, sequence<Dictionary> newLineItems); 52 [Custom, MayThrowException] void completeShippingContactSelection(unsigned short status, sequence<Dictionary> newShippingMethods, Dictionary newTotal, sequence<Dictionary> newLineItems); 53 [Custom, MayThrowException] void completePaymentMethodSelection(Dictionary newTotal, sequence<Dictionary> newLineItems); 54 [MayThrowException] void completePayment(unsigned short status); 55 55 56 56 attribute EventHandler onvalidatemerchant; -
trunk/Source/WebCore/bindings/js/JSApplePaySessionCustom.cpp
r206386 r206977 54 54 return JSValue::decode(throwVMError(&state, scope, createNotEnoughArgumentsError(&state))); 55 55 56 ExceptionCode ec = 0;57 56 uint16_t status = convert<uint16_t>(state, state.argument(0), NormalConversion); 58 57 RETURN_IF_EXCEPTION(scope, JSValue()); … … 63 62 ArrayValue newLineItems { &state, state.argument(2) }; 64 63 RETURN_IF_EXCEPTION(scope, JSValue()); 65 impl.completeShippingMethodSelection(status, newTotal, newLineItems, ec); 66 setDOMException(&state, ec); 64 propagateException(state, scope, impl.completeShippingMethodSelection(status, newTotal, newLineItems)); 67 65 68 66 return jsUndefined(); … … 84 82 return JSValue::decode(throwVMError(&state, scope, createNotEnoughArgumentsError(&state))); 85 83 86 ExceptionCode ec = 0;87 84 uint16_t status = convert<uint16_t>(state, state.argument(0), NormalConversion); 88 85 RETURN_IF_EXCEPTION(scope, JSValue()); … … 96 93 ArrayValue newLineItems { &state, state.argument(3) }; 97 94 RETURN_IF_EXCEPTION(scope, JSValue()); 98 impl.completeShippingContactSelection(status, newShippingMethods, newTotal, newLineItems, ec); 99 setDOMException(&state, ec);95 96 propagateException(state, scope, impl.completeShippingContactSelection(status, newShippingMethods, newTotal, newLineItems)); 100 97 101 98 return jsUndefined(); … … 117 114 return JSValue::decode(throwVMError(&state, scope, createNotEnoughArgumentsError(&state))); 118 115 119 ExceptionCode ec = 0;120 116 Dictionary newTotal = { &state, state.argument(0) }; 121 117 RETURN_IF_EXCEPTION(scope, JSValue()); … … 123 119 ArrayValue newLineItems { &state, state.argument(1) }; 124 120 RETURN_IF_EXCEPTION(scope, JSValue()); 125 impl.completePaymentMethodSelection(newTotal, newLineItems, ec); 126 setDOMException(&state, ec);121 122 propagateException(state, scope, impl.completePaymentMethodSelection(newTotal, newLineItems)); 127 123 128 124 return jsUndefined(); -
trunk/Source/WebCore/bindings/js/JSDOMBinding.h
r206976 r206977 917 917 } 918 918 919 template<typename T> inline JSC::JSValue toJSNewlyCreated(JSC::ExecState& state, JSDOMGlobalObject& globalObject, JSC::ThrowScope& throwScope, ExceptionOr<T>&& value)919 inline JSC::JSValue toJSBoolean(JSC::ExecState& state, JSC::ThrowScope& throwScope, ExceptionOr<bool>&& value) 920 920 { 921 921 if (UNLIKELY(value.hasException())) { … … 923 923 return { }; 924 924 } 925 return toJSNewlyCreated(&state, &globalObject,value.releaseReturnValue());926 } 927 928 template<typename T> inline JSC::JSValue toJSN umber(JSC::ExecState& state, JSC::ThrowScope& throwScope, ExceptionOr<T>&& value)925 return JSC::jsBoolean(value.releaseReturnValue()); 926 } 927 928 template<typename T> inline JSC::JSValue toJSNewlyCreated(JSC::ExecState& state, JSDOMGlobalObject& globalObject, JSC::ThrowScope& throwScope, ExceptionOr<T>&& value) 929 929 { 930 930 if (UNLIKELY(value.hasException())) { … … 932 932 return { }; 933 933 } 934 return toJSNewlyCreated(&state, &globalObject, value.releaseReturnValue()); 935 } 936 937 template<typename T> inline JSC::JSValue toJSNumber(JSC::ExecState& state, JSC::ThrowScope& throwScope, ExceptionOr<T>&& value) 938 { 939 if (UNLIKELY(value.hasException())) { 940 propagateException(state, throwScope, value.releaseException()); 941 return { }; 942 } 934 943 return JSC::jsNumber(value.releaseReturnValue()); 935 944 } -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r206976 r206977 5539 5539 5540 5540 push(@$outputArray, " RETURN_IF_EXCEPTION(throwScope, encodedJSValue());\n") if $codeGenerator->ExtendedAttributeContains($interface->extendedAttributes->{ConstructorCallWith}, "ScriptState"); 5541 push(@$outputArray, " return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));\n"); 5541 if ($interface->extendedAttributes->{ConstructorMayThrowException}) { 5542 push(@$outputArray, " return JSValue::encode(toJSNewlyCreated(*state, *castedThis->globalObject(), throwScope, WTFMove(object)));\n"); 5543 } else { 5544 push(@$outputArray, " return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));\n"); 5545 } 5542 5546 push(@$outputArray, "}\n\n"); 5543 5547 } -
trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt
r206976 r206977 34 34 ConstructorCallWith=Document|ScriptExecutionContext|ScriptState 35 35 ConstructorConditional=* 36 ConstructorMayThrowException 36 37 ConstructorMayThrowLegacyException 37 38 ConstructorTemplate=Event|TypedArray
Note: See TracChangeset
for help on using the changeset viewer.