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 11 matching lines...) Expand all Loading... | |
22 #include "modules/payments/AndroidPayTokenization.h" | 22 #include "modules/payments/AndroidPayTokenization.h" |
23 #include "modules/payments/HTMLIFrameElementPayments.h" | 23 #include "modules/payments/HTMLIFrameElementPayments.h" |
24 #include "modules/payments/PaymentAddress.h" | 24 #include "modules/payments/PaymentAddress.h" |
25 #include "modules/payments/PaymentItem.h" | 25 #include "modules/payments/PaymentItem.h" |
26 #include "modules/payments/PaymentRequestUpdateEvent.h" | 26 #include "modules/payments/PaymentRequestUpdateEvent.h" |
27 #include "modules/payments/PaymentResponse.h" | 27 #include "modules/payments/PaymentResponse.h" |
28 #include "modules/payments/PaymentShippingOption.h" | 28 #include "modules/payments/PaymentShippingOption.h" |
29 #include "modules/payments/PaymentsValidators.h" | 29 #include "modules/payments/PaymentsValidators.h" |
30 #include "mojo/public/cpp/bindings/interface_request.h" | 30 #include "mojo/public/cpp/bindings/interface_request.h" |
31 #include "mojo/public/cpp/bindings/wtf_array.h" | 31 #include "mojo/public/cpp/bindings/wtf_array.h" |
32 #include "platform/RuntimeEnabledFeatures.h" | |
32 #include "platform/mojo/MojoHelper.h" | 33 #include "platform/mojo/MojoHelper.h" |
33 #include "public/platform/InterfaceProvider.h" | 34 #include "public/platform/InterfaceProvider.h" |
34 #include "public/platform/Platform.h" | 35 #include "public/platform/Platform.h" |
35 #include "public/platform/WebTraceLocation.h" | 36 #include "public/platform/WebTraceLocation.h" |
36 #include "wtf/HashSet.h" | 37 #include "wtf/HashSet.h" |
37 #include <utility> | 38 #include <utility> |
38 | 39 |
39 using payments::mojom::blink::ActivePaymentQueryResult; | 40 using payments::mojom::blink::ActivePaymentQueryResult; |
40 using payments::mojom::blink::PaymentAddressPtr; | 41 using payments::mojom::blink::PaymentAddressPtr; |
41 using payments::mojom::blink::PaymentCurrencyAmount; | 42 using payments::mojom::blink::PaymentCurrencyAmount; |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
512 | 513 |
513 // 1. If |document| has no browsing context, then return false. | 514 // 1. If |document| has no browsing context, then return false. |
514 if (!frame) | 515 if (!frame) |
515 return false; | 516 return false; |
516 | 517 |
517 // 2. If |document|'s browsing context is a top-level browsing context, then | 518 // 2. If |document|'s browsing context is a top-level browsing context, then |
518 // return true. | 519 // return true. |
519 if (frame->isMainFrame()) | 520 if (frame->isMainFrame()) |
520 return true; | 521 return true; |
521 | 522 |
523 if (!RuntimeEnabledFeatures::paymentRequestIFrameEnabled()) | |
Rick Byers
2016/11/23 16:54:55
nit: this check is now redundant with the check in
please use gerrit instead
2016/11/23 17:27:36
Removed.
| |
524 return false; | |
525 | |
522 // 3. If |document|'s browsing context has a browsing context container that | 526 // 3. If |document|'s browsing context has a browsing context container that |
523 // is an iframe element with an |allowpaymentrequest| attribute specified, and | 527 // is an iframe element with an |allowpaymentrequest| attribute specified, and |
524 // whose node document is allowed to use the feature indicated by | 528 // whose node document is allowed to use the feature indicated by |
525 // |allowpaymentrequest|, then return true. | 529 // |allowpaymentrequest|, then return true. |
526 HTMLFrameOwnerElement* ownerElement = toHTMLFrameOwnerElement(frame->owner()); | 530 HTMLFrameOwnerElement* ownerElement = toHTMLFrameOwnerElement(frame->owner()); |
527 if (ownerElement && isHTMLIFrameElement(ownerElement)) { | 531 if (ownerElement && isHTMLIFrameElement(ownerElement)) { |
528 HTMLIFrameElement* iframe = toHTMLIFrameElement(ownerElement); | 532 HTMLIFrameElement* iframe = toHTMLIFrameElement(ownerElement); |
529 if (HTMLIFrameElementPayments::from(*iframe).allowPaymentRequest(*iframe)) | 533 if (HTMLIFrameElementPayments::from(*iframe).allowPaymentRequest(*iframe)) |
530 return allowedToUsePaymentRequest(frame->tree().parent()); | 534 return allowedToUsePaymentRequest(frame->tree().parent()); |
531 } | 535 } |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
725 if (exceptionState.hadException()) | 729 if (exceptionState.hadException()) |
726 return; | 730 return; |
727 | 731 |
728 if (!scriptState->getExecutionContext()->isSecureContext()) { | 732 if (!scriptState->getExecutionContext()->isSecureContext()) { |
729 exceptionState.throwSecurityError("Must be in a secure context"); | 733 exceptionState.throwSecurityError("Must be in a secure context"); |
730 return; | 734 return; |
731 } | 735 } |
732 | 736 |
733 if (!allowedToUsePaymentRequest(scriptState->domWindow()->frame())) { | 737 if (!allowedToUsePaymentRequest(scriptState->domWindow()->frame())) { |
734 exceptionState.throwSecurityError( | 738 exceptionState.throwSecurityError( |
735 "Must be in a top-level browsing context or an iframe needs to specify " | 739 RuntimeEnabledFeatures::paymentRequestIFrameEnabled() |
736 "'allowpaymentrequest' explicitly"); | 740 ? "Must be in a top-level browsing context or an iframe needs to " |
741 "specify 'allowpaymentrequest' explicitly" | |
742 : "Must be in a top-level browsing context"); | |
737 return; | 743 return; |
738 } | 744 } |
739 | 745 |
740 bool keepShippingOptions = validatePaymentDetails(details, exceptionState); | 746 bool keepShippingOptions = validatePaymentDetails(details, exceptionState); |
741 if (exceptionState.hadException()) | 747 if (exceptionState.hadException()) |
742 return; | 748 return; |
743 | 749 |
744 if (details.hasError() && !details.error().isEmpty()) { | 750 if (details.hasError() && !details.error().isEmpty()) { |
745 exceptionState.throwTypeError("Error value should be empty"); | 751 exceptionState.throwTypeError("Error value should be empty"); |
746 return; | 752 return; |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
963 m_completeResolver.clear(); | 969 m_completeResolver.clear(); |
964 m_showResolver.clear(); | 970 m_showResolver.clear(); |
965 m_abortResolver.clear(); | 971 m_abortResolver.clear(); |
966 m_canMakeActivePaymentResolver.clear(); | 972 m_canMakeActivePaymentResolver.clear(); |
967 if (m_clientBinding.is_bound()) | 973 if (m_clientBinding.is_bound()) |
968 m_clientBinding.Close(); | 974 m_clientBinding.Close(); |
969 m_paymentProvider.reset(); | 975 m_paymentProvider.reset(); |
970 } | 976 } |
971 | 977 |
972 } // namespace blink | 978 } // namespace blink |
OLD | NEW |