Index: ios/chrome/browser/tabs/tab_model.mm |
diff --git a/ios/chrome/browser/tabs/tab_model.mm b/ios/chrome/browser/tabs/tab_model.mm |
index 0a4a9fdf5b0dbfd915085c012970856134f9335a..f6efb53da08b95a71a7871c8f48766f4188f681b 100644 |
--- a/ios/chrome/browser/tabs/tab_model.mm |
+++ b/ios/chrome/browser/tabs/tab_model.mm |
@@ -514,14 +514,21 @@ Tab* GetOpenerForTab(id<NSFastEnumeration> tabs, Tab* tab) { |
inBackground:inBackground]; |
} |
-- (Tab*)insertTabWithWebState:(std::unique_ptr<web::WebState>)webState |
- atIndex:(NSUInteger)index { |
+- (Tab*)insertTabWithNavigationItems: |
+ (web::ScopedNavigationItemList)navigationItems |
+ selectedNavigationIndex:(int)selectedNavigationIndex |
+ atIndex:(NSUInteger)index |
+ inBackground:(BOOL)inBackground { |
DCHECK(_browserState); |
- DCHECK_EQ(webState->GetBrowserState(), _browserState); |
+ auto webState = base::MakeUnique<web::WebStateImpl>(_browserState); |
+ webState->GetNavigationManagerImpl().ReplaceSessionHistory( |
+ std::move(navigationItems), selectedNavigationIndex); |
base::scoped_nsobject<Tab> tab( |
[[Tab alloc] initWithWebState:std::move(webState) model:self]); |
[tab webController].webUsageEnabled = webUsageEnabled_; |
[self insertTab:tab atIndex:index]; |
+ if (!inBackground) |
+ [self setCurrentTab:tab]; |
return tab; |
} |
@@ -872,7 +879,7 @@ Tab* GetOpenerForTab(id<NSFastEnumeration> tabs, Tab* tab) { |
[tab webController].usePlaceholderOverlay = YES; |
// Restore the CertificatePolicyCache (note that webState is invalid after |
- // passing it via move semantic to -insertTabWithWebState:atIndex:). |
+ // passing it via move semantic to -initWithWebState:model:). |
UpdateCertificatePolicyCacheFromWebState(policyCache, [tab webState]); |
[self insertTab:tab atIndex:self.count opener:nil]; |
[restoredTabs addObject:tab.get()]; |