Commit 9c19d6b4 authored by Stepan Khapugin's avatar Stepan Khapugin Committed by Commit Bot

[multiball] Move TabSwitcher-related flags.

Moves isTabSwitcherActive, dismissingTabSwitcher to SceneController.

Bug: none
Change-Id: If90fd2ee706f42a57433beabc3d564058bada511
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2087401
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748267}
parent 7d71d608
......@@ -385,7 +385,6 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
@implementation MainController
// Defined by MainControllerGuts.
@synthesize dismissingTabSwitcher = _dismissingTabSwitcher;
@synthesize restoreHelper = _restoreHelper;
// Defined by public protocols.
......@@ -396,7 +395,6 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
@synthesize isColdStart = _isColdStart;
@synthesize startupParameters = _startupParameters;
@synthesize appLaunchTime = _appLaunchTime;
@synthesize tabSwitcherIsActive;
#pragma mark - Application lifecycle
......@@ -1277,6 +1275,10 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
@implementation MainController (TestingOnly)
- (BOOL)tabSwitcherActive {
return self.sceneController.isTabSwitcherActive;
}
- (void)dismissModalDialogsWithCompletion:(ProceduralBlock)completion
dismissOmnibox:(BOOL)dismissOmnibox {
[self.sceneController dismissModalDialogsWithCompletion:completion
......@@ -1295,10 +1297,6 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
return self.sceneController.tabSwitcher;
}
- (void)setTabSwitcherActive:(BOOL)active {
self.tabSwitcherIsActive = active;
}
- (void)setStartupParametersWithURL:(const GURL&)launchURL {
NSString* sourceApplication = @"Fake App";
self.startupParameters = [ChromeAppStartupParameters
......
......@@ -23,13 +23,6 @@ class ChromeBrowserState;
// ownership of Scene-related objects to SceneController.
@protocol MainControllerGuts <StartupInformation, BrowsingDataCommands>
// If YES, the tab switcher is currently active.
@property(nonatomic, assign, getter=isTabSwitcherActive)
BOOL tabSwitcherIsActive;
// YES while animating the dismissal of tab switcher.
@property(nonatomic, assign) BOOL dismissingTabSwitcher;
// Parameters received at startup time when the app is launched from another
// app.
@property(nonatomic, strong) AppStartupParameters* startupParameters;
......
......@@ -29,7 +29,7 @@ class GURL;
@property(nonatomic, readonly) DeviceSharingManager* deviceSharingManager;
// Tab switcher state.
@property(nonatomic, getter=isTabSwitcherActive) BOOL tabSwitcherActive;
- (BOOL)tabSwitcherActive;
@property(nonatomic, strong) id<TabSwitcher> tabSwitcher;
......
......@@ -173,6 +173,11 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
// the main view controller. This property should not be accessed before the
// browser has started up to the FOREGROUND stage.
@property(nonatomic, strong) TabGridCoordinator* mainCoordinator;
// If YES, the tab switcher is currently active.
@property(nonatomic, assign, getter=isTabSwitcherActive)
BOOL tabSwitcherIsActive;
// YES while animating the dismissal of tab switcher.
@property(nonatomic, assign) BOOL dismissingTabSwitcher;
@end
......@@ -359,8 +364,8 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
tabModel = mainTabModel;
[self setCurrentInterfaceForMode:ApplicationMode::NORMAL];
}
if (self.mainController.tabSwitcherIsActive) {
DCHECK(!self.mainController.dismissingTabSwitcher);
if (self.tabSwitcherIsActive) {
DCHECK(!self.dismissingTabSwitcher);
[self beginDismissingTabSwitcherWithCurrentModel:self.mainInterface.tabModel
focusOmnibox:NO];
[self finishDismissingTabSwitcher];
......@@ -558,7 +563,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
}
- (void)displayTabSwitcher {
DCHECK(!self.mainController.isTabSwitcherActive);
DCHECK(!self.tabSwitcherIsActive);
if (!self.isProcessingVoiceSearchCommand) {
[self.currentInterface.bvc userEnteredTabSwitcher];
[self showTabSwitcher];
......@@ -871,7 +876,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
}
- (NSString*)currentPageDisplayURL {
if (self.mainController.tabSwitcherIsActive)
if (self.tabSwitcherIsActive)
return nil;
web::WebState* webState =
self.currentInterface.browser->GetWebStateList()->GetActiveWebState();
......@@ -889,7 +894,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
CGFloat scale = 0.0;
// For screenshots of the tab switcher we need to use a scale of 1.0 to avoid
// spending too much time since the tab switcher can have lots of subviews.
if (self.mainController.tabSwitcherIsActive)
if (self.tabSwitcherIsActive)
scale = 1.0;
return CaptureView(lastView, scale);
}
......@@ -942,7 +947,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
DCHECK(tabModel == self.mainInterface.tabModel ||
tabModel == self.incognitoInterface.tabModel);
self.mainController.dismissingTabSwitcher = YES;
self.dismissingTabSwitcher = YES;
ApplicationMode mode = (tabModel == self.mainInterface.tabModel)
? ApplicationMode::NORMAL
: ApplicationMode::INCOGNITO;
......@@ -967,8 +972,8 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
if (self.currentInterface.browser &&
self.currentInterface.browser->GetWebStateList() &&
self.currentInterface.browser->GetWebStateList()->count() == 0U) {
self.mainController.tabSwitcherIsActive = NO;
self.mainController.dismissingTabSwitcher = NO;
self.tabSwitcherIsActive = NO;
self.dismissingTabSwitcher = NO;
self.modeToDisplayOnTabSwitcherDismissal = TabSwitcherDismissalMode::NONE;
self.NTPActionAfterTabSwitcherDismissal = NO_ACTION;
[self showTabSwitcher];
......@@ -998,8 +1003,8 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
action();
}
self.mainController.tabSwitcherIsActive = NO;
self.mainController.dismissingTabSwitcher = NO;
self.tabSwitcherIsActive = NO;
self.dismissingTabSwitcher = NO;
}
#pragma mark Tab opening utility methods.
......@@ -1102,7 +1107,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
}
- (BOOL)shouldOpenNTPTabOnActivationOfTabModel:(TabModel*)tabModel {
if (self.mainController.tabSwitcherIsActive) {
if (self.tabSwitcherIsActive) {
TabModel* mainTabModel = self.browserViewWrangler.mainInterface.tabModel;
TabModel* otrTabModel =
self.browserViewWrangler.incognitoInterface.tabModel;
......@@ -1155,7 +1160,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
self.interfaceProvider.currentInterface = newInterface;
if (!self.mainController.dismissingTabSwitcher)
if (!self.dismissingTabSwitcher)
[self displayCurrentBVCAndFocusOmnibox:NO];
// Tell the BVC that was made current that it can use the web.
......@@ -1183,7 +1188,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
// it.
ProceduralBlock completionWithBVC = ^{
DCHECK(self.currentInterface.bvc);
DCHECK(!self.mainController.tabSwitcherIsActive);
DCHECK(!self.tabSwitcherIsActive);
DCHECK(!self.signinInteractionCoordinator.isActive);
// This will dismiss the SSO view controller.
[self.interfaceProvider.currentInterface
......@@ -1193,7 +1198,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
ProceduralBlock completionWithoutBVC = ^{
// |self.currentInterface.bvc| may exist but tab switcher should be
// active.
DCHECK(self.mainController.tabSwitcherIsActive);
DCHECK(self.tabSwitcherIsActive);
// This will dismiss the SSO view controller.
[self.signinInteractionCoordinator cancelAndDismiss];
// History coordinator can be started on top of the tab grid. This is not
......@@ -1205,8 +1210,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
// As a top level rule, if the settings are showing, they need to be
// dismissed. Then, based on whether the BVC is present or not, a different
// completion callback is called.
if (!self.mainController.tabSwitcherIsActive &&
self.isSettingsViewPresented) {
if (!self.tabSwitcherIsActive && self.isSettingsViewPresented) {
// In this case, the settings are up and the BVC is showing. Close the
// settings then call the BVC completion.
[self closeSettingsAnimated:NO completion:completionWithBVC];
......@@ -1214,7 +1218,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
// In this case, the settings are up but the BVC is not showing. Close the
// settings then call the no-BVC completion.
[self closeSettingsAnimated:NO completion:completionWithoutBVC];
} else if (![self.mainController isTabSwitcherActive]) {
} else if (!self.tabSwitcherIsActive) {
// In this case, the settings are not shown but the BVC is showing. Call the
// BVC completion.
[self.signinInteractionCoordinator cancel];
......@@ -1284,11 +1288,11 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
tabOpenedCompletion = completion;
}
if (self.mainController.tabSwitcherIsActive) {
if (self.tabSwitcherIsActive) {
// If the tab switcher is already being dismissed, simply add the tab and
// note that when the tab switcher finishes dismissing, the current BVC
// should be switched to be the main BVC if necessary.
if (self.mainController.dismissingTabSwitcher) {
if (self.dismissingTabSwitcher) {
self.modeToDisplayOnTabSwitcherDismissal =
targetMode == ApplicationMode::NORMAL
? TabSwitcherDismissalMode::NORMAL
......@@ -1536,8 +1540,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
// Nothing to do here. The next user action (like clicking on an existing
// regular tab or creating a new incognito tab from the settings menu) will
// take care of the logic to mode switch.
if (self.mainController.tabSwitcherIsActive ||
![self.currentTabModel isOffTheRecord]) {
if (self.tabSwitcherIsActive || ![self.currentTabModel isOffTheRecord]) {
return;
}
......@@ -1556,8 +1559,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
// closure of tabs from the main tab model when the main tab model is not
// current.
// Nothing to do here.
if (self.mainController.tabSwitcherIsActive ||
[self.currentTabModel isOffTheRecord]) {
if (self.tabSwitcherIsActive || [self.currentTabModel isOffTheRecord]) {
return;
}
......@@ -1602,7 +1604,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
restoreInternalStateWithMainBrowser:self.mainInterface.browser
otrBrowser:self.incognitoInterface.browser
activeBrowser:self.currentInterface.browser];
self.mainController.tabSwitcherIsActive = YES;
self.tabSwitcherIsActive = YES;
[self.tabSwitcher setDelegate:self];
[self.mainCoordinator showTabSwitcher:self.tabSwitcher];
......
......@@ -40,6 +40,7 @@ class ChromeBrowserState;
- (void)showFirstRunUI;
- (void)setTabSwitcher:(id<TabSwitcher>)switcher;
- (id<TabSwitcher>)tabSwitcher;
- (BOOL)isTabSwitcherActive;
- (void)dismissModalDialogsWithCompletion:(ProceduralBlock)completion
dismissOmnibox:(BOOL)dismissOmnibox;
......
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