Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(344)

Unified Diff: ios/chrome/browser/ui/tab_switcher/tab_switcher_controller.mm

Issue 2775623002: [ios] WebStateList owns all WebState it manages. (Closed)
Patch Set: Fix ios_chrome_unittests. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 4907234cc4a1dae6497eec6f9cd5ed0b146e83f4..f3c7e076d3c0781d1e9f05c9dc2e2853f4f5edaa 100644
--- a/ios/chrome/browser/ui/tab_switcher/tab_switcher_controller.mm
+++ b/ios/chrome/browser/ui/tab_switcher/tab_switcher_controller.mm
@@ -828,56 +828,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
+ 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 +1195,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];
+
if (panelSessionType == TabSwitcherSessionType::OFF_THE_RECORD_SESSION) {
base::RecordAction(
base::UserMetricsAction("MobileTabSwitcherCloseIncognitoTab"));

Powered by Google App Engine
This is Rietveld 408576698