Chromium Code Reviews| Index: ios/chrome/browser/ui/tab_switcher/tab_switcher_controller.mm | 
| diff --git a/ios/chrome/browser/ui/tab_switcher/tab_switcher_controller.mm b/ios/chrome/browser/ui/tab_switcher/tab_switcher_controller.mm | 
| index 12db3675405241372ef676ba85877956b4998773..8fc2f9f8731b23a7f27bb8f08cd8fe794a62597f 100644 | 
| --- a/ios/chrome/browser/ui/tab_switcher/tab_switcher_controller.mm | 
| +++ b/ios/chrome/browser/ui/tab_switcher/tab_switcher_controller.mm | 
| @@ -50,7 +50,6 @@ | 
| #import "ios/third_party/material_components_ios/src/components/Palettes/src/MaterialPalettes.h" | 
| #import "ios/web/public/navigation_manager.h" | 
| #include "ios/web/public/referrer.h" | 
| -#import "ios/web/web_state/ui/crw_web_controller.h" | 
| #include "ui/base/l10n/l10n_util.h" | 
| #include "ui/base/l10n/l10n_util_mac.h" | 
| @@ -828,56 +827,24 @@ enum class SnapshotViewOption { | 
| atIndex:(NSUInteger)position | 
| transition:(ui::PageTransition)transition | 
| tabModel:(TabModel*)tabModel { | 
| - web::NavigationManager::WebLoadParams params(URL); | 
| - params.referrer = web::Referrer(); | 
| - params.transition_type = transition; | 
| - | 
| - DCHECK(tabModel.browserState); | 
| - | 
| - base::scoped_nsobject<Tab> tab([[Tab alloc] | 
| - initWithBrowserState:tabModel.browserState | 
| - opener:nil | 
| - openedByDOM:NO | 
| - model:tabModel]); | 
| - [tab webController].webUsageEnabled = tabModel.webUsageEnabled; | 
| - | 
| - ProceduralBlock dismissWithNewTab = ^{ | 
| - NSUInteger tabIndex = position; | 
| - if (position > tabModel.count) | 
| - tabIndex = tabModel.count; | 
| - [tabModel insertTab:tab atIndex:tabIndex]; | 
| - | 
| - if (tabModel.tabUsageRecorder) | 
| - tabModel.tabUsageRecorder->TabCreatedForSelection(tab); | 
| - | 
| - [[tab webController] loadWithParams:params]; | 
| - | 
| - if (tabModel.webUsageEnabled) { | 
| - [tab setWebUsageEnabled:tabModel.webUsageEnabled]; | 
| - [[tab webController] triggerPendingLoad]; | 
| - } | 
| - | 
| - NSDictionary* userInfo = @{ | 
| - kTabModelTabKey : tab, | 
| - kTabModelOpenInBackgroundKey : @(NO), | 
| - }; | 
| - | 
| - [[NSNotificationCenter defaultCenter] | 
| - postNotificationName:kTabModelNewTabWillOpenNotification | 
| - object:self | 
| - userInfo:userInfo]; | 
| - | 
| - [tabModel setCurrentTab:tab]; | 
| - | 
| - [self | 
| - tabSwitcherDismissWithModel:tabModel | 
| + NSUInteger tabIndex = position; | 
| + if (position > tabModel.count) | 
| + tabIndex = tabModel.count; | 
| + | 
| + Tab* tab = [tabModel insertTabWithURL:URL | 
| 
 
rohitrao (ping after 24h)
2017/04/03 17:49:35
Could you use insertTabWithLoadParams here instead
 
sdefresne
2017/04/04 13:47:57
Done.
 
 | 
| + referrer:web::Referrer() | 
| + transition:transition | 
| + opener:nil | 
| + openedByDOM:NO | 
| + atIndex:tabIndex | 
| + inBackground:NO]; | 
| + | 
| + [self tabSwitcherDismissWithModel:tabModel | 
| animated:YES | 
| withCompletion:^{ | 
| [self.delegate tabSwitcherDismissTransitionDidEnd:self]; | 
| }]; | 
| - }; | 
| - dismissWithNewTab(); | 
| return tab; | 
| } | 
| @@ -1227,7 +1194,12 @@ enum class SnapshotViewOption { | 
| DCHECK(tab); | 
| const TabSwitcherSessionType panelSessionType = | 
| tabSwitcherPanelController.sessionType; | 
| - [tab close]; | 
| + TabModel* tabModel = | 
| + panelSessionType == TabSwitcherSessionType::OFF_THE_RECORD_SESSION | 
| + ? [_tabSwitcherModel otrTabModel] | 
| + : [_tabSwitcherModel mainTabModel]; | 
| + [tabModel closeTab:tab]; | 
| 
 
rohitrao (ping after 24h)
2017/04/03 17:49:35
DCHECK_NE(NSNotFound, [tabModel indexOfTab:tab]),
 
sdefresne
2017/04/04 13:47:56
Done.
 
 | 
| + | 
| if (panelSessionType == TabSwitcherSessionType::OFF_THE_RECORD_SESSION) { | 
| base::RecordAction( | 
| base::UserMetricsAction("MobileTabSwitcherCloseIncognitoTab")); |