| 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 #import "ios/chrome/browser/payments/payment_request_manager.h" | 5 #import "ios/chrome/browser/payments/payment_request_manager.h" |
| 6 | 6 |
| 7 #include "base/ios/ios_util.h" | 7 #include "base/ios/ios_util.h" |
| 8 #import "base/ios/weak_nsobject.h" | 8 #import "base/ios/weak_nsobject.h" |
| 9 #import "base/mac/bind_objc_block.h" | 9 #import "base/mac/bind_objc_block.h" |
| 10 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 | 196 |
| 197 - (void)disconnectWebState { | 197 - (void)disconnectWebState { |
| 198 if (_webState) { | 198 if (_webState) { |
| 199 _paymentRequestJsManager.reset(); | 199 _paymentRequestJsManager.reset(); |
| 200 _webStateObserver.reset(); | 200 _webStateObserver.reset(); |
| 201 [self disableCurrentWebState]; | 201 [self disableCurrentWebState]; |
| 202 } | 202 } |
| 203 } | 203 } |
| 204 | 204 |
| 205 - (void)initializeWebViewForPaymentRequest { | 205 - (void)initializeWebViewForPaymentRequest { |
| 206 DCHECK(_webStateEnabled); | 206 if (_enabled) { |
| 207 DCHECK(_webStateEnabled); |
| 207 | 208 |
| 208 [_paymentRequestJsManager inject]; | 209 [_paymentRequestJsManager inject]; |
| 209 _isScriptInjected = YES; | 210 _isScriptInjected = YES; |
| 211 } |
| 210 } | 212 } |
| 211 | 213 |
| 212 - (BOOL)handleScriptCommand:(const base::DictionaryValue&)JSONCommand { | 214 - (BOOL)handleScriptCommand:(const base::DictionaryValue&)JSONCommand { |
| 213 if (![self webStateContentIsSecureHTML]) { | 215 if (![self webStateContentIsSecureHTML]) { |
| 214 return NO; | 216 return NO; |
| 215 } | 217 } |
| 216 | 218 |
| 217 std::string command; | 219 std::string command; |
| 218 if (!JSONCommand.GetString("command", &command)) { | 220 if (!JSONCommand.GetString("command", &command)) { |
| 219 DLOG(ERROR) << "RECEIVED BAD JSON - NO 'command' field"; | 221 DLOG(ERROR) << "RECEIVED BAD JSON - NO 'command' field"; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 (web::PaymentResponse)paymentResponse { | 314 (web::PaymentResponse)paymentResponse { |
| 313 [_paymentRequestJsManager resolveRequestPromise:paymentResponse | 315 [_paymentRequestJsManager resolveRequestPromise:paymentResponse |
| 314 completionHandler:nil]; | 316 completionHandler:nil]; |
| 315 } | 317 } |
| 316 | 318 |
| 317 #pragma mark - CRWWebStateObserver methods | 319 #pragma mark - CRWWebStateObserver methods |
| 318 | 320 |
| 319 - (void)webState:(web::WebState*)webState | 321 - (void)webState:(web::WebState*)webState |
| 320 didCommitNavigationWithDetails: | 322 didCommitNavigationWithDetails: |
| 321 (const web::LoadCommittedDetails&)load_details { | 323 (const web::LoadCommittedDetails&)load_details { |
| 324 [self dismissUI]; |
| 322 _isScriptInjected = NO; | 325 _isScriptInjected = NO; |
| 323 [self dismissUI]; | 326 [self enableCurrentWebState]; |
| 324 [self initializeWebViewForPaymentRequest]; | 327 [self initializeWebViewForPaymentRequest]; |
| 325 [self enableCurrentWebState]; | |
| 326 } | 328 } |
| 327 | 329 |
| 328 @end | 330 @end |
| OLD | NEW |