Changeset 223076 in webkit
- Timestamp:
- Oct 9, 2017 3:40:58 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 2 deleted
- 19 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r223073 r223076 1 2017-10-09 Andy Estes <aestes@apple.com> 2 3 [Payment Request] Implement PaymentRequest.show() and PaymentRequest.hide() 4 https://bugs.webkit.org/show_bug.cgi?id=178043 5 <rdar://problem/34076639> 6 7 Reviewed by Tim Horton. 8 9 Copied payment-request-abort-method.https.html and payment-request-show-method.https.html 10 from web-platform-tests/payment-request/ and changed the payment method from basic-card to 11 Apple Pay. This needs to eventually be upstreamed back to WPT. 12 13 * TestExpectations: 14 * http/tests/paymentrequest/payment-request-abort-method.https-expected.txt: Added. 15 * http/tests/paymentrequest/payment-request-abort-method.https.html: Added. 16 * http/tests/paymentrequest/payment-request-show-method.https-expected.txt: Added. 17 * http/tests/paymentrequest/payment-request-show-method.https.html: Added. 18 * platform/ios-wk2/TestExpectations: 19 * platform/mac-wk2/TestExpectations: 20 1 21 2017-10-09 Youenn Fablet <youenn@apple.com> 2 22 -
trunk/LayoutTests/TestExpectations
r223053 r223076 149 149 150 150 # Payment Request is only enabled on Cocoa platforms. 151 http/tests/paymentrequest [ Skip ] 151 152 imported/w3c/web-platform-tests/payment-request [ Skip ] 152 153 -
trunk/LayoutTests/imported/w3c/ChangeLog
r223064 r223076 1 2017-10-09 Andy Estes <aestes@apple.com> 2 3 [Payment Request] Implement PaymentRequest.show() and PaymentRequest.hide() 4 https://bugs.webkit.org/show_bug.cgi?id=178043 5 <rdar://problem/34076639> 6 7 Reviewed by Tim Horton. 8 9 * web-platform-tests/payment-request/payment-request-abort-method.https-expected.txt: Removed. 10 * web-platform-tests/payment-request/payment-request-show-method.https-expected.txt: Removed. 11 1 12 2017-10-09 Youenn Fablet <youenn@apple.com> 2 13 -
trunk/LayoutTests/platform/ios-wk2/TestExpectations
r223053 r223076 29 29 fast/viewport/ios/viewport-fit-auto.html [ Skip ] 30 30 31 http/tests/paymentrequest [ Pass ] 31 32 imported/w3c/web-platform-tests/payment-request [ Pass ] 32 33 webkit.org/b/175611 imported/w3c/web-platform-tests/payment-request/allowpaymentrequest/allowpaymentrequest-attribute-cross-origin-bc-containers.https.html [ Skip ] … … 35 36 webkit.org/b/175611 imported/w3c/web-platform-tests/payment-request/allowpaymentrequest/setting-allowpaymentrequest-timing.https.sub.html [ Skip ] 36 37 webkit.org/b/175611 imported/w3c/web-platform-tests/payment-request/allowpaymentrequest/setting-allowpaymentrequest.https.sub.html [ Skip ] 37 webkit.org/b/177391 imported/w3c/web-platform-tests/payment-request/payment-request-show-method.https.html [ Pass Failure ] 38 webkit.org/b/177391 imported/w3c/web-platform-tests/payment-request/payment-request-abort-method.https.html [ Pass Failure ] 38 39 # skip in favor of tests in http/tests/paymentrequest 40 imported/w3c/web-platform-tests/payment-request/payment-request-show-method.https.html [ WontFix ] 41 imported/w3c/web-platform-tests/payment-request/payment-request-abort-method.https.html [ WontFix ] 39 42 40 43 # skip manual payment-request tests -
trunk/LayoutTests/platform/mac-wk2/TestExpectations
r223071 r223076 26 26 fast/visual-viewport/rubberbanding-viewport-rects-header-footer.html [ Pass ] 27 27 28 imported/w3c/web-platform-tests/payment-request [ Pass ] 28 [ Sierra+ ] http/tests/paymentrequest [ Pass ] 29 [ Sierra+ ] imported/w3c/web-platform-tests/payment-request [ Pass ] 29 30 webkit.org/b/175611 imported/w3c/web-platform-tests/payment-request/allowpaymentrequest/allowpaymentrequest-attribute-cross-origin-bc-containers.https.html [ Skip ] 30 31 webkit.org/b/175611 imported/w3c/web-platform-tests/payment-request/allowpaymentrequest/no-attribute-cross-origin-bc-containers.https.html [ Skip ] … … 33 34 webkit.org/b/175611 imported/w3c/web-platform-tests/payment-request/allowpaymentrequest/setting-allowpaymentrequest.https.sub.html [ Skip ] 34 35 webkit.org/b/177783 imported/w3c/web-platform-tests/payment-request/rejects_if_not_active.https.html [ Skip ] 35 webkit.org/b/177391 imported/w3c/web-platform-tests/payment-request/payment-request-show-method.https.html [ Pass Failure ] 36 webkit.org/b/177391 imported/w3c/web-platform-tests/payment-request/payment-request-abort-method.https.html [ Pass Failure ] 36 37 # skip in favor of tests in http/tests/paymentrequest 38 imported/w3c/web-platform-tests/payment-request/payment-request-show-method.https.html [ WontFix ] 39 imported/w3c/web-platform-tests/payment-request/payment-request-abort-method.https.html [ WontFix ] 37 40 38 41 # skip manual payment-request tests -
trunk/Source/WebCore/ChangeLog
r223073 r223076 1 2017-10-09 Andy Estes <aestes@apple.com> 2 3 [Payment Request] Implement PaymentRequest.show() and PaymentRequest.hide() 4 https://bugs.webkit.org/show_bug.cgi?id=178043 5 <rdar://problem/34076639> 6 7 Reviewed by Tim Horton. 8 9 Tests: http/tests/paymentrequest/payment-request-abort-method.https.html 10 http/tests/paymentrequest/payment-request-show-method.https.html 11 12 * Modules/applepay/PaymentCoordinator.h: 13 * Modules/applepay/PaymentSession.h: Virtually inherited from PaymentSessionBase to 14 accommodate ApplePayPaymentHandler inheriting from both this and PaymentHandler. 15 (WebCore::PaymentSession::~PaymentSession): Deleted. 16 * Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp: 17 (WebCore::paymentCoordinator): Virtually inherited from PaymentSessionBase to accommodate 18 ApplePayPaymentHandler inheriting from both this and PaymentSession. 19 (WebCore::ApplePayPaymentHandler::hasActiveSession): Added. Calls PaymentCoordinator::hasActiveSession(). 20 (WebCore::ApplePayPaymentHandler::show): Added. Calls PaymentCoordinator::beginPaymentSession(). 21 (WebCore::ApplePayPaymentHandler::hide): Added. Calls PaymentCoordinator::abortPaymentSession(). 22 * Modules/applepay/paymentrequest/ApplePayPaymentHandler.h: Inherited from PaymentSession in 23 addition to PaymentHandler so that this can be PaymentCoordinator active session. 24 * Modules/paymentrequest/PaymentHandler.cpp: 25 (WebCore::PaymentHandler::create): 26 (WebCore::PaymentHandler::hasActiveSession): 27 * Modules/paymentrequest/PaymentHandler.h: 28 * Modules/paymentrequest/PaymentRequest.cpp: 29 (WebCore::PaymentRequest::~PaymentRequest): 30 (WebCore::PaymentRequest::show): Rejected the promise if PaymentCoordinator has an active session. 31 (WebCore::PaymentRequest::abort): Called stop(). 32 (WebCore::PaymentRequest::canSuspendForDocumentSuspension const): Returned true if state is 33 Interactive and there is an active handler showing. 34 (WebCore::PaymentRequest::stop): Hid the active session if it's showing, then set state to 35 Closed and rejected the show promise. 36 * Modules/paymentrequest/PaymentRequest.h: 37 * Modules/paymentrequest/PaymentSessionBase.h: Added. Inherits from 38 RefCounted<PaymentSessionBase> and defines a virtual destructor. This allows subclasses to 39 virtually inherit a single ref-count to support multiple inheritance. 40 * WebCore.xcodeproj/project.pbxproj: 41 * bindings/scripts/CodeGeneratorJS.pm: 42 (GetGnuVTableOffsetForType): Added ApplePaySession to the list of classes that need a vtable 43 offset of 3. 44 * page/MainFrame.cpp: 45 (WebCore::MainFrame::setPaymentCoordinator): Added a setter for m_paymentCoordinator. 46 * page/MainFrame.h: 47 * testing/Internals.cpp: 48 (WebCore::Internals::Internals): Set the main frame's payment coordinator to a new 49 PaymentCoordinator with MockPaymentCoordinator as its client. 50 * testing/MockPaymentCoordinator.cpp: Added a mock PaymentCoordinatorClient for testing. 51 (WebCore::MockPaymentCoordinator::supportsVersion): 52 (WebCore::MockPaymentCoordinator::canMakePayments): 53 (WebCore::MockPaymentCoordinator::canMakePaymentsWithActiveCard): 54 (WebCore::MockPaymentCoordinator::openPaymentSetup): 55 (WebCore::MockPaymentCoordinator::showPaymentUI): 56 (WebCore::MockPaymentCoordinator::paymentCoordinatorDestroyed): 57 * testing/MockPaymentCoordinator.h: Added. 58 1 59 2017-10-09 Youenn Fablet <youenn@apple.com> 2 60 -
trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.h
r222915 r223076 1 1 /* 2 * Copyright (C) 2015 , 2016Apple Inc. All rights reserved.2 * Copyright (C) 2015-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 48 48 class PaymentCoordinator { 49 49 public: 50 explicit PaymentCoordinator(PaymentCoordinatorClient&);51 ~PaymentCoordinator();50 WEBCORE_EXPORT explicit PaymentCoordinator(PaymentCoordinatorClient&); 51 WEBCORE_EXPORT ~PaymentCoordinator(); 52 52 53 53 bool supportsVersion(unsigned version); -
trunk/Source/WebCore/Modules/applepay/PaymentSession.h
r223053 r223076 29 29 30 30 #include "ApplePaySessionPaymentRequest.h" 31 #include <wtf/RefCounted.h>31 #include "PaymentSessionBase.h" 32 32 33 33 namespace WebCore { … … 38 38 class URL; 39 39 40 class PaymentSession : public RefCounted<PaymentSession>{40 class PaymentSession : public virtual PaymentSessionBase { 41 41 public: 42 virtual ~PaymentSession() { }43 44 42 virtual void validateMerchant(const URL&) = 0; 45 43 virtual void didAuthorizePayment(const Payment&) = 0; -
trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp
r223053 r223076 35 35 #include "Frame.h" 36 36 #include "JSApplePayRequest.h" 37 #include "LinkIconCollector.h" 37 38 #include "MainFrame.h" 38 39 #include "PaymentContact.h" … … 49 50 auto& url = WTF::get<URL>(identifier); 50 51 return url.host() == "apple.com" && url.path() == "/apple-pay"; 52 } 53 54 static inline PaymentCoordinator& paymentCoordinator(Document& document) 55 { 56 return document.frame()->mainFrame().paymentCoordinator(); 57 } 58 59 bool ApplePayPaymentHandler::hasActiveSession(Document& document) 60 { 61 return paymentCoordinator(document).hasActiveSession(); 51 62 } 52 63 … … 148 159 } 149 160 150 void ApplePayPaymentHandler::show( )161 void ApplePayPaymentHandler::show(Document& document) 151 162 { 152 // FIXME: Call PaymentCoordinator::beginPaymentSession() with m_applePayRequest 163 Vector<URL> linkIconURLs; 164 for (auto& icon : LinkIconCollector { document }.iconsOfTypes({ LinkIconType::TouchIcon, LinkIconType::TouchPrecomposedIcon })) 165 linkIconURLs.append(icon.url); 166 167 paymentCoordinator(document).beginPaymentSession(*this, document.url(), linkIconURLs, *m_applePayRequest); 168 } 169 170 void ApplePayPaymentHandler::hide(Document& document) 171 { 172 paymentCoordinator(document).abortPaymentSession(); 153 173 } 154 174 -
trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.h
r223053 r223076 30 30 #include "ApplePaySessionPaymentRequest.h" 31 31 #include "PaymentHandler.h" 32 #include "PaymentSession.h" 32 33 #include <wtf/Noncopyable.h> 33 34 #include <wtf/Ref.h> … … 35 36 namespace WebCore { 36 37 37 class Document;38 38 class PaymentRequest; 39 39 40 class ApplePayPaymentHandler final : public PaymentHandler { 41 WTF_MAKE_NONCOPYABLE(ApplePayPaymentHandler); 40 class ApplePayPaymentHandler final : public PaymentHandler, public PaymentSession { 42 41 public: 43 42 static bool handlesIdentifier(const PaymentRequest::MethodIdentifier&); 43 static bool hasActiveSession(Document&); 44 44 45 45 private: 46 friend std::unique_ptr<ApplePayPaymentHandler> std::make_unique<ApplePayPaymentHandler>(PaymentRequest&);46 friend class PaymentHandler; 47 47 explicit ApplePayPaymentHandler(PaymentRequest&); 48 48 49 // PaymentHandler 49 50 ExceptionOr<void> convertData(JSC::ExecState&, JSC::JSValue&&) final; 50 void show() final; 51 void show(Document&) final; 52 void hide(Document&) final; 53 54 // PaymentSession 55 void validateMerchant(const URL&) final { } 56 void didAuthorizePayment(const Payment&) final { } 57 void didSelectShippingMethod(const ApplePaySessionPaymentRequest::ShippingMethod&) final { } 58 void didSelectShippingContact(const PaymentContact&) final { } 59 void didSelectPaymentMethod(const PaymentMethod&) final { } 60 void didCancelPaymentSession() final { } 51 61 52 62 Ref<PaymentRequest> m_paymentRequest; -
trunk/Source/WebCore/Modules/paymentrequest/PaymentHandler.cpp
r223053 r223076 35 35 namespace WebCore { 36 36 37 std::unique_ptr<PaymentHandler> PaymentHandler::create(PaymentRequest& paymentRequest, const PaymentRequest::MethodIdentifier& identifier)37 RefPtr<PaymentHandler> PaymentHandler::create(PaymentRequest& paymentRequest, const PaymentRequest::MethodIdentifier& identifier) 38 38 { 39 39 #if ENABLE(APPLE_PAY) 40 40 if (ApplePayPaymentHandler::handlesIdentifier(identifier)) 41 return std::make_unique<ApplePayPaymentHandler>(paymentRequest);41 return adoptRef(new ApplePayPaymentHandler(paymentRequest)); 42 42 #else 43 43 UNUSED_PARAM(paymentRequest); … … 48 48 } 49 49 50 bool PaymentHandler::hasActiveSession(Document& document) 51 { 52 #if ENABLE(APPLE_PAY) 53 return ApplePayPaymentHandler::hasActiveSession(document); 54 #else 55 UNUSED_PARAM(document); 56 return false; 57 #endif 58 } 59 50 60 } // namespace WebCore 51 61 -
trunk/Source/WebCore/Modules/paymentrequest/PaymentHandler.h
r223053 r223076 29 29 30 30 #include "PaymentRequest.h" 31 #include "PaymentSessionBase.h" 31 32 32 33 namespace JSC { … … 37 38 namespace WebCore { 38 39 39 class PaymentHandler { 40 class Document; 41 42 class PaymentHandler : public virtual PaymentSessionBase { 40 43 public: 41 static std::unique_ptr<PaymentHandler> create(PaymentRequest&, const PaymentRequest::MethodIdentifier&);42 virtual ~PaymentHandler() = default;44 static RefPtr<PaymentHandler> create(PaymentRequest&, const PaymentRequest::MethodIdentifier&); 45 static bool hasActiveSession(Document&); 43 46 44 47 virtual ExceptionOr<void> convertData(JSC::ExecState&, JSC::JSValue&&) = 0; 45 virtual void show() = 0; 48 virtual void show(Document&) = 0; 49 virtual void hide(Document&) = 0; 46 50 }; 47 51 -
trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp
r223053 r223076 337 337 PaymentRequest::~PaymentRequest() 338 338 { 339 ASSERT(!hasPendingActivity()); 340 ASSERT(!m_activePaymentHandler); 339 341 } 340 342 … … 350 352 } 351 353 352 // FIXME: Reject promise with AbortError if PaymentCoordinator already has an active session. 354 auto& document = downcast<Document>(*scriptExecutionContext()); 355 if (PaymentHandler::hasActiveSession(document)) { 356 promise.reject(Exception { AbortError }); 357 return; 358 } 353 359 354 360 m_state = State::Interactive; … … 356 362 m_showPromise = WTFMove(promise); 357 363 358 std::unique_ptr<PaymentHandler> selectedPaymentHandler;364 RefPtr<PaymentHandler> selectedPaymentHandler; 359 365 for (auto& paymentMethod : m_serializedMethodData) { 360 auto scope = DECLARE_THROW_SCOPE( scriptExecutionContext()->vm());361 JSC::JSValue data = JSONParse( scriptExecutionContext()->execState(), paymentMethod.serializedData);366 auto scope = DECLARE_THROW_SCOPE(document.vm()); 367 JSC::JSValue data = JSONParse(document.execState(), paymentMethod.serializedData); 362 368 if (scope.exception()) { 363 369 m_showPromise->reject(Exception { ExistingExceptionError }); … … 369 375 continue; 370 376 371 auto result = handler->convertData(* scriptExecutionContext()->execState(), WTFMove(data));377 auto result = handler->convertData(*document.execState(), WTFMove(data)); 372 378 if (result.hasException()) { 373 379 m_showPromise->reject(result.releaseException()); … … 384 390 } 385 391 386 selectedPaymentHandler->show(); 392 ASSERT(!m_activePaymentHandler); 393 m_activePaymentHandler = WTFMove(selectedPaymentHandler); 394 395 m_activePaymentHandler->show(document); 396 setPendingActivity(this); 387 397 } 388 398 … … 393 403 return Exception { InvalidStateError }; 394 404 395 m_state = State::Closed; 396 ASSERT(m_showPromise); 397 m_showPromise->reject(Exception { AbortError }); 405 stop(); 398 406 promise.resolve(); 399 407 return { }; … … 424 432 } 425 433 434 bool PaymentRequest::canSuspendForDocumentSuspension() const 435 { 436 switch (m_state) { 437 case State::Created: 438 case State::Closed: 439 ASSERT(!m_activePaymentHandler); 440 return true; 441 case State::Interactive: 442 return !m_activePaymentHandler; 443 } 444 } 445 446 void PaymentRequest::stop() 447 { 448 if (m_state != State::Interactive) 449 return; 450 451 if (auto paymentHandler = std::exchange(m_activePaymentHandler, nullptr)) { 452 unsetPendingActivity(this); 453 paymentHandler->hide(downcast<Document>(*scriptExecutionContext())); 454 } 455 456 ASSERT(m_state == State::Interactive); 457 m_state = State::Closed; 458 m_showPromise->reject(Exception { AbortError }); 459 } 460 426 461 } // namespace WebCore 427 462 -
trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.h
r223053 r223076 41 41 class Document; 42 42 class PaymentAddress; 43 class PaymentHandler; 43 44 class PaymentResponse; 44 45 enum class PaymentShippingType; … … 86 87 // ActiveDOMObject 87 88 const char* activeDOMObjectName() const final { return "PaymentRequest"; } 88 bool canSuspendForDocumentSuspension() const final { return true; }89 void stop() final { }89 bool canSuspendForDocumentSuspension() const final; 90 void stop() final; 90 91 91 92 // EventTarget … … 103 104 State m_state { State::Created }; 104 105 std::optional<ShowPromise> m_showPromise; 105 std::optional<AbortPromise> m_abortPromise;106 106 std::optional<CanMakePaymentPromise> m_canMakePaymentPromise; 107 RefPtr<PaymentHandler> m_activePaymentHandler; 107 108 }; 108 109 -
trunk/Source/WebCore/Modules/paymentrequest/PaymentSessionBase.h
r223073 r223076 26 26 #pragma once 27 27 28 #if ENABLE( PAYMENT_REQUEST)28 #if ENABLE(APPLE_PAY) || ENABLE(PAYMENT_REQUEST) 29 29 30 #include "PaymentRequest.h" 31 32 namespace JSC { 33 class ExecState; 34 class JSValue; 35 } 30 #include <wtf/RefCounted.h> 36 31 37 32 namespace WebCore { 38 33 39 class PaymentHandler { 40 public: 41 static std::unique_ptr<PaymentHandler> create(PaymentRequest&, const PaymentRequest::MethodIdentifier&); 42 virtual ~PaymentHandler() = default; 43 44 virtual ExceptionOr<void> convertData(JSC::ExecState&, JSC::JSValue&&) = 0; 45 virtual void show() = 0; 34 struct PaymentSessionBase : RefCounted<PaymentSessionBase> { 35 virtual ~PaymentSessionBase() = default; 46 36 }; 47 37 48 38 } // namespace WebCore 49 39 50 #endif // ENABLE( PAYMENT_REQUEST)40 #endif // ENABLE(APPLE_PAY) || ENABLE(PAYMENT_REQUEST) -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r223053 r223076 2348 2348 517A534F1F54A8BA00DCDC0A /* ServiceWorkerRegistrationData.h in Headers */ = {isa = PBXBuildFile; fileRef = 517A534C1F549D4A00DCDC0A /* ServiceWorkerRegistrationData.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2349 2349 517A53581F5889E800DCDC0A /* FetchLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 4147E2B61C89912600A7E715 /* FetchLoaderClient.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2350 517A535A1F5889EF00DCDC0A /* FetchLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 4147E2B51C89912600A7E715 /* FetchLoader.h */; settings = {ATTRIBUTES = (Private, ); }; };2351 2350 517A535B1F588A4C00DCDC0A /* FetchBodyConsumer.h in Headers */ = {isa = PBXBuildFile; fileRef = 41CF8BE51D46222000707DC9 /* FetchBodyConsumer.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2352 2351 517A535D1F5899FE00DCDC0A /* ServiceWorkerFetchResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 517A535C1F5899F200DCDC0A /* ServiceWorkerFetchResult.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 4439 4438 A17C81230F2A5CF7005DAAEB /* HTMLElementFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = A17C81210F2A5CF7005DAAEB /* HTMLElementFactory.h */; }; 4440 4439 A17D275E1EAC579800BF01E7 /* MediaSelectionOption.h in Headers */ = {isa = PBXBuildFile; fileRef = A17D275D1EAC579800BF01E7 /* MediaSelectionOption.h */; settings = {ATTRIBUTES = (Private, ); }; }; 4440 A17FEE641F8893220021E811 /* PaymentSessionBase.h in Headers */ = {isa = PBXBuildFile; fileRef = A17FEE631F8893220021E811 /* PaymentSessionBase.h */; }; 4441 4441 A182D5B71BE722670087A7CC /* SettingsCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = A182D5B61BE722620087A7CC /* SettingsCocoa.mm */; }; 4442 4442 A185B4291E8211A100DC9118 /* PreviewLoader.mm in Sources */ = {isa = PBXBuildFile; fileRef = A185B4271E8211A100DC9118 /* PreviewLoader.mm */; }; … … 4450 4450 A19D934B1AA11B1E00B46C24 /* NetworkExtensionContentFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = A19D93491AA11B1E00B46C24 /* NetworkExtensionContentFilter.h */; }; 4451 4451 A1AA9AB91D23911500FEADB3 /* ContentFilterBlockedPage.html in Resources */ = {isa = PBXBuildFile; fileRef = A1AA9AB81D23911500FEADB3 /* ContentFilterBlockedPage.html */; }; 4452 A1AFEDE61F8BFF6D0087013F /* MockPaymentCoordinator.h in Headers */ = {isa = PBXBuildFile; fileRef = A1AFEDE41F8BFF6D0087013F /* MockPaymentCoordinator.h */; }; 4453 A1AFEDE71F8BFF6D0087013F /* MockPaymentCoordinator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1AFEDE51F8BFF6D0087013F /* MockPaymentCoordinator.cpp */; }; 4452 4454 A1B5B29E1AAA846E008B6042 /* MockContentFilterSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1B5B29C1AAA846E008B6042 /* MockContentFilterSettings.cpp */; }; 4453 4455 A1B5B29F1AAA846F008B6042 /* MockContentFilterSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = A1B5B29D1AAA846E008B6042 /* MockContentFilterSettings.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 12923 12925 A17C81210F2A5CF7005DAAEB /* HTMLElementFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLElementFactory.h; sourceTree = "<group>"; }; 12924 12926 A17D275D1EAC579800BF01E7 /* MediaSelectionOption.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MediaSelectionOption.h; sourceTree = "<group>"; }; 12927 A17FEE631F8893220021E811 /* PaymentSessionBase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PaymentSessionBase.h; sourceTree = "<group>"; }; 12925 12928 A182D5B61BE722620087A7CC /* SettingsCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SettingsCocoa.mm; sourceTree = "<group>"; }; 12926 12929 A185B4271E8211A100DC9118 /* PreviewLoader.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PreviewLoader.mm; sourceTree = "<group>"; }; … … 12935 12938 A19D93491AA11B1E00B46C24 /* NetworkExtensionContentFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkExtensionContentFilter.h; sourceTree = "<group>"; }; 12936 12939 A1AA9AB81D23911500FEADB3 /* ContentFilterBlockedPage.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = ContentFilterBlockedPage.html; sourceTree = "<group>"; }; 12940 A1AFEDE41F8BFF6D0087013F /* MockPaymentCoordinator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MockPaymentCoordinator.h; sourceTree = "<group>"; }; 12941 A1AFEDE51F8BFF6D0087013F /* MockPaymentCoordinator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MockPaymentCoordinator.cpp; sourceTree = "<group>"; }; 12937 12942 A1B5B29C1AAA846E008B6042 /* MockContentFilterSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MockContentFilterSettings.cpp; sourceTree = "<group>"; }; 12938 12943 A1B5B29D1AAA846E008B6042 /* MockContentFilterSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MockContentFilterSettings.h; sourceTree = "<group>"; }; … … 18227 18232 2DAAE32C19DCAF6000E002D2 /* MockPageOverlayClient.cpp */, 18228 18233 2DAAE32D19DCAF6000E002D2 /* MockPageOverlayClient.h */, 18234 A1AFEDE51F8BFF6D0087013F /* MockPaymentCoordinator.cpp */, 18235 A1AFEDE41F8BFF6D0087013F /* MockPaymentCoordinator.h */, 18229 18236 A14061891E2ECA0A0032B34E /* MockPreviewLoaderClient.cpp */, 18230 18237 A140618A1E2ECA0A0032B34E /* MockPreviewLoaderClient.h */, … … 21765 21772 A1F76B3A1F44CF240014C318 /* PaymentResponse.h */, 21766 21773 A1F76B3C1F44CF240014C318 /* PaymentResponse.idl */, 21774 A17FEE631F8893220021E811 /* PaymentSessionBase.h */, 21767 21775 A1F76B521F44D2C70014C318 /* PaymentShippingOption.h */, 21768 21776 A1F76B541F44D2C70014C318 /* PaymentShippingOption.idl */, … … 22172 22180 E446140E0CD6826900FADA75 /* JSHTMLVideoElement.cpp */, 22173 22181 E446140F0CD6826900FADA75 /* JSHTMLVideoElement.h */, 22174 7C7903B71F86FDE400463A70 /* JSImageBitmapRenderingContext.cpp */,22175 7C7903B81F86FDE600463A70 /* JSImageBitmapRenderingContext.h */,22176 22182 31D26BC61F86D269008FF255 /* JSImageBitmap.cpp */, 22177 22183 31D26BC31F86D265008FF255 /* JSImageBitmap.h */, 22178 22184 31D26BC41F86D266008FF255 /* JSImageBitmapOptions.cpp */, 22179 22185 31D26BC51F86D268008FF255 /* JSImageBitmapOptions.h */, 22186 7C7903B71F86FDE400463A70 /* JSImageBitmapRenderingContext.cpp */, 22187 7C7903B81F86FDE600463A70 /* JSImageBitmapRenderingContext.h */, 22180 22188 A77979240D6B9E64003851B9 /* JSImageData.cpp */, 22181 22189 A77979250D6B9E64003851B9 /* JSImageData.h */, … … 27143 27151 2D6F3E911C1ECB2F0061DBD4 /* MockPageOverlay.h in Headers */, 27144 27152 2D97F04819DD4140001EE9C3 /* MockPageOverlayClient.h in Headers */, 27153 A1AFEDE61F8BFF6D0087013F /* MockPaymentCoordinator.h in Headers */, 27145 27154 A140618C1E2ECA0A0032B34E /* MockPreviewLoaderClient.h in Headers */, 27146 27155 AA5F3B8D16CC33D100455EB0 /* PlatformSpeechSynthesizerMock.h in Headers */, … … 27972 27981 84730D871248F0B300D3A9C9 /* FEOffset.h in Headers */, 27973 27982 84730D891248F0B300D3A9C9 /* FESpecularLighting.h in Headers */, 27983 517A535B1F588A4C00DCDC0A /* FetchBodyConsumer.h in Headers */, 27974 27984 4129C9971F59B963009D7403 /* FetchBodySource.h in Headers */, 27975 27985 41D129DB1F3D143800D15E47 /* FetchHeaders.h in Headers */, 27986 517A53581F5889E800DCDC0A /* FetchLoaderClient.h in Headers */, 27976 27987 41AD753A1CEF6BD100A31486 /* FetchOptions.h in Headers */, 27977 27988 7CE1914D1F2A9AFB00272F78 /* FetchReferrerPolicy.h in Headers */, … … 28191 28202 977B3867122883E900B81FF8 /* HTMLDocumentParser.h in Headers */, 28192 28203 93F198E608245E59001E9ABC /* HTMLElement.h in Headers */, 28193 517A53581F5889E800DCDC0A /* FetchLoaderClient.h in Headers */,28194 28204 A17C81230F2A5CF7005DAAEB /* HTMLElementFactory.h in Headers */, 28195 28205 977B37241228721700B81FF8 /* HTMLElementStack.h in Headers */, … … 28819 28829 838EF53C1DC14A7C008F0C39 /* JSIDBTransactionMode.h in Headers */, 28820 28830 269239961505E1AA009E57FC /* JSIDBVersionChangeEvent.h in Headers */, 28831 7C7761AA1F878AA500F869FC /* JSImageBitmapRenderingContext.h in Headers */, 28821 28832 A77979290D6B9E64003851B9 /* JSImageData.h in Headers */, 28822 28833 7C193C011F5E11050088F3E6 /* JSImageSmoothingQuality.h in Headers */, … … 29369 29380 37C738EF1EDBD71B003F2B0B /* MathMLUnknownElement.h in Headers */, 29370 29381 439046EA12DA25E812AF80AC /* MathOperator.h in Headers */, 29371 517A535B1F588A4C00DCDC0A /* FetchBodyConsumer.h in Headers */,29372 29382 49D5DC2C0F423A73008F20FD /* Matrix3DTransformOperation.h in Headers */, 29373 29383 49E911C70EF86D47009D0CAF /* MatrixTransformOperation.h in Headers */, … … 29443 29453 CDDC1E7A18A952F30027A9D4 /* MediaSourcePrivateClient.h in Headers */, 29444 29454 CD61FE681794AADB004101EB /* MediaSourceRegistry.h in Headers */, 29445 7C7761AA1F878AA500F869FC /* JSImageBitmapRenderingContext.h in Headers */,29446 29455 078E091517D14D1C00420AA1 /* MediaStream.h in Headers */, 29447 29456 078E094C17D1709600420AA1 /* MediaStreamAudioDestinationNode.h in Headers */, … … 29526 29535 A19D934B1AA11B1E00B46C24 /* NetworkExtensionContentFilter.h in Headers */, 29527 29536 628D214C12131ED10055DCFC /* NetworkingContext.h in Headers */, 29528 517A535D1F5899FE00DCDC0A /* ServiceWorkerFetchResult.h in Headers */,29529 29537 8A81BF8511DCFD9000DA2B98 /* NetworkLoadMetrics.h in Headers */, 29530 29538 59C27F07138D28CF0079B7E2 /* NetworkResourcesData.h in Headers */, … … 29659 29667 A1F76B3D1F44CF240014C318 /* PaymentResponse.h in Headers */, 29660 29668 A1491DA31F859D870095F5D4 /* PaymentSession.h in Headers */, 29669 A17FEE641F8893220021E811 /* PaymentSessionBase.h in Headers */, 29661 29670 A1F76B551F44D2C70014C318 /* PaymentShippingOption.h in Headers */, 29662 29671 A1F76B491F44D07A0014C318 /* PaymentShippingType.h in Headers */, … … 30144 30153 51F1755D1F3EBC8300C74950 /* ServiceWorker.h in Headers */, 30145 30154 51F1755F1F3EBC8300C74950 /* ServiceWorkerContainer.h in Headers */, 30155 517A535D1F5899FE00DCDC0A /* ServiceWorkerFetchResult.h in Headers */, 30146 30156 51F175611F3EBC8300C74950 /* ServiceWorkerGlobalScope.h in Headers */, 30147 30157 51F175631F3EBC8300C74950 /* ServiceWorkerJob.h in Headers */, … … 31341 31351 2D6F3E901C1ECB270061DBD4 /* MockPageOverlay.cpp in Sources */, 31342 31352 2D97F04719DD413C001EE9C3 /* MockPageOverlayClient.cpp in Sources */, 31353 A1AFEDE71F8BFF6D0087013F /* MockPaymentCoordinator.cpp in Sources */, 31343 31354 A140618B1E2ECA0A0032B34E /* MockPreviewLoaderClient.cpp in Sources */, 31344 31355 AA5F3B8F16CC4B3900455EB0 /* PlatformSpeechSynthesizerMock.cpp in Sources */, … … 31750 31761 BC64B4DB0CB4298A005F2B62 /* CSSFontSelector.cpp in Sources */, 31751 31762 C2E38F011E84573500CA3ADF /* CSSFontStyleRangeValue.cpp in Sources */, 31752 7C7761A81F878A8B00F869FC /* JSImageBitmapRenderingContext.cpp in Sources */,31753 31763 C2E38EFD1E8396FD00CA3ADF /* CSSFontStyleValue.cpp in Sources */, 31754 31764 A80E6CF10A1989CA007FB8C5 /* CSSFontValue.cpp in Sources */, … … 32393 32403 C3CF17A615B0063F00276D39 /* IdTargetObserverRegistry.cpp in Sources */, 32394 32404 B275356F0B053814002CE64F /* Image.cpp in Sources */, 32405 31D26BCB1F87065B008FF255 /* ImageBitmap.cpp in Sources */, 32395 32406 7C7903B41F86F95C00463A70 /* ImageBitmapRenderingContext.cpp in Sources */, 32396 31D26BCB1F87065B008FF255 /* ImageBitmap.cpp in Sources */,32397 32407 43D2597713C816F400608559 /* ImageBuffer.cpp in Sources */, 32398 32408 B2A10B940B3818D700099AA4 /* ImageBufferCG.cpp in Sources */, … … 32866 32876 31D26BC81F87063D008FF255 /* JSImageBitmap.cpp in Sources */, 32867 32877 31D26BCA1F870645008FF255 /* JSImageBitmapOptions.cpp in Sources */, 32878 7C7761A81F878A8B00F869FC /* JSImageBitmapRenderingContext.cpp in Sources */, 32868 32879 A77979280D6B9E64003851B9 /* JSImageData.cpp in Sources */, 32869 32880 A7D0318E0E93540300E24ACD /* JSImageDataCustom.cpp in Sources */, -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r223053 r223076 3523 3523 { 3524 3524 my $typename = shift; 3525 if ($typename eq "SVGAElement" 3525 if ($typename eq "ApplePaySession" 3526 || $typename eq "SVGAElement" 3526 3527 || $typename eq "SVGCircleElement" 3527 3528 || $typename eq "SVGClipPathElement" -
trunk/Source/WebCore/page/MainFrame.cpp
r219595 r223076 1 1 /* 2 * Copyright (C) 2013-201 6Apple Inc. All rights reserved.2 * Copyright (C) 2013-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 138 138 #endif 139 139 140 #if ENABLE(APPLE_PAY) 141 void MainFrame::setPaymentCoordinator(std::unique_ptr<PaymentCoordinator>&& paymentCoordinator) 142 { 143 m_paymentCoordinator = WTFMove(paymentCoordinator); 140 144 } 145 #endif 146 147 } -
trunk/Source/WebCore/page/MainFrame.h
r219008 r223076 1 1 /* 2 * Copyright (C) 2013-201 4Apple Inc. All rights reserved.2 * Copyright (C) 2013-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 65 65 #if ENABLE(APPLE_PAY) 66 66 PaymentCoordinator& paymentCoordinator() const { return *m_paymentCoordinator; } 67 WEBCORE_EXPORT void setPaymentCoordinator(std::unique_ptr<PaymentCoordinator>&&); 67 68 #endif 68 69 -
trunk/Source/WebCore/testing/Internals.cpp
r223073 r223076 242 242 #endif 243 243 244 #if ENABLE(APPLE_PAY) 245 #include "MockPaymentCoordinator.h" 246 #include "PaymentCoordinator.h" 247 #endif 248 244 249 using JSC::CallData; 245 250 using JSC::CallType; … … 501 506 502 507 setConsoleMessageListener(nullptr); 508 509 #if ENABLE(APPLE_PAY) 510 document.frame()->mainFrame().setPaymentCoordinator(std::make_unique<PaymentCoordinator>(*new MockPaymentCoordinator())); 511 #endif 503 512 } 504 513 -
trunk/Source/WebCore/testing/MockPaymentCoordinator.cpp
r223073 r223076 25 25 26 26 #include "config.h" 27 #include "PaymentHandler.h" 28 29 #if ENABLE(PAYMENT_REQUEST) 27 #include "MockPaymentCoordinator.h" 30 28 31 29 #if ENABLE(APPLE_PAY) 32 #include "ApplePayPaymentHandler.h" 33 # endif30 31 #include <wtf/RunLoop.h> 34 32 35 33 namespace WebCore { 36 34 37 std::unique_ptr<PaymentHandler> PaymentHandler::create(PaymentRequest& paymentRequest, const PaymentRequest::MethodIdentifier& identifier)35 bool MockPaymentCoordinator::supportsVersion(unsigned version) 38 36 { 39 #if ENABLE(APPLE_PAY) 40 if (ApplePayPaymentHandler::handlesIdentifier(identifier)) 41 return std::make_unique<ApplePayPaymentHandler>(paymentRequest); 37 ASSERT(version > 0); 38 39 #if !ENABLE(APPLE_PAY_SESSION_V3) 40 static const unsigned currentVersion = 2; 42 41 #else 43 UNUSED_PARAM(paymentRequest); 44 UNUSED_PARAM(identifier); 42 static const unsigned currentVersion = 3; 45 43 #endif 46 44 47 return nullptr; 45 return version <= currentVersion; 46 } 47 48 bool MockPaymentCoordinator::canMakePayments() 49 { 50 return true; 51 } 52 53 void MockPaymentCoordinator::canMakePaymentsWithActiveCard(const String&, const String&, WTF::Function<void(bool)>&& completionHandler) 54 { 55 RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler)]() { 56 completionHandler(true); 57 }); 58 } 59 60 void MockPaymentCoordinator::openPaymentSetup(const String&, const String&, WTF::Function<void(bool)>&& completionHandler) 61 { 62 RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler)]() { 63 completionHandler(true); 64 }); 65 } 66 67 bool MockPaymentCoordinator::showPaymentUI(const URL&, const Vector<URL>&, const ApplePaySessionPaymentRequest&) 68 { 69 return true; 70 } 71 72 void MockPaymentCoordinator::paymentCoordinatorDestroyed() 73 { 74 delete this; 48 75 } 49 76 50 77 } // namespace WebCore 51 78 52 #endif // ENABLE( PAYMENT_REQUEST)79 #endif // ENABLE(APPLE_PAY) -
trunk/Source/WebCore/testing/MockPaymentCoordinator.h
r223073 r223076 28 28 #if ENABLE(APPLE_PAY) 29 29 30 #include "ApplePaySessionPaymentRequest.h" 31 #include <wtf/RefCounted.h> 30 #include "PaymentCoordinatorClient.h" 32 31 33 32 namespace WebCore { 34 33 35 class Payment;36 class PaymentContact; 37 class PaymentMethod;38 class URL;39 40 class PaymentSession : public RefCounted<PaymentSession> { 41 public: 42 v irtual ~PaymentSession(){ }43 44 v irtual void validateMerchant(const URL&) = 0;45 v irtual void didAuthorizePayment(const Payment&) = 0;46 v irtual void didSelectShippingMethod(const ApplePaySessionPaymentRequest::ShippingMethod&) = 0;47 v irtual void didSelectShippingContact(const PaymentContact&) = 0;48 v irtual void didSelectPaymentMethod(const PaymentMethod&) = 0;49 v irtual void didCancelPaymentSession() = 0;34 class MockPaymentCoordinator final : public PaymentCoordinatorClient { 35 private: 36 bool supportsVersion(unsigned) final; 37 bool canMakePayments() final; 38 void canMakePaymentsWithActiveCard(const String&, const String&, WTF::Function<void(bool)>&&); 39 void openPaymentSetup(const String&, const String&, WTF::Function<void(bool)>&&); 40 bool showPaymentUI(const URL&, const Vector<URL>&, const ApplePaySessionPaymentRequest&) final; 41 void completeMerchantValidation(const PaymentMerchantSession&) final { } 42 void completeShippingMethodSelection(std::optional<ShippingMethodUpdate>&&) final { } 43 void completeShippingContactSelection(std::optional<ShippingContactUpdate>&&) final { } 44 void completePaymentMethodSelection(std::optional<PaymentMethodUpdate>&&) final { } 45 void completePaymentSession(std::optional<PaymentAuthorizationResult>&&) final { } 46 void abortPaymentSession() final { } 47 void cancelPaymentSession() final { } 48 void paymentCoordinatorDestroyed() final; 50 49 }; 51 50
Note: See TracChangeset
for help on using the changeset viewer.