OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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/shared/chrome/browser/tabs/web_state_opener.h" | 5 #import "ios/chrome/browser/web_state_list/web_state_opener.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #import "ios/web/public/navigation_manager.h" | 8 #import "ios/web/public/navigation_manager.h" |
9 #import "ios/web/public/web_state/web_state.h" | 9 #import "ios/web/public/web_state/web_state.h" |
10 | 10 |
11 #if !defined(__has_feature) || !__has_feature(objc_arc) | 11 #if !defined(__has_feature) || !__has_feature(objc_arc) |
12 #error "This file requires ARC support." | 12 #error "This file requires ARC support." |
13 #endif | 13 #endif |
14 | 14 |
15 namespace { | 15 namespace { |
16 int NavigationIndexFromWebState(web::WebState* web_state) { | 16 int NavigationIndexFromWebState(web::WebState* web_state) { |
17 if (!web_state) | 17 if (!web_state) |
18 return -1; | 18 return -1; |
19 | 19 |
20 DCHECK(web_state->GetNavigationManager()); | 20 DCHECK(web_state->GetNavigationManager()); |
21 return web_state->GetNavigationManager()->GetLastCommittedItemIndex(); | 21 return web_state->GetNavigationManager()->GetLastCommittedItemIndex(); |
22 } | 22 } |
23 } // namespace | 23 } // namespace |
24 | 24 |
25 WebStateOpener::WebStateOpener(web::WebState* opener) | 25 WebStateOpener::WebStateOpener(web::WebState* opener) |
26 : WebStateOpener(opener, NavigationIndexFromWebState(opener)) {} | 26 : WebStateOpener(opener, NavigationIndexFromWebState(opener)) {} |
27 | 27 |
28 WebStateOpener::WebStateOpener(web::WebState* opener, int navigation_index) | 28 WebStateOpener::WebStateOpener(web::WebState* opener, int navigation_index) |
29 : opener(opener), navigation_index(navigation_index) {} | 29 : opener(opener), navigation_index(navigation_index) {} |
OLD | NEW |