Move the user gesture requirement to the ApplePaySession constructor
https://bugs.webkit.org/show_bug.cgi?id=159225
rdar://problem/26507267
Reviewed by Tim Horton.
By doing this, clients can do pre-validation before showing the sheet, while we still maintain the user gesture requirement.
* Modules/applepay/ApplePaySession.cpp:
(WebCore::ApplePaySession::create):
(WebCore::ApplePaySession::begin): Deleted.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@202584 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index e58cbc7..15d7b82 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,17 @@
+2016-06-28 Anders Carlsson <andersca@apple.com>
+
+ Move the user gesture requirement to the ApplePaySession constructor
+ https://bugs.webkit.org/show_bug.cgi?id=159225
+ rdar://problem/26507267
+
+ Reviewed by Tim Horton.
+
+ By doing this, clients can do pre-validation before showing the sheet, while we still maintain the user gesture requirement.
+
+ * Modules/applepay/ApplePaySession.cpp:
+ (WebCore::ApplePaySession::create):
+ (WebCore::ApplePaySession::begin): Deleted.
+
2016-06-28 Youenn Fablet <youenn@apple.com>
Iterable interfaces should have their related prototype @@iterator property writable
diff --git a/Source/WebCore/Modules/applepay/ApplePaySession.cpp b/Source/WebCore/Modules/applepay/ApplePaySession.cpp
index bbd8423..68a03ac6 100644
--- a/Source/WebCore/Modules/applepay/ApplePaySession.cpp
+++ b/Source/WebCore/Modules/applepay/ApplePaySession.cpp
@@ -647,6 +647,12 @@
return nullptr;
}
+ if (!ScriptController::processingUserGesture()) {
+ window.printErrorMessage("Must create a new ApplePaySession from a user gesture handler.");
+ ec = INVALID_ACCESS_ERR;
+ return nullptr;
+ }
+
auto& paymentCoordinator = document.frame()->mainFrame().paymentCoordinator();
if (!version || !paymentCoordinator.supportsVersion(version)) {
@@ -762,13 +768,6 @@
auto& document = *downcast<Document>(scriptExecutionContext());
auto& window = *document.domWindow();
- if (!ScriptController::processingUserGesture()) {
- window.printErrorMessage("Must call ApplePaySession.begin from a user gesture handler.");
-
- ec = INVALID_ACCESS_ERR;
- return;
- }
-
if (!canBegin()) {
window.printErrorMessage("Payment session is already active.");
ec = INVALID_ACCESS_ERR;