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

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

Issue 2029473002: PaymentRequest should throw if not in top context. (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 | « third_party/WebKit/LayoutTests/payments/payment-request-in-iframe.html ('k') | no next file » | 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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
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()->frame() || !scriptState->domWindow()->frame() ->isMainFrame()) {
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
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
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/payments/payment-request-in-iframe.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698