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

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 gn check Created 3 years, 8 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 99622659ad7d02ce70daae5aef1cc6e09e8c1c4b..502ca999b4879314f9fad173413e4af586913740 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"
@@ -843,56 +842,25 @@ 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;
+ NSUInteger tabIndex = position;
+ if (position > tabModel.count)
+ tabIndex = tabModel.count;
- DCHECK(tabModel.browserState);
+ web::NavigationManager::WebLoadParams loadParams(URL);
+ loadParams.transition_type = transition;
- base::scoped_nsobject<Tab> tab([[Tab alloc]
- initWithBrowserState:tabModel.browserState
- opener:nil
- openedByDOM:NO
- model:tabModel]);
- [tab webController].webUsageEnabled = tabModel.webUsageEnabled;
+ Tab* tab = [tabModel insertTabWithLoadParams:loadParams
+ opener:nil
+ openedByDOM:NO
+ atIndex:tabIndex
+ inBackground:NO];
- 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
+ [self tabSwitcherDismissWithModel:tabModel
animated:YES
withCompletion:^{
[self.delegate tabSwitcherDismissTransitionDidEnd:self];
}];
- };
- dismissWithNewTab();
return tab;
}
@@ -1242,7 +1210,13 @@ enum class SnapshotViewOption {
DCHECK(tab);
const TabSwitcherSessionType panelSessionType =
tabSwitcherPanelController.sessionType;
- [tab close];
+ TabModel* tabModel =
+ panelSessionType == TabSwitcherSessionType::OFF_THE_RECORD_SESSION
+ ? [_tabSwitcherModel otrTabModel]
+ : [_tabSwitcherModel mainTabModel];
+ DCHECK_NE(NSNotFound, static_cast<NSInteger>([tabModel indexOfTab:tab]));
+ [tabModel closeTab:tab];
+
if (panelSessionType == TabSwitcherSessionType::OFF_THE_RECORD_SESSION) {
base::RecordAction(
base::UserMetricsAction("MobileTabSwitcherCloseIncognitoTab"));
« no previous file with comments | « ios/chrome/browser/ui/tab_switcher/DEPS ('k') | ios/chrome/browser/ui/tabs/tab_strip_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698