Commit 84d1f087 authored by Stepan Khapugin's avatar Stepan Khapugin Committed by Commit Bot

[multiball] Cleanup Scene/Main Controller Guts.

Cleans up the Guts protocols from things that are no longer used.
Uses interfaceProvider everywhere instead of alternative accessors.

Bug: 1045659, 1045660
Change-Id: Ib3355505686c6b034e98373d380330dff256d8af
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2087675
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748190}
parent db0eaaec
...@@ -1164,7 +1164,10 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData( ...@@ -1164,7 +1164,10 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
} }
- (ChromeBrowserState*)currentBrowserState { - (ChromeBrowserState*)currentBrowserState {
return self.currentBVC.browserState; if (!self.interfaceProvider.currentInterface.browser) {
return nullptr;
}
return self.interfaceProvider.currentInterface.browser->GetBrowserState();
} }
- (bool)mustShowRestoreInfobar { - (bool)mustShowRestoreInfobar {
...@@ -1206,12 +1209,6 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData( ...@@ -1206,12 +1209,6 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
#pragma mark - SceneController plumbing
- (BOOL)currentPageIsIncognito {
return [self currentBrowserState] -> IsOffTheRecord();
}
#pragma mark - BrowsingDataCommands #pragma mark - BrowsingDataCommands
- (void)removeBrowsingDataForBrowserState:(ChromeBrowserState*)browserState - (void)removeBrowsingDataForBrowserState:(ChromeBrowserState*)browserState
......
...@@ -16,10 +16,7 @@ ...@@ -16,10 +16,7 @@
#import "ios/chrome/browser/ui/commands/browsing_data_commands.h" #import "ios/chrome/browser/ui/commands/browsing_data_commands.h"
@class AppState; @class AppState;
@class BrowserViewController;
class ChromeBrowserState; class ChromeBrowserState;
@class TabGridCoordinator;
@protocol BrowserInterfaceProvider;
// TODO(crbug.com/1012697): Remove this protocol when SceneController is // TODO(crbug.com/1012697): Remove this protocol when SceneController is
// operational. Move the private internals back into MainController, and pass // operational. Move the private internals back into MainController, and pass
...@@ -40,13 +37,7 @@ class ChromeBrowserState; ...@@ -40,13 +37,7 @@ class ChromeBrowserState;
// Keeps track of the restore state during startup. // Keeps track of the restore state during startup.
@property(nonatomic, strong) CrashRestoreHelper* restoreHelper; @property(nonatomic, strong) CrashRestoreHelper* restoreHelper;
- (TabModel*)currentTabModel;
- (ChromeBrowserState*)mainBrowserState; - (ChromeBrowserState*)mainBrowserState;
- (ChromeBrowserState*)currentBrowserState;
- (BrowserViewController*)currentBVC;
- (BrowserViewController*)mainBVC;
- (BrowserViewController*)otrBVC;
- (id<BrowserInterfaceProvider>)interfaceProvider;
- (UIWindow*)window; - (UIWindow*)window;
- (NSDictionary*)launchOptions; - (NSDictionary*)launchOptions;
- (AppState*)appState; - (AppState*)appState;
......
...@@ -118,6 +118,10 @@ const NSTimeInterval kDisplayPromoDelay = 0.1; ...@@ -118,6 +118,10 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
SettingsNavigationControllerDelegate, SettingsNavigationControllerDelegate,
WebStateListObserving> WebStateListObserving>
// The scene level component for url loading. Is passed down to
// browser state level UrlLoadingService instances.
@property(nonatomic, assign) AppUrlLoadingService* appURLLoadingService;
// A flag that keeps track of the UI initialization for the controlled scene. // A flag that keeps track of the UI initialization for the controlled scene.
@property(nonatomic, assign) BOOL hasInitializedUI; @property(nonatomic, assign) BOOL hasInitializedUI;
...@@ -216,19 +220,19 @@ const NSTimeInterval kDisplayPromoDelay = 0.1; ...@@ -216,19 +220,19 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
} }
- (id<BrowserInterface>)mainInterface { - (id<BrowserInterface>)mainInterface {
return self.mainController.interfaceProvider.mainInterface; return self.browserViewWrangler.mainInterface;
} }
- (id<BrowserInterface>)currentInterface { - (id<BrowserInterface>)currentInterface {
return self.mainController.interfaceProvider.currentInterface; return self.browserViewWrangler.currentInterface;
} }
- (id<BrowserInterface>)incognitoInterface { - (id<BrowserInterface>)incognitoInterface {
return self.mainController.interfaceProvider.incognitoInterface; return self.browserViewWrangler.incognitoInterface;
} }
- (id<BrowserInterfaceProvider>)interfaceProvider { - (id<BrowserInterfaceProvider>)interfaceProvider {
return self.mainController.interfaceProvider; return self.browserViewWrangler;
} }
- (BOOL)isSettingsViewPresented { - (BOOL)isSettingsViewPresented {
...@@ -507,10 +511,10 @@ const NSTimeInterval kDisplayPromoDelay = 0.1; ...@@ -507,10 +511,10 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
- (void)showHistory { - (void)showHistory {
self.historyCoordinator = [[HistoryCoordinator alloc] self.historyCoordinator = [[HistoryCoordinator alloc]
initWithBaseViewController:self.mainController.currentBVC initWithBaseViewController:self.currentInterface.bvc
browser:self.mainInterface.browser]; browser:self.mainInterface.browser];
self.historyCoordinator.loadStrategy = self.historyCoordinator.loadStrategy =
[self currentPageIsIncognito] ? UrlLoadStrategy::ALWAYS_IN_INCOGNITO self.currentInterface.incognito ? UrlLoadStrategy::ALWAYS_IN_INCOGNITO
: UrlLoadStrategy::NORMAL; : UrlLoadStrategy::NORMAL;
[self.historyCoordinator start]; [self.historyCoordinator start];
} }
...@@ -526,7 +530,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1; ...@@ -526,7 +530,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
- (void)prepareTabSwitcher { - (void)prepareTabSwitcher {
web::WebState* currentWebState = web::WebState* currentWebState =
self.mainController.currentBVC.tabModel.webStateList->GetActiveWebState(); self.currentInterface.browser->GetWebStateList()->GetActiveWebState();
if (currentWebState) { if (currentWebState) {
BOOL loading = currentWebState->IsLoading(); BOOL loading = currentWebState->IsLoading();
SnapshotTabHelper::FromWebState(currentWebState) SnapshotTabHelper::FromWebState(currentWebState)
...@@ -556,7 +560,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1; ...@@ -556,7 +560,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
- (void)displayTabSwitcher { - (void)displayTabSwitcher {
DCHECK(!self.mainController.isTabSwitcherActive); DCHECK(!self.mainController.isTabSwitcherActive);
if (!self.isProcessingVoiceSearchCommand) { if (!self.isProcessingVoiceSearchCommand) {
[self.mainController.currentBVC userEnteredTabSwitcher]; [self.currentInterface.bvc userEnteredTabSwitcher];
[self showTabSwitcher]; [self showTabSwitcher];
self.isProcessingTabSwitcherCommand = YES; self.isProcessingTabSwitcherCommand = YES;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, dispatch_after(dispatch_time(DISPATCH_TIME_NOW,
...@@ -712,12 +716,12 @@ const NSTimeInterval kDisplayPromoDelay = 0.1; ...@@ -712,12 +716,12 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
(UIViewController*)baseViewController { (UIViewController*)baseViewController {
DCHECK(!self.signinInteractionCoordinator.isSettingsViewPresented); DCHECK(!self.signinInteractionCoordinator.isSettingsViewPresented);
if (!baseViewController) { if (!baseViewController) {
DCHECK_EQ(self.mainController.currentBVC, DCHECK_EQ(self.currentInterface.bvc,
self.mainCoordinator.activeViewController); self.mainCoordinator.activeViewController);
baseViewController = self.mainController.currentBVC; baseViewController = self.currentInterface.bvc;
} }
if ([self.mainController currentBrowserState] -> IsOffTheRecord()) { if (self.currentInterface.incognito) {
NOTREACHED(); NOTREACHED();
return; return;
} }
...@@ -741,9 +745,9 @@ const NSTimeInterval kDisplayPromoDelay = 0.1; ...@@ -741,9 +745,9 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
(UIViewController*)baseViewController { (UIViewController*)baseViewController {
DCHECK(!self.signinInteractionCoordinator.isSettingsViewPresented); DCHECK(!self.signinInteractionCoordinator.isSettingsViewPresented);
if (!baseViewController) { if (!baseViewController) {
DCHECK_EQ(self.mainController.currentBVC, DCHECK_EQ(self.currentInterface.bvc,
self.mainCoordinator.activeViewController); self.mainCoordinator.activeViewController);
baseViewController = self.mainController.currentBVC; baseViewController = self.currentInterface.bvc;
} }
if (self.settingsNavigationController) { if (self.settingsNavigationController) {
...@@ -789,7 +793,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1; ...@@ -789,7 +793,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
if (!baseViewController) { if (!baseViewController) {
// TODO(crbug.com/779791): Don't pass base view controller through // TODO(crbug.com/779791): Don't pass base view controller through
// dispatched command. // dispatched command.
baseViewController = [self.mainController currentBVC]; baseViewController = self.currentInterface.bvc;
} }
DCHECK(!self.signinInteractionCoordinator.isSettingsViewPresented); DCHECK(!self.signinInteractionCoordinator.isSettingsViewPresented);
if (self.settingsNavigationController) { if (self.settingsNavigationController) {
...@@ -862,11 +866,15 @@ const NSTimeInterval kDisplayPromoDelay = 0.1; ...@@ -862,11 +866,15 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
#pragma mark - UserFeedbackDataSource #pragma mark - UserFeedbackDataSource
- (BOOL)currentPageIsIncognito {
return self.currentInterface.incognito;
}
- (NSString*)currentPageDisplayURL { - (NSString*)currentPageDisplayURL {
if (self.mainController.tabSwitcherIsActive) if (self.mainController.tabSwitcherIsActive)
return nil; return nil;
web::WebState* webState = web::WebState* webState =
self.mainController.currentTabModel.webStateList->GetActiveWebState(); self.currentInterface.browser->GetWebStateList()->GetActiveWebState();
if (!webState) if (!webState)
return nil; return nil;
// Returns URL of browser tab that is currently showing. // Returns URL of browser tab that is currently showing.
...@@ -887,7 +895,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1; ...@@ -887,7 +895,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
} }
- (NSString*)currentPageSyncedUserName { - (NSString*)currentPageSyncedUserName {
ChromeBrowserState* browserState = self.mainController.currentBrowserState; ChromeBrowserState* browserState = self.currentBrowserState;
if (browserState->IsOffTheRecord()) if (browserState->IsOffTheRecord())
return nil; return nil;
signin::IdentityManager* identity_manager = signin::IdentityManager* identity_manager =
...@@ -896,10 +904,6 @@ const NSTimeInterval kDisplayPromoDelay = 0.1; ...@@ -896,10 +904,6 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
return username.empty() ? nil : base::SysUTF8ToNSString(username); return username.empty() ? nil : base::SysUTF8ToNSString(username);
} }
- (BOOL)currentPageIsIncognito {
return self.mainController.currentBrowserState->IsOffTheRecord();
}
#pragma mark - SettingsNavigationControllerDelegate #pragma mark - SettingsNavigationControllerDelegate
- (void)closeSettings { - (void)closeSettings {
...@@ -913,7 +917,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1; ...@@ -913,7 +917,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
- (id<ApplicationCommands, BrowserCommands>)dispatcherForSettings { - (id<ApplicationCommands, BrowserCommands>)dispatcherForSettings {
// Assume that settings always wants the dispatcher from the main BVC. // Assume that settings always wants the dispatcher from the main BVC.
return self.mainController.mainBVC.dispatcher; return self.mainInterface.bvc.dispatcher;
} }
#pragma mark - TabSwitcherDelegate #pragma mark - TabSwitcherDelegate
...@@ -929,6 +933,10 @@ const NSTimeInterval kDisplayPromoDelay = 0.1; ...@@ -929,6 +933,10 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
[self finishDismissingTabSwitcher]; [self finishDismissingTabSwitcher];
} }
// Begins the process of dismissing the tab switcher with the given current
// model, switching which BVC is suspended if necessary, but not updating the
// UI. The omnibox will be focused after the tab switcher dismissal is
// completed if |focusOmnibox| is YES.
- (void)beginDismissingTabSwitcherWithCurrentModel:(TabModel*)tabModel - (void)beginDismissingTabSwitcherWithCurrentModel:(TabModel*)tabModel
focusOmnibox:(BOOL)focusOmnibox { focusOmnibox:(BOOL)focusOmnibox {
DCHECK(tabModel == self.mainInterface.tabModel || DCHECK(tabModel == self.mainInterface.tabModel ||
...@@ -945,6 +953,8 @@ const NSTimeInterval kDisplayPromoDelay = 0.1; ...@@ -945,6 +953,8 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
[self displayCurrentBVCAndFocusOmnibox:focusOmnibox]; [self displayCurrentBVCAndFocusOmnibox:focusOmnibox];
} }
// Completes the process of dismissing the tab switcher, removing it from the
// screen and showing the appropriate BVC.
- (void)finishDismissingTabSwitcher { - (void)finishDismissingTabSwitcher {
// In real world devices, it is possible to have an empty tab model at the // In real world devices, it is possible to have an empty tab model at the
// finishing block of a BVC presentation animation. This can happen when the // finishing block of a BVC presentation animation. This can happen when the
...@@ -969,7 +979,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1; ...@@ -969,7 +979,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
// as part of the BVC presentation process. The BVC is presented before the // as part of the BVC presentation process. The BVC is presented before the
// animations begin, so it should be the current active VC at this point. // animations begin, so it should be the current active VC at this point.
DCHECK_EQ(self.mainCoordinator.activeViewController, DCHECK_EQ(self.mainCoordinator.activeViewController,
self.mainController.currentBVC); self.currentInterface.bvc);
if (self.modeToDisplayOnTabSwitcherDismissal == if (self.modeToDisplayOnTabSwitcherDismissal ==
TabSwitcherDismissalMode::NORMAL) { TabSwitcherDismissalMode::NORMAL) {
...@@ -1003,11 +1013,17 @@ const NSTimeInterval kDisplayPromoDelay = 0.1; ...@@ -1003,11 +1013,17 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
}; };
case START_QR_CODE_SCANNER: case START_QR_CODE_SCANNER:
return ^{ return ^{
[self.mainController.currentBVC.dispatcher showQRScanner]; id<QRScannerCommands> QRHandler = HandlerForProtocol(
self.currentInterface.browser->GetCommandDispatcher(),
QRScannerCommands);
[QRHandler showQRScanner];
}; };
case FOCUS_OMNIBOX: case FOCUS_OMNIBOX:
return ^{ return ^{
[self.mainController.currentBVC.dispatcher focusOmnibox]; id<OmniboxFocuser> focusHandler = HandlerForProtocol(
self.currentInterface.browser->GetCommandDispatcher(),
OmniboxFocuser);
[focusHandler focusOmnibox];
}; };
default: default:
return nil; return nil;
...@@ -1024,7 +1040,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1; ...@@ -1024,7 +1040,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
if (backgroundBVC.playingTTS) if (backgroundBVC.playingTTS)
[backgroundBVC startVoiceSearch]; [backgroundBVC startVoiceSearch];
else else
[self.mainController.currentBVC startVoiceSearch]; [self.currentInterface.bvc startVoiceSearch];
} }
#pragma mark - TabSwitching #pragma mark - TabSwitching
...@@ -1080,18 +1096,16 @@ const NSTimeInterval kDisplayPromoDelay = 0.1; ...@@ -1080,18 +1096,16 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
} }
- (BOOL)URLIsOpenedInRegularMode:(const GURL&)URL { - (BOOL)URLIsOpenedInRegularMode:(const GURL&)URL {
WebStateList* webStateList = WebStateList* webStateList = self.mainInterface.browser->GetWebStateList();
self.mainController.interfaceProvider.mainInterface.tabModel.webStateList;
return webStateList && webStateList->GetIndexOfWebStateWithURL(URL) != return webStateList && webStateList->GetIndexOfWebStateWithURL(URL) !=
WebStateList::kInvalidIndex; WebStateList::kInvalidIndex;
} }
- (BOOL)shouldOpenNTPTabOnActivationOfTabModel:(TabModel*)tabModel { - (BOOL)shouldOpenNTPTabOnActivationOfTabModel:(TabModel*)tabModel {
if (self.mainController.tabSwitcherIsActive) { if (self.mainController.tabSwitcherIsActive) {
TabModel* mainTabModel = TabModel* mainTabModel = self.browserViewWrangler.mainInterface.tabModel;
self.mainController.interfaceProvider.mainInterface.tabModel;
TabModel* otrTabModel = TabModel* otrTabModel =
self.mainController.interfaceProvider.incognitoInterface.tabModel; self.browserViewWrangler.incognitoInterface.tabModel;
// Only attempt to dismiss the tab switcher and open a new tab if: // Only attempt to dismiss the tab switcher and open a new tab if:
// - there are no tabs open in either tab model, and // - there are no tabs open in either tab model, and
// - the tab switcher controller is not directly or indirectly presenting // - the tab switcher controller is not directly or indirectly presenting
...@@ -1168,7 +1182,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1; ...@@ -1168,7 +1182,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
// Then, depending on what the SSO view controller is presented on, dismiss // Then, depending on what the SSO view controller is presented on, dismiss
// it. // it.
ProceduralBlock completionWithBVC = ^{ ProceduralBlock completionWithBVC = ^{
DCHECK(self.mainController.currentBVC); DCHECK(self.currentInterface.bvc);
DCHECK(!self.mainController.tabSwitcherIsActive); DCHECK(!self.mainController.tabSwitcherIsActive);
DCHECK(!self.signinInteractionCoordinator.isActive); DCHECK(!self.signinInteractionCoordinator.isActive);
// This will dismiss the SSO view controller. // This will dismiss the SSO view controller.
...@@ -1177,7 +1191,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1; ...@@ -1177,7 +1191,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
dismissOmnibox:dismissOmnibox]; dismissOmnibox:dismissOmnibox];
}; };
ProceduralBlock completionWithoutBVC = ^{ ProceduralBlock completionWithoutBVC = ^{
// |self.mainController.currentBVC| 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.mainController.tabSwitcherIsActive);
// This will dismiss the SSO view controller. // This will dismiss the SSO view controller.
...@@ -1297,7 +1311,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1; ...@@ -1297,7 +1311,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
atIndex:tabIndex]; atIndex:tabIndex];
} }
} else { } else {
if (!self.mainController.currentBVC.presentedViewController) { if (!self.currentInterface.bvc.presentedViewController) {
[targetInterface.bvc expectNewForegroundTab]; [targetInterface.bvc expectNewForegroundTab];
} }
[self setCurrentInterfaceForMode:targetMode]; [self setCurrentInterfaceForMode:targetMode];
...@@ -1331,23 +1345,22 @@ const NSTimeInterval kDisplayPromoDelay = 0.1; ...@@ -1331,23 +1345,22 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
- (void)openNewTabFromOriginPoint:(CGPoint)originPoint - (void)openNewTabFromOriginPoint:(CGPoint)originPoint
focusOmnibox:(BOOL)focusOmnibox { focusOmnibox:(BOOL)focusOmnibox {
[self.mainController.currentBVC openNewTabFromOriginPoint:originPoint [self.currentInterface.bvc openNewTabFromOriginPoint:originPoint
focusOmnibox:focusOmnibox]; focusOmnibox:focusOmnibox];
} }
- (ChromeBrowserState*)currentBrowserState { - (ChromeBrowserState*)currentBrowserState {
return self.mainController.interfaceProvider.currentInterface.browserState; return self.browserViewWrangler.currentInterface.browserState;
} }
- (TabModel*)currentTabModel { - (TabModel*)currentTabModel {
return self.mainController.interfaceProvider.currentInterface.bvc.tabModel; return self.browserViewWrangler.currentInterface.bvc.tabModel;
} }
// Asks the respective Snapshot helper to update the snapshot for the active // Asks the respective Snapshot helper to update the snapshot for the active
// WebState. // WebState.
- (void)updateActiveWebStateSnapshot { - (void)updateActiveWebStateSnapshot {
WebStateList* webStateList = WebStateList* webStateList = self.currentInterface.bvc.tabModel.webStateList;
self.mainController.currentBVC.tabModel.webStateList;
if (webStateList) { if (webStateList) {
web::WebState* webState = webStateList->GetActiveWebState(); web::WebState* webState = webStateList->GetActiveWebState();
if (webState) { if (webState) {
...@@ -1367,8 +1380,8 @@ const NSTimeInterval kDisplayPromoDelay = 0.1; ...@@ -1367,8 +1380,8 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
tabOpenedCompletion:(ProceduralBlock)tabOpenedCompletion { tabOpenedCompletion:(ProceduralBlock)tabOpenedCompletion {
BrowserViewController* targetBVC = BrowserViewController* targetBVC =
targetMode == ApplicationMode::NORMAL targetMode == ApplicationMode::NORMAL
? self.mainController.interfaceProvider.mainInterface.bvc ? self.browserViewWrangler.mainInterface.bvc
: self.mainController.interfaceProvider.incognitoInterface.bvc; : self.browserViewWrangler.incognitoInterface.bvc;
web::WebState* currentWebState = web::WebState* currentWebState =
targetBVC.tabModel.webStateList->GetActiveWebState(); targetBVC.tabModel.webStateList->GetActiveWebState();
...@@ -1416,8 +1429,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1; ...@@ -1416,8 +1429,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
- (void)displayCurrentBVCAndFocusOmnibox:(BOOL)focusOmnibox { - (void)displayCurrentBVCAndFocusOmnibox:(BOOL)focusOmnibox {
ProceduralBlock completion = nil; ProceduralBlock completion = nil;
if (focusOmnibox) { if (focusOmnibox) {
__weak BrowserViewController* weakCurrentBVC = __weak BrowserViewController* weakCurrentBVC = self.currentInterface.bvc;
self.mainController.currentBVC;
completion = ^{ completion = ^{
[weakCurrentBVC.dispatcher focusOmnibox]; [weakCurrentBVC.dispatcher focusOmnibox];
}; };
...@@ -1436,7 +1448,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1; ...@@ -1436,7 +1448,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
UIViewController* accountsViewController = UIViewController* accountsViewController =
[[SignedInAccountsViewController alloc] [[SignedInAccountsViewController alloc]
initWithBrowserState:browserState initWithBrowserState:browserState
dispatcher:self.mainController.mainBVC.dispatcher]; dispatcher:self.mainInterface.bvc.dispatcher];
[[self topPresentedViewController] [[self topPresentedViewController]
presentViewController:accountsViewController presentViewController:accountsViewController
animated:YES animated:YES
...@@ -1525,11 +1537,11 @@ const NSTimeInterval kDisplayPromoDelay = 0.1; ...@@ -1525,11 +1537,11 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
// 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.mainController.tabSwitcherIsActive ||
![self.mainController.currentTabModel isOffTheRecord]) { ![self.currentTabModel isOffTheRecord]) {
return; return;
} }
if ([self.mainController.currentTabModel count] == 0U) { if ([self.currentTabModel count] == 0U) {
[self showTabSwitcher]; [self showTabSwitcher];
} else { } else {
[self setCurrentInterfaceForMode:ApplicationMode::NORMAL]; [self setCurrentInterfaceForMode:ApplicationMode::NORMAL];
...@@ -1545,13 +1557,15 @@ const NSTimeInterval kDisplayPromoDelay = 0.1; ...@@ -1545,13 +1557,15 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
// current. // current.
// Nothing to do here. // Nothing to do here.
if (self.mainController.tabSwitcherIsActive || if (self.mainController.tabSwitcherIsActive ||
[self.mainController.currentTabModel isOffTheRecord]) { [self.currentTabModel isOffTheRecord]) {
return; return;
} }
[self showTabSwitcher]; [self showTabSwitcher];
} }
// Clears incognito data that is specific to iOS and won't be cleared by
// deleting the browser state.
- (void)clearIOSSpecificIncognitoData { - (void)clearIOSSpecificIncognitoData {
DCHECK(self.mainController.mainBrowserState DCHECK(self.mainController.mainBrowserState
->HasOffTheRecordChromeBrowserState()); ->HasOffTheRecordChromeBrowserState());
...@@ -1577,7 +1591,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1; ...@@ -1577,7 +1591,7 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
self.interfaceProvider.mainInterface.userInteractionEnabled = YES; self.interfaceProvider.mainInterface.userInteractionEnabled = YES;
self.interfaceProvider.incognitoInterface.userInteractionEnabled = YES; self.interfaceProvider.incognitoInterface.userInteractionEnabled = YES;
[self.mainController.currentBVC setPrimary:YES]; [self.currentInterface.bvc setPrimary:YES];
} }
- (void)showTabSwitcher { - (void)showTabSwitcher {
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
class ChromeBrowserState; class ChromeBrowserState;
@class BrowserViewWrangler; @class BrowserViewWrangler;
@class TabModel;
@protocol SceneControllerGuts <WebStateListObserving> @protocol SceneControllerGuts <WebStateListObserving>
...@@ -26,24 +25,9 @@ class ChromeBrowserState; ...@@ -26,24 +25,9 @@ class ChromeBrowserState;
// BrowserViewInformation protocol. // BrowserViewInformation protocol.
@property(nonatomic, strong) BrowserViewWrangler* browserViewWrangler; @property(nonatomic, strong) BrowserViewWrangler* browserViewWrangler;
// The scene level component for url loading. Is passed down to
// browser state level UrlLoadingService instances.
@property(nonatomic, assign) AppUrlLoadingService* appURLLoadingService;
- (void)startUpChromeUIPostCrash:(BOOL)isPostCrashLaunch - (void)startUpChromeUIPostCrash:(BOOL)isPostCrashLaunch
needRestoration:(BOOL)needsRestoration; needRestoration:(BOOL)needsRestoration;
- (void)dismissModalDialogsWithCompletion:(ProceduralBlock)completion
dismissOmnibox:(BOOL)dismissOmnibox;
- (void)openSelectedTabInMode:(ApplicationModeForTabOpening)tabOpeningTargetMode
withUrlLoadParams:(const UrlLoadParams&)urlLoadParams
completion:(ProceduralBlock)completion;
- (void)openTabFromLaunchOptions:(NSDictionary*)launchOptions
startupInformation:(id<StartupInformation>)startupInformation
appState:(AppState*)appState;
- (void)dismissModalsAndOpenSelectedTabInMode: - (void)dismissModalsAndOpenSelectedTabInMode:
(ApplicationModeForTabOpening)targetMode (ApplicationModeForTabOpening)targetMode
withUrlLoadParams: withUrlLoadParams:
...@@ -51,27 +35,15 @@ class ChromeBrowserState; ...@@ -51,27 +35,15 @@ class ChromeBrowserState;
dismissOmnibox:(BOOL)dismissOmnibox dismissOmnibox:(BOOL)dismissOmnibox
completion:(ProceduralBlock)completion; completion:(ProceduralBlock)completion;
- (BOOL)shouldOpenNTPTabOnActivationOfTabModel:(TabModel*)tabModel;
// TabSwitcherDelegate helpers
// Begins the process of dismissing the tab switcher with the given current
// model, switching which BVC is suspended if necessary, but not updating the
// UI. The omnibox will be focused after the tab switcher dismissal is
// completed if |focusOmnibox| is YES.
- (void)beginDismissingTabSwitcherWithCurrentModel:(TabModel*)tabModel
focusOmnibox:(BOOL)focusOmnibox;
// Completes the process of dismissing the tab switcher, removing it from the
// screen and showing the appropriate BVC.
- (void)finishDismissingTabSwitcher;
- (BOOL)presentingFirstRunUI;
// Testing only. // Testing only.
- (BOOL)presentingFirstRunUI;
- (void)showFirstRunUI; - (void)showFirstRunUI;
- (void)setTabSwitcher:(id<TabSwitcher>)switcher; - (void)setTabSwitcher:(id<TabSwitcher>)switcher;
- (id<TabSwitcher>)tabSwitcher; - (id<TabSwitcher>)tabSwitcher;
- (void)dismissModalDialogsWithCompletion:(ProceduralBlock)completion
dismissOmnibox:(BOOL)dismissOmnibox;
#pragma mark - AppNavigation helpers #pragma mark - AppNavigation helpers
// Presents a SignedInAccountsViewController for |browserState| on the top view // Presents a SignedInAccountsViewController for |browserState| on the top view
...@@ -79,12 +51,6 @@ class ChromeBrowserState; ...@@ -79,12 +51,6 @@ class ChromeBrowserState;
- (void)presentSignedInAccountsViewControllerForBrowserState: - (void)presentSignedInAccountsViewControllerForBrowserState:
(ChromeBrowserState*)browserState; (ChromeBrowserState*)browserState;
// Clears incognito data that is specific to iOS and won't be cleared by
// deleting the browser state.
- (void)clearIOSSpecificIncognitoData;
- (void)activateBVCAndMakeCurrentBVCPrimary;
#pragma mark - iOS 12 compat #pragma mark - iOS 12 compat
// Method called on SceneController when the scene disconnects. Exposed here for // Method called on SceneController when the scene disconnects. Exposed here for
......
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