Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: third_party/WebKit/Source/modules/payments/PaymentRequest.cpp

Issue 2083883003: Reject PaymentResponse.complete() promise on error. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/JSONValuesForV8.h" 8 #include "bindings/core/v8/JSONValuesForV8.h"
9 #include "bindings/core/v8/ScriptPromiseResolver.h" 9 #include "bindings/core/v8/ScriptPromiseResolver.h"
10 #include "bindings/core/v8/ScriptState.h" 10 #include "bindings/core/v8/ScriptState.h"
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 ExecutionContext* PaymentRequest::getExecutionContext() const 318 ExecutionContext* PaymentRequest::getExecutionContext() const
319 { 319 {
320 return ContextLifecycleObserver::getExecutionContext(); 320 return ContextLifecycleObserver::getExecutionContext();
321 } 321 }
322 322
323 ScriptPromise PaymentRequest::complete(ScriptState* scriptState, PaymentComplete result) 323 ScriptPromise PaymentRequest::complete(ScriptState* scriptState, PaymentComplete result)
324 { 324 {
325 if (m_completeResolver) 325 if (m_completeResolver)
326 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(InvalidStateError, "Already called complete() once")); 326 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(InvalidStateError, "Already called complete() once"));
327 327
328 // User has cancelled the transaction while the website was processing it.
329 if (!m_paymentProvider)
330 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(InvalidStateError, "Request cancelled"));
Marijn Kruisselbrink 2016/06/21 20:45:50 It seems a bit odd that this throws a different ex
please use gerrit instead 2016/06/21 21:03:01 User cancelling the payment request does not appea
331
328 // The payment provider should respond in PaymentRequest::OnComplete(). 332 // The payment provider should respond in PaymentRequest::OnComplete().
329 m_paymentProvider->Complete(mojom::blink::PaymentComplete(result)); 333 m_paymentProvider->Complete(mojom::blink::PaymentComplete(result));
330 334
331 m_completeResolver = ScriptPromiseResolver::create(scriptState); 335 m_completeResolver = ScriptPromiseResolver::create(scriptState);
332 return m_completeResolver->promise(); 336 return m_completeResolver->promise();
333 } 337 }
334 338
335 void PaymentRequest::onUpdatePaymentDetails(const ScriptValue& detailsScriptValu e) 339 void PaymentRequest::onUpdatePaymentDetails(const ScriptValue& detailsScriptValu e)
336 { 340 {
337 if (!m_showResolver || !m_paymentProvider) 341 if (!m_showResolver || !m_paymentProvider)
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 { 541 {
538 m_completeResolver.clear(); 542 m_completeResolver.clear();
539 m_showResolver.clear(); 543 m_showResolver.clear();
540 m_abortResolver.clear(); 544 m_abortResolver.clear();
541 if (m_clientBinding.is_bound()) 545 if (m_clientBinding.is_bound())
542 m_clientBinding.Close(); 546 m_clientBinding.Close();
543 m_paymentProvider.reset(); 547 m_paymentProvider.reset();
544 } 548 }
545 549
546 } // namespace blink 550 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698