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

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

Issue 2701993002: DO NOT COMMIT: Results of running new (proposed) clang-format on Blink (Closed)
Patch Set: Created 3 years, 10 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
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 <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 #include "bindings/core/v8/ConditionalFeatures.h" 9 #include "bindings/core/v8/ConditionalFeatures.h"
10 #include "bindings/core/v8/ExceptionState.h" 10 #include "bindings/core/v8/ExceptionState.h"
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 PaymentRequest::~PaymentRequest() {} 649 PaymentRequest::~PaymentRequest() {}
650 650
651 ScriptPromise PaymentRequest::show(ScriptState* scriptState) { 651 ScriptPromise PaymentRequest::show(ScriptState* scriptState) {
652 if (!m_paymentProvider.is_bound() || m_showResolver) 652 if (!m_paymentProvider.is_bound() || m_showResolver)
653 return ScriptPromise::rejectWithDOMException( 653 return ScriptPromise::rejectWithDOMException(
654 scriptState, 654 scriptState,
655 DOMException::create(InvalidStateError, "Already called show() once")); 655 DOMException::create(InvalidStateError, "Already called show() once"));
656 656
657 if (!scriptState->domWindow() || !scriptState->domWindow()->frame()) 657 if (!scriptState->domWindow() || !scriptState->domWindow()->frame())
658 return ScriptPromise::rejectWithDOMException( 658 return ScriptPromise::rejectWithDOMException(
659 scriptState, DOMException::create(InvalidStateError, 659 scriptState,
660 "Cannot show the payment request")); 660 DOMException::create(InvalidStateError,
661 "Cannot show the payment request"));
661 662
662 m_paymentProvider->Show(); 663 m_paymentProvider->Show();
663 664
664 m_showResolver = ScriptPromiseResolver::create(scriptState); 665 m_showResolver = ScriptPromiseResolver::create(scriptState);
665 return m_showResolver->promise(); 666 return m_showResolver->promise();
666 } 667 }
667 668
668 ScriptPromise PaymentRequest::abort(ScriptState* scriptState) { 669 ScriptPromise PaymentRequest::abort(ScriptState* scriptState) {
669 if (m_abortResolver) 670 if (m_abortResolver)
670 return ScriptPromise::rejectWithDOMException( 671 return ScriptPromise::rejectWithDOMException(
(...skipping 10 matching lines...) Expand all
681 682
682 m_abortResolver = ScriptPromiseResolver::create(scriptState); 683 m_abortResolver = ScriptPromiseResolver::create(scriptState);
683 m_paymentProvider->Abort(); 684 m_paymentProvider->Abort();
684 return m_abortResolver->promise(); 685 return m_abortResolver->promise();
685 } 686 }
686 687
687 ScriptPromise PaymentRequest::canMakePayment(ScriptState* scriptState) { 688 ScriptPromise PaymentRequest::canMakePayment(ScriptState* scriptState) {
688 if (!m_paymentProvider.is_bound() || m_canMakePaymentResolver || 689 if (!m_paymentProvider.is_bound() || m_canMakePaymentResolver ||
689 !scriptState->contextIsValid()) { 690 !scriptState->contextIsValid()) {
690 return ScriptPromise::rejectWithDOMException( 691 return ScriptPromise::rejectWithDOMException(
691 scriptState, DOMException::create(InvalidStateError, 692 scriptState,
692 "Cannot query payment request")); 693 DOMException::create(InvalidStateError,
694 "Cannot query payment request"));
693 } 695 }
694 696
695 m_paymentProvider->CanMakePayment(); 697 m_paymentProvider->CanMakePayment();
696 698
697 m_canMakePaymentResolver = ScriptPromiseResolver::create(scriptState); 699 m_canMakePaymentResolver = ScriptPromiseResolver::create(scriptState);
698 return m_canMakePaymentResolver->promise(); 700 return m_canMakePaymentResolver->promise();
699 } 701 }
700 702
701 bool PaymentRequest::hasPendingActivity() const { 703 bool PaymentRequest::hasPendingActivity() const {
702 return m_showResolver || m_completeResolver; 704 return m_showResolver || m_completeResolver;
703 } 705 }
704 706
705 const AtomicString& PaymentRequest::interfaceName() const { 707 const AtomicString& PaymentRequest::interfaceName() const {
706 return EventTargetNames::PaymentRequest; 708 return EventTargetNames::PaymentRequest;
707 } 709 }
708 710
709 ExecutionContext* PaymentRequest::getExecutionContext() const { 711 ExecutionContext* PaymentRequest::getExecutionContext() const {
710 return ContextLifecycleObserver::getExecutionContext(); 712 return ContextLifecycleObserver::getExecutionContext();
711 } 713 }
712 714
713 ScriptPromise PaymentRequest::complete(ScriptState* scriptState, 715 ScriptPromise PaymentRequest::complete(ScriptState* scriptState,
714 PaymentComplete result) { 716 PaymentComplete result) {
715 if (m_completeResolver) 717 if (m_completeResolver)
716 return ScriptPromise::rejectWithDOMException( 718 return ScriptPromise::rejectWithDOMException(
717 scriptState, DOMException::create(InvalidStateError, 719 scriptState,
718 "Already called complete() once")); 720 DOMException::create(InvalidStateError,
721 "Already called complete() once"));
719 722
720 if (!m_completeTimer.isActive()) 723 if (!m_completeTimer.isActive())
721 return ScriptPromise::rejectWithDOMException( 724 return ScriptPromise::rejectWithDOMException(
722 scriptState, 725 scriptState,
723 DOMException::create( 726 DOMException::create(
724 InvalidStateError, 727 InvalidStateError,
725 "Timed out after 60 seconds, complete() called too late")); 728 "Timed out after 60 seconds, complete() called too late"));
726 729
727 // User has cancelled the transaction while the website was processing it. 730 // User has cancelled the transaction while the website was processing it.
728 if (!m_paymentProvider) 731 if (!m_paymentProvider)
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 m_completeResolver.clear(); 1049 m_completeResolver.clear();
1047 m_showResolver.clear(); 1050 m_showResolver.clear();
1048 m_abortResolver.clear(); 1051 m_abortResolver.clear();
1049 m_canMakePaymentResolver.clear(); 1052 m_canMakePaymentResolver.clear();
1050 if (m_clientBinding.is_bound()) 1053 if (m_clientBinding.is_bound())
1051 m_clientBinding.Close(); 1054 m_clientBinding.Close();
1052 m_paymentProvider.reset(); 1055 m_paymentProvider.reset();
1053 } 1056 }
1054 1057
1055 } // namespace blink 1058 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698