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

Side by Side Diff: ios/chrome/browser/web/resources/payment_request.js

Issue 2850723003: [Payment Request] Updates PaymentRequestUpdateEvent.updateWith function (Closed)
Patch Set: Addressed comment Created 3 years, 7 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 | « no previous file | 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 /** 5 /**
6 * @fileoverview JavaScript implementation of the Payment Request API. When 6 * @fileoverview JavaScript implementation of the Payment Request API. When
7 * loaded, installs the API onto the window object. Conforms 7 * loaded, installs the API onto the window object. Conforms
8 * to https://www.w3.org/TR/payment-request/. Note: This is a work in progress. 8 * to https://www.w3.org/TR/payment-request/. Note: This is a work in progress.
9 */ 9 */
10 10
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 223
224 /** 224 /**
225 * The event that enables the web page to update the details of the payment 225 * The event that enables the web page to update the details of the payment
226 * request in response to a user interaction. 226 * request in response to a user interaction.
227 * @type {Event} 227 * @type {Event}
228 */ 228 */
229 __gCrWeb['paymentRequestManager'].updateEvent = null; 229 __gCrWeb['paymentRequestManager'].updateEvent = null;
230 230
231 /** 231 /**
232 * Handles invocation of updateWith() on the updateEvent object. Updates the 232 * Handles invocation of updateWith() on the updateEvent object. Updates the
233 * payment details when the |updateWithPromise| is resolved. Throws an error 233 * payment details. Throws an error if |detailsOrPromise| is not a valid
234 * if |updateWithPromise| is not a valid instance of Promise or if it fulfills 234 * instance of window.PaymentDetails or it is a promise that does not fulfill
235 * with an invalid instance of window.PaymentDetails. 235 * with a valid one.
236 * @param {?Promise<?window.PaymentDetails|undefined>|undefined} 236 * @param {!Promise<!window.PaymentDetails>|!window.PaymentDetails}
237 * updateWithPromise 237 * detailsOrPromise
238 */ 238 */
239 __gCrWeb['paymentRequestManager'].updateWith = function(updateWithPromise) { 239 __gCrWeb['paymentRequestManager'].updateWith = function(detailsOrPromise) {
240 // Check to see |updateWithPromise| is an instance of Promise. 240 // if |detailsOrPromise| is not an instance of a Promise, wrap it in a
241 if (!updateWithPromise || !(updateWithPromise.then instanceof Function) || 241 // Promise that fulfills with |detailsOrPromise|.
242 !(updateWithPromise.catch instanceof Function)) { 242 if (!detailsOrPromise || !(detailsOrPromise.then instanceof Function) ||
243 throw new TypeError('An instance of Promise must be provided'); 243 !(detailsOrPromise.catch instanceof Function)) {
244 detailsOrPromise = Promise.resolve(detailsOrPromise);
244 } 245 }
245 246
246 updateWithPromise 247 detailsOrPromise
247 .then(function(paymentDetails) { 248 .then(function(paymentDetails) {
248 if (!paymentDetails) 249 if (!paymentDetails)
249 throw new TypeError( 250 throw new TypeError(
250 'An instance of PaymentDetails must be provided.'); 251 'An instance of PaymentDetails must be provided.');
251 252
252 var message = { 253 var message = {
253 'command': 'paymentRequest.updatePaymentDetails', 254 'command': 'paymentRequest.updatePaymentDetails',
254 'payment_details': paymentDetails, 255 'payment_details': paymentDetails,
255 }; 256 };
256 __gCrWeb.message.invokeOnHost(message); 257 __gCrWeb.message.invokeOnHost(message);
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 } 856 }
856 857
857 var message = { 858 var message = {
858 'command': 'paymentRequest.responseComplete', 859 'command': 'paymentRequest.responseComplete',
859 'result': opt_result, 860 'result': opt_result,
860 }; 861 };
861 __gCrWeb.message.invokeOnHost(message); 862 __gCrWeb.message.invokeOnHost(message);
862 863
863 return __gCrWeb['paymentRequestManager'].responsePromiseResolver.promise; 864 return __gCrWeb['paymentRequestManager'].responsePromiseResolver.promise;
864 }; 865 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698