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/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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
294 EventTargetWithInlineData::trace(visitor); | 294 EventTargetWithInlineData::trace(visitor); |
295 ContextLifecycleObserver::trace(visitor); | 295 ContextLifecycleObserver::trace(visitor); |
296 } | 296 } |
297 | 297 |
298 PaymentRequest::PaymentRequest(ScriptState* scriptState, const Vector<String>& s upportedMethods, const PaymentDetails& details, const PaymentOptions& options, c onst ScriptValue& data, ExceptionState& exceptionState) | 298 PaymentRequest::PaymentRequest(ScriptState* scriptState, const Vector<String>& s upportedMethods, const PaymentDetails& details, const PaymentOptions& options, c onst ScriptValue& data, ExceptionState& exceptionState) |
299 : ContextLifecycleObserver(scriptState->getExecutionContext()) | 299 : ContextLifecycleObserver(scriptState->getExecutionContext()) |
300 , ActiveScriptWrappable(this) | 300 , ActiveScriptWrappable(this) |
301 , m_options(options) | 301 , m_options(options) |
302 , m_clientBinding(this) | 302 , m_clientBinding(this) |
303 { | 303 { |
304 // TODO(rouslan): Also check for a top-level browsing context. | |
305 // https://github.com/w3c/browser-payment-api/issues/2 | |
306 if (!scriptState->getExecutionContext()->isSecureContext()) { | 304 if (!scriptState->getExecutionContext()->isSecureContext()) { |
307 exceptionState.throwSecurityError("Must be in a secure context"); | 305 exceptionState.throwSecurityError("Must be in a secure context"); |
308 return; | 306 return; |
309 } | 307 } |
310 | 308 |
309 if (scriptState->domWindow() != scriptState->domWindow()->top()) { | |
Marijn Kruisselbrink
2016/06/01 00:19:25
I believe this check is more typically written as
please use gerrit instead
2016/06/01 00:42:29
Done.
| |
310 exceptionState.throwSecurityError("Must be in a top-level browsing conte xt"); | |
311 return; | |
312 } | |
313 | |
311 if (supportedMethods.isEmpty()) { | 314 if (supportedMethods.isEmpty()) { |
312 exceptionState.throwTypeError("Must specify at least one payment method identifier"); | 315 exceptionState.throwTypeError("Must specify at least one payment method identifier"); |
313 return; | 316 return; |
314 } | 317 } |
315 m_supportedMethods = supportedMethods; | 318 m_supportedMethods = supportedMethods; |
316 | 319 |
317 validatePaymentDetails(details, exceptionState); | 320 validatePaymentDetails(details, exceptionState); |
318 if (exceptionState.hadException()) | 321 if (exceptionState.hadException()) |
319 return; | 322 return; |
320 m_details = details; | 323 m_details = details; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
440 void PaymentRequest::clearResolversAndCloseMojoConnection() | 443 void PaymentRequest::clearResolversAndCloseMojoConnection() |
441 { | 444 { |
442 m_completeResolver.clear(); | 445 m_completeResolver.clear(); |
443 m_showResolver.clear(); | 446 m_showResolver.clear(); |
444 if (m_clientBinding.is_bound()) | 447 if (m_clientBinding.is_bound()) |
445 m_clientBinding.Close(); | 448 m_clientBinding.Close(); |
446 m_paymentProvider.reset(); | 449 m_paymentProvider.reset(); |
447 } | 450 } |
448 | 451 |
449 } // namespace blink | 452 } // namespace blink |
OLD | NEW |