| OLD | NEW |
| 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/ScriptPromiseResolver.h" | 8 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 9 #include "bindings/core/v8/ScriptState.h" | 9 #include "bindings/core/v8/ScriptState.h" |
| 10 #include "bindings/core/v8/V8StringResource.h" | 10 #include "bindings/core/v8/V8StringResource.h" |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 | 486 |
| 487 // 2. If |document|'s browsing context is a top-level browsing context, then | 487 // 2. If |document|'s browsing context is a top-level browsing context, then |
| 488 // return true. | 488 // return true. |
| 489 if (frame->isMainFrame()) | 489 if (frame->isMainFrame()) |
| 490 return true; | 490 return true; |
| 491 | 491 |
| 492 // 3. If |document|'s browsing context has a browsing context container that | 492 // 3. If |document|'s browsing context has a browsing context container that |
| 493 // is an iframe element with an |allowpaymentrequest| attribute specified, and | 493 // is an iframe element with an |allowpaymentrequest| attribute specified, and |
| 494 // whose node document is allowed to use the feature indicated by | 494 // whose node document is allowed to use the feature indicated by |
| 495 // |allowpaymentrequest|, then return true. | 495 // |allowpaymentrequest|, then return true. |
| 496 if (RuntimeEnabledFeatures::paymentRequestIFrameEnabled() && frame->owner() && | 496 if (frame->owner() && frame->owner()->allowPaymentRequest()) |
| 497 frame->owner()->allowPaymentRequest()) { | |
| 498 return allowedToUsePaymentRequest(frame->tree().parent()); | 497 return allowedToUsePaymentRequest(frame->tree().parent()); |
| 499 } | |
| 500 | 498 |
| 501 // 4. Return false. | 499 // 4. Return false. |
| 502 return false; | 500 return false; |
| 503 } | 501 } |
| 504 | 502 |
| 505 } // namespace | 503 } // namespace |
| 506 | 504 |
| 507 PaymentRequest* PaymentRequest::create( | 505 PaymentRequest* PaymentRequest::create( |
| 508 Document& document, | 506 Document& document, |
| 509 const HeapVector<PaymentMethodData>& methodData, | 507 const HeapVector<PaymentMethodData>& methodData, |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 if (exceptionState.hadException()) | 685 if (exceptionState.hadException()) |
| 688 return; | 686 return; |
| 689 | 687 |
| 690 if (!document.isSecureContext()) { | 688 if (!document.isSecureContext()) { |
| 691 exceptionState.throwSecurityError("Must be in a secure context"); | 689 exceptionState.throwSecurityError("Must be in a secure context"); |
| 692 return; | 690 return; |
| 693 } | 691 } |
| 694 | 692 |
| 695 if (!allowedToUsePaymentRequest(document.frame())) { | 693 if (!allowedToUsePaymentRequest(document.frame())) { |
| 696 exceptionState.throwSecurityError( | 694 exceptionState.throwSecurityError( |
| 697 RuntimeEnabledFeatures::paymentRequestIFrameEnabled() | 695 "Must be in a top-level browsing context or an iframe needs to specify " |
| 698 ? "Must be in a top-level browsing context or an iframe needs to " | 696 "'allowpaymentrequest' explicitly"); |
| 699 "specify 'allowpaymentrequest' explicitly" | |
| 700 : "Must be in a top-level browsing context"); | |
| 701 return; | 697 return; |
| 702 } | 698 } |
| 703 | 699 |
| 704 PaymentDetailsPtr validatedDetails = | 700 PaymentDetailsPtr validatedDetails = |
| 705 payments::mojom::blink::PaymentDetails::New(); | 701 payments::mojom::blink::PaymentDetails::New(); |
| 706 validateAndConvertPaymentDetails(details, m_options.requestShipping(), | 702 validateAndConvertPaymentDetails(details, m_options.requestShipping(), |
| 707 validatedDetails, m_shippingOption, | 703 validatedDetails, m_shippingOption, |
| 708 exceptionState); | 704 exceptionState); |
| 709 if (exceptionState.hadException()) | 705 if (exceptionState.hadException()) |
| 710 return; | 706 return; |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 924 m_completeResolver.clear(); | 920 m_completeResolver.clear(); |
| 925 m_showResolver.clear(); | 921 m_showResolver.clear(); |
| 926 m_abortResolver.clear(); | 922 m_abortResolver.clear(); |
| 927 m_canMakePaymentResolver.clear(); | 923 m_canMakePaymentResolver.clear(); |
| 928 if (m_clientBinding.is_bound()) | 924 if (m_clientBinding.is_bound()) |
| 929 m_clientBinding.Close(); | 925 m_clientBinding.Close(); |
| 930 m_paymentProvider.reset(); | 926 m_paymentProvider.reset(); |
| 931 } | 927 } |
| 932 | 928 |
| 933 } // namespace blink | 929 } // namespace blink |
| OLD | NEW |