| OLD | NEW |
| (Empty) |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #import "ios/shared/chrome/browser/tabs/web_state_opener.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #import "ios/web/public/navigation_manager.h" | |
| 9 #import "ios/web/public/web_state/web_state.h" | |
| 10 | |
| 11 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
| 12 #error "This file requires ARC support." | |
| 13 #endif | |
| 14 | |
| 15 namespace { | |
| 16 int NavigationIndexFromWebState(web::WebState* web_state) { | |
| 17 if (!web_state) | |
| 18 return -1; | |
| 19 | |
| 20 DCHECK(web_state->GetNavigationManager()); | |
| 21 return web_state->GetNavigationManager()->GetLastCommittedItemIndex(); | |
| 22 } | |
| 23 } // namespace | |
| 24 | |
| 25 WebStateOpener::WebStateOpener(web::WebState* opener) | |
| 26 : WebStateOpener(opener, NavigationIndexFromWebState(opener)) {} | |
| 27 | |
| 28 WebStateOpener::WebStateOpener(web::WebState* opener, int navigation_index) | |
| 29 : opener(opener), navigation_index(navigation_index) {} | |
| OLD | NEW |