Commit 0a7fda5f authored by Nazerke's avatar Nazerke Committed by Commit Bot

[iOS][tabmodel] Deprecation of TabModel in MainController.

This CL removes MainController's dependence on TabModel by getting
WebStateList from Browser instead.

Bug: 1045575, 1049849
Change-Id: I1d931a618f5c94d44a20032db3ed3a2dcc836458
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2166200Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Commit-Queue: Nazerke Kalidolda <nazerke@google.com>
Cr-Commit-Position: refs/heads/master@{#763307}
parent 69f75048
...@@ -199,7 +199,6 @@ source_set("app_internal") { ...@@ -199,7 +199,6 @@ source_set("app_internal") {
"//ios/chrome/browser/snapshots", "//ios/chrome/browser/snapshots",
"//ios/chrome/browser/suggestions", "//ios/chrome/browser/suggestions",
"//ios/chrome/browser/sync", "//ios/chrome/browser/sync",
"//ios/chrome/browser/tabs",
"//ios/chrome/browser/ui:feature_flags", "//ios/chrome/browser/ui:feature_flags",
"//ios/chrome/browser/ui/appearance", "//ios/chrome/browser/ui/appearance",
"//ios/chrome/browser/ui/authentication", "//ios/chrome/browser/ui/authentication",
......
...@@ -74,7 +74,6 @@ ...@@ -74,7 +74,6 @@
#import "ios/chrome/browser/snapshots/snapshot_cache.h" #import "ios/chrome/browser/snapshots/snapshot_cache.h"
#import "ios/chrome/browser/snapshots/snapshot_cache_factory.h" #import "ios/chrome/browser/snapshots/snapshot_cache_factory.h"
#include "ios/chrome/browser/system_flags.h" #include "ios/chrome/browser/system_flags.h"
#import "ios/chrome/browser/tabs/tab_model.h"
#import "ios/chrome/browser/ui/appearance/appearance_customization.h" #import "ios/chrome/browser/ui/appearance/appearance_customization.h"
#import "ios/chrome/browser/ui/commands/browser_commands.h" #import "ios/chrome/browser/ui/commands/browser_commands.h"
#import "ios/chrome/browser/ui/first_run/first_run_util.h" #import "ios/chrome/browser/ui/first_run/first_run_util.h"
...@@ -264,8 +263,8 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData( ...@@ -264,8 +263,8 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
// Returns whether the restore infobar should be displayed. // Returns whether the restore infobar should be displayed.
- (bool)mustShowRestoreInfobar; - (bool)mustShowRestoreInfobar;
// Returns the set of the sessions ids of the tabs in the given |tabModel|. // Returns the set of the sessions ids of the tabs in the given |webStateList|.
- (NSMutableSet*)liveSessionsForTabModel:(TabModel*)tabModel; - (NSMutableSet*)liveSessionsForWebStateList:(WebStateList*)webStateList;
// Purge the unused snapshots. // Purge the unused snapshots.
- (void)purgeSnapshots; - (void)purgeSnapshots;
// Sets a LocalState pref marking the TOS EULA as accepted. // Sets a LocalState pref marking the TOS EULA as accepted.
...@@ -468,9 +467,9 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData( ...@@ -468,9 +467,9 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
ChromeBrowserState* chromeBrowserState = ChromeBrowserState* chromeBrowserState =
_browserStateManager->GetLastUsedBrowserState(); _browserStateManager->GetLastUsedBrowserState();
// The CrashRestoreHelper must clean up the old browser state information // The CrashRestoreHelper must clean up the old browser state information.
// before the tabModels can be created. |self.restoreHelper| must be kept // |self.restoreHelper| must be kept alive until the BVC receives the
// alive until the BVC receives the browser state and tab model. // browser state.
BOOL needRestoration = NO; BOOL needRestoration = NO;
if (isPostCrashLaunch) { if (isPostCrashLaunch) {
needRestoration = [CrashRestoreHelper needRestoration = [CrashRestoreHelper
...@@ -862,7 +861,7 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData( ...@@ -862,7 +861,7 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
if (cookie_util::ShouldClearSessionCookies()) { if (cookie_util::ShouldClearSessionCookies()) {
cookie_util::ClearSessionCookies( cookie_util::ClearSessionCookies(
self.mainBrowserState->GetOriginalChromeBrowserState()); self.mainBrowserState->GetOriginalChromeBrowserState());
if (![self.otrTabModel isEmpty]) { if (!(self.otrBrowser->GetWebStateList()->empty())) {
cookie_util::ClearSessionCookies( cookie_util::ClearSessionCookies(
self.mainBrowserState->GetOffTheRecordChromeBrowserState()); self.mainBrowserState->GetOffTheRecordChromeBrowserState());
} }
...@@ -1048,7 +1047,7 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData( ...@@ -1048,7 +1047,7 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
// If there are no incognito tabs, then ensure the app starts in normal mode, // If there are no incognito tabs, then ensure the app starts in normal mode,
// since the UI isn't supposed to ever put the user in incognito mode without // since the UI isn't supposed to ever put the user in incognito mode without
// any incognito tabs. // any incognito tabs.
return ![self.otrTabModel isEmpty]; return !(self.otrBrowser->GetWebStateList()->empty());
} }
- (void)prepareForFirstRunUI { - (void)prepareForFirstRunUI {
...@@ -1094,16 +1093,6 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData( ...@@ -1094,16 +1093,6 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
return self.interfaceProvider.mainInterface.browser; return self.interfaceProvider.mainInterface.browser;
} }
- (TabModel*)mainTabModel {
DCHECK(self.interfaceProvider);
return self.interfaceProvider.mainInterface.tabModel;
}
- (TabModel*)otrTabModel {
DCHECK(self.interfaceProvider);
return self.interfaceProvider.incognitoInterface.tabModel;
}
- (Browser*)otrBrowser { - (Browser*)otrBrowser {
DCHECK(self.interfaceProvider); DCHECK(self.interfaceProvider);
return self.interfaceProvider.incognitoInterface.browser; return self.interfaceProvider.incognitoInterface.browser;
...@@ -1126,8 +1115,7 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData( ...@@ -1126,8 +1115,7 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
return !GetApplicationContext()->WasLastShutdownClean(); return !GetApplicationContext()->WasLastShutdownClean();
} }
- (NSMutableSet*)liveSessionsForTabModel:(TabModel*)tabModel { - (NSMutableSet*)liveSessionsForWebStateList:(WebStateList*)webStateList {
WebStateList* webStateList = tabModel.webStateList;
NSMutableSet* result = [NSMutableSet setWithCapacity:webStateList->count()]; NSMutableSet* result = [NSMutableSet setWithCapacity:webStateList->count()];
for (int index = 0; index < webStateList->count(); ++index) { for (int index = 0; index < webStateList->count(); ++index) {
web::WebState* webState = webStateList->GetWebStateAt(index); web::WebState* webState = webStateList->GetWebStateAt(index);
...@@ -1136,10 +1124,12 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData( ...@@ -1136,10 +1124,12 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
return result; return result;
} }
- (void)purgeSnapshots { - (void)purgeSnapshots {
NSMutableSet* liveSessions = [self liveSessionsForTabModel:self.mainTabModel]; NSMutableSet* liveSessions =
[liveSessions unionSet:[self liveSessionsForTabModel:self.otrTabModel]]; [self liveSessionsForWebStateList:self.mainBrowser->GetWebStateList()];
[liveSessions
unionSet:[self liveSessionsForWebStateList:self.otrBrowser
->GetWebStateList()]];
// Keep snapshots that are less than one minute old, to prevent a concurrency // Keep snapshots that are less than one minute old, to prevent a concurrency
// issue if they are created while the purge is running. // issue if they are created while the purge is running.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment