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

Side by Side Diff: ios/chrome/browser/payments/js_payment_request_manager.mm

Issue 2733953003: [Payments] Return a basic card response (Closed)
Patch Set: addressed comments from anthony Created 3 years, 9 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 #import "ios/chrome/browser/payments/js_payment_request_manager.h" 5 #import "ios/chrome/browser/payments/js_payment_request_manager.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/json/string_escape.h" 8 #include "base/json/string_escape.h"
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "components/payments/core/payment_address.h"
11 #include "ios/web/public/payments/payment_request.h" 12 #include "ios/web/public/payments/payment_request.h"
12 13
13 #if !defined(__has_feature) || !__has_feature(objc_arc) 14 #if !defined(__has_feature) || !__has_feature(objc_arc)
14 #error "This file requires ARC support." 15 #error "This file requires ARC support."
15 #endif 16 #endif
16 17
17 namespace { 18 namespace {
18 19
19 // Sanitizes |JSON| and wraps it in quotes so it can be injected safely in 20 // Sanitizes |JSON| and wraps it in quotes so it can be injected safely in
20 // JavaScript. 21 // JavaScript.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 [self executeScript:script completionHandler:completionHandler]; 73 [self executeScript:script completionHandler:completionHandler];
73 } 74 }
74 75
75 - (void)resolveResponsePromiseWithCompletionHandler: 76 - (void)resolveResponsePromiseWithCompletionHandler:
76 (ProceduralBlockWithBool)completionHandler { 77 (ProceduralBlockWithBool)completionHandler {
77 NSString* script = 78 NSString* script =
78 @"__gCrWeb['paymentRequestManager'].resolveResponsePromise()"; 79 @"__gCrWeb['paymentRequestManager'].resolveResponsePromise()";
79 [self executeScript:script completionHandler:completionHandler]; 80 [self executeScript:script completionHandler:completionHandler];
80 } 81 }
81 82
82 - (void)updateShippingAddress:(const web::PaymentAddress&)shippingAddress 83 - (void)updateShippingAddress:(const payments::PaymentAddress&)shippingAddress
83 completionHandler:(ProceduralBlockWithBool)completionHanlder { 84 completionHandler:(ProceduralBlockWithBool)completionHanlder {
84 std::unique_ptr<base::DictionaryValue> shippingAddressData = 85 std::unique_ptr<base::DictionaryValue> shippingAddressData =
85 shippingAddress.ToDictionaryValue(); 86 shippingAddress.ToDictionaryValue();
86 std::string shippingAddressDataJSON; 87 std::string shippingAddressDataJSON;
87 base::JSONWriter::Write(*shippingAddressData, &shippingAddressDataJSON); 88 base::JSONWriter::Write(*shippingAddressData, &shippingAddressDataJSON);
88 NSString* script = [NSString 89 NSString* script = [NSString
89 stringWithFormat:@"__gCrWeb['paymentRequestManager']." 90 stringWithFormat:@"__gCrWeb['paymentRequestManager']."
90 @"updateShippingAddressAndDispatchEvent(%@)", 91 @"updateShippingAddressAndDispatchEvent(%@)",
91 base::SysUTF8ToNSString(shippingAddressDataJSON)]; 92 base::SysUTF8ToNSString(shippingAddressDataJSON)];
92 [self executeScript:script completionHandler:completionHanlder]; 93 [self executeScript:script completionHandler:completionHanlder];
(...skipping 21 matching lines...) Expand all
114 115
115 - (NSString*)scriptPath { 116 - (NSString*)scriptPath {
116 return @"payment_request_manager"; 117 return @"payment_request_manager";
117 } 118 }
118 119
119 - (NSString*)presenceBeacon { 120 - (NSString*)presenceBeacon {
120 return @"__gCrWeb.paymentRequestManager"; 121 return @"__gCrWeb.paymentRequestManager";
121 } 122 }
122 123
123 @end 124 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/payments/js_payment_request_manager.h ('k') | ios/chrome/browser/payments/payment_request_coordinator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698