| 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/web/web_state/ui/crw_wk_navigation_states.h" | 5 #import "ios/web/web_state/ui/crw_wk_navigation_states.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 | 8 |
| 9 #if !defined(__has_feature) || !__has_feature(objc_arc) | 9 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 10 #error "This file requires ARC support." | 10 #error "This file requires ARC support." |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 } | 62 } |
| 63 | 63 |
| 64 - (NSString*)description { | 64 - (NSString*)description { |
| 65 return [NSString stringWithFormat:@"records: %@, lastAddedNavigation: %@", | 65 return [NSString stringWithFormat:@"records: %@, lastAddedNavigation: %@", |
| 66 _records, self.lastAddedNavigation]; | 66 _records, self.lastAddedNavigation]; |
| 67 } | 67 } |
| 68 | 68 |
| 69 - (void)setState:(web::WKNavigationState)state | 69 - (void)setState:(web::WKNavigationState)state |
| 70 forNavigation:(WKNavigation*)navigation { | 70 forNavigation:(WKNavigation*)navigation { |
| 71 if (!navigation) { | 71 if (!navigation) { |
| 72 // WKWebView may call WKNavigationDelegate callbacks with nil | 72 // WKWebView may call WKNavigationDelegate callbacks with nil. |
| 73 // |WKNavigation|. TODO(crbug.com/677354): Remove this once WKWebView bug | |
| 74 // is fixed. | |
| 75 return; | 73 return; |
| 76 } | 74 } |
| 77 | 75 |
| 78 CRWWKNavigationsStateRecord* record = [_records objectForKey:navigation]; | 76 CRWWKNavigationsStateRecord* record = [_records objectForKey:navigation]; |
| 79 if (!record) { | 77 if (!record) { |
| 80 DCHECK(state == web::WKNavigationState::REQUESTED || | 78 DCHECK(state == web::WKNavigationState::REQUESTED || |
| 81 state == web::WKNavigationState::STARTED || | 79 state == web::WKNavigationState::STARTED || |
| 82 state == web::WKNavigationState::COMMITTED); | 80 state == web::WKNavigationState::COMMITTED); |
| 83 record = | 81 record = |
| 84 [[CRWWKNavigationsStateRecord alloc] initWithState:state | 82 [[CRWWKNavigationsStateRecord alloc] initWithState:state |
| (...skipping 23 matching lines...) Expand all Loading... |
| 108 - (web::WKNavigationState)lastAddedNavigationState { | 106 - (web::WKNavigationState)lastAddedNavigationState { |
| 109 CRWWKNavigationsStateRecord* lastAddedRecord = nil; | 107 CRWWKNavigationsStateRecord* lastAddedRecord = nil; |
| 110 WKNavigation* lastAddedNavigation = [self lastAddedNavigation]; | 108 WKNavigation* lastAddedNavigation = [self lastAddedNavigation]; |
| 111 if (lastAddedNavigation) | 109 if (lastAddedNavigation) |
| 112 lastAddedRecord = [_records objectForKey:lastAddedNavigation]; | 110 lastAddedRecord = [_records objectForKey:lastAddedNavigation]; |
| 113 | 111 |
| 114 return lastAddedRecord.state; | 112 return lastAddedRecord.state; |
| 115 } | 113 } |
| 116 | 114 |
| 117 @end | 115 @end |
| OLD | NEW |