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

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

Issue 2073603002: Add shippingOption to PaymentResponse (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase #2 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
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 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 DCHECK(success); 450 DCHECK(success);
451 ALLOW_UNUSED_LOCAL(success); 451 ALLOW_UNUSED_LOCAL(success);
452 } 452 }
453 453
454 void PaymentRequest::OnPaymentResponse(mojom::blink::PaymentResponsePtr response ) 454 void PaymentRequest::OnPaymentResponse(mojom::blink::PaymentResponsePtr response )
455 { 455 {
456 DCHECK(m_showResolver); 456 DCHECK(m_showResolver);
457 DCHECK(!m_completeResolver); 457 DCHECK(!m_completeResolver);
458 458
459 if (m_options.requestShipping()) { 459 if (m_options.requestShipping()) {
460 if (!response->shipping_address) { 460 if (!response->shipping_address || response->shipping_option.isEmpty()) {
461 m_showResolver->reject(DOMException::create(SyntaxError)); 461 m_showResolver->reject(DOMException::create(SyntaxError));
462 clearResolversAndCloseMojoConnection(); 462 clearResolversAndCloseMojoConnection();
463 return; 463 return;
464 } 464 }
465 465
466 String errorMessage; 466 String errorMessage;
467 if (!PaymentsValidators::isValidShippingAddress(response->shipping_addre ss, &errorMessage)) { 467 if (!PaymentsValidators::isValidShippingAddress(response->shipping_addre ss, &errorMessage)) {
468 m_showResolver->reject(DOMException::create(SyntaxError, errorMessag e)); 468 m_showResolver->reject(DOMException::create(SyntaxError, errorMessag e));
469 clearResolversAndCloseMojoConnection(); 469 clearResolversAndCloseMojoConnection();
470 return; 470 return;
471 } 471 }
472 472
473 m_shippingAddress = new PaymentAddress(response->shipping_address.Clone( )); 473 m_shippingAddress = new PaymentAddress(response->shipping_address.Clone( ));
474 m_shippingOption = response->shipping_option_id; 474 m_shippingOption = response->shipping_option;
475 } else { 475 } else {
476 if (response->shipping_address) { 476 if (response->shipping_address || !response->shipping_option.isNull()) {
477 m_showResolver->reject(DOMException::create(SyntaxError)); 477 m_showResolver->reject(DOMException::create(SyntaxError));
478 clearResolversAndCloseMojoConnection(); 478 clearResolversAndCloseMojoConnection();
479 return; 479 return;
480 } 480 }
481 } 481 }
482 482
483 if ((m_options.requestPayerEmail() && response->payer_email.isEmpty()) 483 if ((m_options.requestPayerEmail() && response->payer_email.isEmpty())
484 || (m_options.requestPayerPhone() && response->payer_phone.isEmpty()) 484 || (m_options.requestPayerPhone() && response->payer_phone.isEmpty())
485 || (!m_options.requestPayerEmail() && !response->payer_email.isNull()) 485 || (!m_options.requestPayerEmail() && !response->payer_email.isNull())
486 || (!m_options.requestPayerPhone() && !response->payer_phone.isNull())) { 486 || (!m_options.requestPayerPhone() && !response->payer_phone.isNull())) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 { 535 {
536 m_completeResolver.clear(); 536 m_completeResolver.clear();
537 m_showResolver.clear(); 537 m_showResolver.clear();
538 m_abortResolver.clear(); 538 m_abortResolver.clear();
539 if (m_clientBinding.is_bound()) 539 if (m_clientBinding.is_bound())
540 m_clientBinding.Close(); 540 m_clientBinding.Close();
541 m_paymentProvider.reset(); 541 m_paymentProvider.reset();
542 } 542 }
543 543
544 } // namespace blink 544 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698