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