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/ui/payments/payment_request_manager.h" | 5 #import "ios/chrome/browser/ui/payments/payment_request_manager.h" |
6 | 6 |
7 #include "base/ios/block_types.h" | 7 #include "base/ios/block_types.h" |
8 #include "base/ios/ios_util.h" | 8 #include "base/ios/ios_util.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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 [self webState]->AddScriptCommandCallback(callback, kCommandPrefix); | 303 [self webState]->AddScriptCommandCallback(callback, kCommandPrefix); |
304 | 304 |
305 _webStateEnabled = YES; | 305 _webStateEnabled = YES; |
306 } | 306 } |
307 } else { | 307 } else { |
308 [self disableCurrentWebState]; | 308 [self disableCurrentWebState]; |
309 } | 309 } |
310 } | 310 } |
311 | 311 |
312 - (void)disableCurrentWebState { | 312 - (void)disableCurrentWebState { |
313 if (_webStateEnabled) { | 313 if (_webState && _webStateEnabled) { |
314 _webState->RemoveScriptCommandCallback(kCommandPrefix); | 314 _webState->RemoveScriptCommandCallback(kCommandPrefix); |
315 _webStateEnabled = NO; | 315 _webStateEnabled = NO; |
316 } | 316 } |
317 } | 317 } |
318 | 318 |
319 - (void)disconnectWebState { | 319 - (void)disconnectWebState { |
320 if (_webState) { | 320 if (_webState) { |
321 _paymentRequestJsManager = nil; | 321 _paymentRequestJsManager = nil; |
322 _webStateObserver.reset(); | 322 _webStateObserver.reset(); |
323 [self disableCurrentWebState]; | 323 [self disableCurrentWebState]; |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 #pragma mark - CRWWebStateObserver methods | 782 #pragma mark - CRWWebStateObserver methods |
783 | 783 |
784 - (void)webState:(web::WebState*)webState | 784 - (void)webState:(web::WebState*)webState |
785 didCommitNavigationWithDetails: | 785 didCommitNavigationWithDetails: |
786 (const web::LoadCommittedDetails&)load_details { | 786 (const web::LoadCommittedDetails&)load_details { |
787 [self dismissUI]; | 787 [self dismissUI]; |
788 [self enableCurrentWebState]; | 788 [self enableCurrentWebState]; |
789 } | 789 } |
790 | 790 |
791 @end | 791 @end |
OLD | NEW |