Commit 4ae39b82 authored by Stepan Khapugin's avatar Stepan Khapugin Committed by Commit Bot

[multiball] Create MainControllerGuts protocol.

Creates a new protocol to expose MainController internals to
SceneController.
Makes a bunch of ivars in MainController properties.

Bug: 1012697
Change-Id: Ia1607c7ed75cb0b2edf99252d9c0342237e92b26
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1848695
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707353}
parent 619e8002
...@@ -133,6 +133,7 @@ source_set("app_internal") { ...@@ -133,6 +133,7 @@ source_set("app_internal") {
"main_application_delegate_testing.h", "main_application_delegate_testing.h",
"main_controller.h", "main_controller.h",
"main_controller.mm", "main_controller.mm",
"main_controller_guts.h",
"main_controller_private.h", "main_controller_private.h",
"memory_monitor.h", "memory_monitor.h",
"memory_monitor.mm", "memory_monitor.mm",
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#import "ios/chrome/app/application_delegate/startup_information.h" #import "ios/chrome/app/application_delegate/startup_information.h"
#import "ios/chrome/app/application_delegate/tab_opening.h" #import "ios/chrome/app/application_delegate/tab_opening.h"
#import "ios/chrome/app/application_delegate/tab_switching.h" #import "ios/chrome/app/application_delegate/tab_switching.h"
#import "ios/chrome/app/main_controller_guts.h"
#import "ios/chrome/browser/ui/commands/application_commands.h" #import "ios/chrome/browser/ui/commands/application_commands.h"
@class AppState; @class AppState;
...@@ -23,12 +24,13 @@ ...@@ -23,12 +24,13 @@
// //
// By design, it has no public API of its own. Anything interacting with // By design, it has no public API of its own. Anything interacting with
// MainController should be doing so through a specific protocol. // MainController should be doing so through a specific protocol.
@interface MainController : NSObject<ApplicationCommands, @interface MainController : NSObject <ApplicationCommands,
AppNavigation, AppNavigation,
BrowserLauncher, BrowserLauncher,
StartupInformation, MainControllerGuts,
TabOpening, StartupInformation,
TabSwitching> TabOpening,
TabSwitching>
// The application window. // The application window.
@property(nonatomic, strong) UIWindow* window; @property(nonatomic, strong) UIWindow* window;
......
...@@ -330,9 +330,6 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -330,9 +330,6 @@ enum class EnterTabSwitcherSnapshotResult {
// The object that drives the Chrome startup/shutdown logic. // The object that drives the Chrome startup/shutdown logic.
std::unique_ptr<IOSChromeMain> _chromeMain; std::unique_ptr<IOSChromeMain> _chromeMain;
// The ChromeBrowserState associated with the main (non-OTR) browsing mode.
ios::ChromeBrowserState* _mainBrowserState; // Weak.
// Wrangler to handle BVC and tab model creation, access, and related logic. // Wrangler to handle BVC and tab model creation, access, and related logic.
// Implements faetures exposed from this object through the // Implements faetures exposed from this object through the
// BrowserViewInformation protocol. // BrowserViewInformation protocol.
...@@ -372,18 +369,6 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -372,18 +369,6 @@ enum class EnterTabSwitcherSnapshotResult {
// in a modal dialog. // in a modal dialog.
BOOL _isPresentingFirstRunUI; BOOL _isPresentingFirstRunUI;
// The tab switcher command and the voice search commands can be sent by views
// that reside in a different UIWindow leading to the fact that the exclusive
// touch property will be ineffective and a command for processing both
// commands may be sent in the same run of the runloop leading to
// inconsistencies. Those two boolean indicate if one of those commands have
// been processed in the last 200ms in order to only allow processing one at
// a time.
// TODO(crbug.com/560296): Provide a general solution for handling mutually
// exclusive chrome commands sent at nearly the same time.
BOOL _isProcessingTabSwitcherCommand;
BOOL _isProcessingVoiceSearchCommand;
// Bridge to listen to pref changes. // Bridge to listen to pref changes.
std::unique_ptr<PrefObserverBridge> _localStatePrefObserverBridge; std::unique_ptr<PrefObserverBridge> _localStatePrefObserverBridge;
...@@ -406,23 +391,20 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -406,23 +391,20 @@ enum class EnterTabSwitcherSnapshotResult {
// Cached launchOptions from -didFinishLaunchingWithOptions. // Cached launchOptions from -didFinishLaunchingWithOptions.
NSDictionary* _launchOptions; NSDictionary* _launchOptions;
// Coordinator for displaying history.
HistoryCoordinator* _historyCoordinator;
// Variable backing metricsMediator property. // Variable backing metricsMediator property.
__weak MetricsMediator* _metricsMediator; __weak MetricsMediator* _metricsMediator;
// Hander for the startup tasks, deferred or not. // Hander for the startup tasks, deferred or not.
StartupTasks* _startupTasks; StartupTasks* _startupTasks;
// The application level component for url loading. Is passed down to
// browser state level UrlLoadingService instances.
AppUrlLoadingService* _appURLLoadingService;
// If the animations were disabled. // If the animations were disabled.
BOOL _animationDisabled; BOOL _animationDisabled;
} }
// The ChromeBrowserState associated with the main (non-OTR) browsing mode.
@property(nonatomic, assign)
ios::ChromeBrowserState* mainBrowserState; // Weak.
// The main coordinator, lazily created the first time it is accessed. Manages // The main coordinator, lazily created the first time it is accessed. Manages
// 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.
...@@ -434,12 +416,6 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -434,12 +416,6 @@ enum class EnterTabSwitcherSnapshotResult {
@property(nonatomic, readwrite) @property(nonatomic, readwrite)
NTPTabOpeningPostOpeningAction NTPActionAfterTabSwitcherDismissal; NTPTabOpeningPostOpeningAction NTPActionAfterTabSwitcherDismissal;
// The SigninInteractionCoordinator to present Sign In UI. It is created the
// first time Sign In UI is needed to be presented and should not be destroyed
// while the UI is presented.
@property(nonatomic, strong)
SigninInteractionCoordinator* signinInteractionCoordinator;
// Returns YES if the settings are presented, either from // Returns YES if the settings are presented, either from
// _settingsNavigationController or from SigninInteractionCoordinator. // _settingsNavigationController or from SigninInteractionCoordinator.
@property(nonatomic, assign, readonly, getter=isSettingsViewPresented) @property(nonatomic, assign, readonly, getter=isSettingsViewPresented)
...@@ -573,10 +549,15 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -573,10 +549,15 @@ enum class EnterTabSwitcherSnapshotResult {
@end @end
@implementation MainController @implementation MainController
// Defined by MainControllerGuts.
@synthesize historyCoordinator;
@synthesize settingsNavigationController;
@synthesize appURLLoadingService;
@synthesize isProcessingTabSwitcherCommand;
@synthesize isProcessingVoiceSearchCommand;
@synthesize signinInteractionCoordinator;
// Defined by public protocols. // Defined by public protocols.
// - AppNavigation
@synthesize settingsNavigationController = _settingsNavigationController;
// - BrowserLauncher // - BrowserLauncher
@synthesize launchOptions = _launchOptions; @synthesize launchOptions = _launchOptions;
@synthesize browserInitializationStage = _browserInitializationStage; @synthesize browserInitializationStage = _browserInitializationStage;
...@@ -589,7 +570,6 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -589,7 +570,6 @@ enum class EnterTabSwitcherSnapshotResult {
@synthesize mainCoordinator = _mainCoordinator; @synthesize mainCoordinator = _mainCoordinator;
@synthesize NTPActionAfterTabSwitcherDismissal = @synthesize NTPActionAfterTabSwitcherDismissal =
_NTPActionAfterTabSwitcherDismissal; _NTPActionAfterTabSwitcherDismissal;
@synthesize signinInteractionCoordinator = _signinInteractionCoordinator;
#pragma mark - Application lifecycle #pragma mark - Application lifecycle
...@@ -721,29 +701,29 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -721,29 +701,29 @@ enum class EnterTabSwitcherSnapshotResult {
[_restoreHelper moveAsideSessionInformation]; [_restoreHelper moveAsideSessionInformation];
} }
_appURLLoadingService = new AppUrlLoadingService(); self.appURLLoadingService = new AppUrlLoadingService();
_appURLLoadingService->SetDelegate(self); self.appURLLoadingService->SetDelegate(self);
// Initialize and set the main browser state. // Initialize and set the main browser state.
[self initializeBrowserState:chromeBrowserState]; [self initializeBrowserState:chromeBrowserState];
_mainBrowserState = chromeBrowserState; self.mainBrowserState = chromeBrowserState;
[_browserViewWrangler shutdown]; [_browserViewWrangler shutdown];
_browserViewWrangler = _browserViewWrangler = [[BrowserViewWrangler alloc]
[[BrowserViewWrangler alloc] initWithBrowserState:_mainBrowserState initWithBrowserState:self.mainBrowserState
webStateListObserver:self webStateListObserver:self
applicationCommandEndpoint:self applicationCommandEndpoint:self
appURLLoadingService:_appURLLoadingService appURLLoadingService:self.appURLLoadingService
storageSwitcher:self]; storageSwitcher:self];
// Force an obvious initialization of the AuthenticationService. This must // Force an obvious initialization of the AuthenticationService. This must
// be done before creation of the UI to ensure the service is initialised // be done before creation of the UI to ensure the service is initialised
// before use (it is a security issue, so accessing the service CHECK if // before use (it is a security issue, so accessing the service CHECK if
// this is not the case). // this is not the case).
DCHECK(_mainBrowserState); DCHECK(self.mainBrowserState);
AuthenticationServiceFactory::CreateAndInitializeForBrowserState( AuthenticationServiceFactory::CreateAndInitializeForBrowserState(
_mainBrowserState, self.mainBrowserState,
std::make_unique<MainControllerAuthenticationServiceDelegate>( std::make_unique<MainControllerAuthenticationServiceDelegate>(
_mainBrowserState, self)); self.mainBrowserState, self));
// Send "Chrome Opened" event to the feature_engagement::Tracker on cold // Send "Chrome Opened" event to the feature_engagement::Tracker on cold
// start. // start.
...@@ -757,10 +737,10 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -757,10 +737,10 @@ enum class EnterTabSwitcherSnapshotResult {
[_browserViewWrangler createMainBrowser]; [_browserViewWrangler createMainBrowser];
_spotlightManager = _spotlightManager =
[SpotlightManager spotlightManagerWithBrowserState:_mainBrowserState]; [SpotlightManager spotlightManagerWithBrowserState:self.mainBrowserState];
ShareExtensionService* service = ShareExtensionService* service =
ShareExtensionServiceFactory::GetForBrowserState(_mainBrowserState); ShareExtensionServiceFactory::GetForBrowserState(self.mainBrowserState);
service->Initialize(); service->Initialize();
// Before bringing up the UI, make sure the launch mode is correct, and // Before bringing up the UI, make sure the launch mode is correct, and
...@@ -791,9 +771,9 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -791,9 +771,9 @@ enum class EnterTabSwitcherSnapshotResult {
interfaceProvider:self.interfaceProvider]; interfaceProvider:self.interfaceProvider];
if (self.isColdStart) { if (self.isColdStart) {
[ContentSuggestionsSchedulerNotifications [ContentSuggestionsSchedulerNotifications
notifyColdStart:_mainBrowserState]; notifyColdStart:self.mainBrowserState];
[ContentSuggestionsSchedulerNotifications [ContentSuggestionsSchedulerNotifications
notifyForeground:_mainBrowserState]; notifyForeground:self.mainBrowserState];
} }
ios::GetChromeBrowserProvider()->GetOverridesProvider()->InstallOverrides(); ios::GetChromeBrowserProvider()->GetOverridesProvider()->InstallOverrides();
...@@ -868,9 +848,9 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -868,9 +848,9 @@ enum class EnterTabSwitcherSnapshotResult {
} }
- (void)clearIOSSpecificIncognitoData { - (void)clearIOSSpecificIncognitoData {
DCHECK(_mainBrowserState->HasOffTheRecordChromeBrowserState()); DCHECK(self.mainBrowserState->HasOffTheRecordChromeBrowserState());
ios::ChromeBrowserState* otrBrowserState = ios::ChromeBrowserState* otrBrowserState =
_mainBrowserState->GetOffTheRecordChromeBrowserState(); self.mainBrowserState->GetOffTheRecordChromeBrowserState();
[self removeBrowsingDataForBrowserState:otrBrowserState [self removeBrowsingDataForBrowserState:otrBrowserState
timePeriod:browsing_data::TimePeriod::ALL_TIME timePeriod:browsing_data::TimePeriod::ALL_TIME
removeMask:BrowsingDataRemoveMask::REMOVE_ALL removeMask:BrowsingDataRemoveMask::REMOVE_ALL
...@@ -988,8 +968,8 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -988,8 +968,8 @@ enum class EnterTabSwitcherSnapshotResult {
_extensionSearchEngineDataUpdater = nullptr; _extensionSearchEngineDataUpdater = nullptr;
[_historyCoordinator stop]; [self.historyCoordinator stop];
_historyCoordinator = nil; self.historyCoordinator = nil;
ios::GetChromeBrowserProvider() ios::GetChromeBrowserProvider()
->GetMailtoHandlerProvider() ->GetMailtoHandlerProvider()
...@@ -1096,7 +1076,7 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -1096,7 +1076,7 @@ enum class EnterTabSwitcherSnapshotResult {
// Track changes to default search engine. // Track changes to default search engine.
TemplateURLService* service = TemplateURLService* service =
ios::TemplateURLServiceFactory::GetForBrowserState( ios::TemplateURLServiceFactory::GetForBrowserState(
_mainBrowserState); self.mainBrowserState);
_extensionSearchEngineDataUpdater = _extensionSearchEngineDataUpdater =
std::make_unique<ExtensionSearchEngineDataUpdater>( std::make_unique<ExtensionSearchEngineDataUpdater>(
service); service);
...@@ -1108,7 +1088,7 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -1108,7 +1088,7 @@ enum class EnterTabSwitcherSnapshotResult {
enqueueBlockNamed:kSendInstallPingIfNecessary enqueueBlockNamed:kSendInstallPingIfNecessary
block:^{ block:^{
auto URLLoaderFactory = auto URLLoaderFactory =
_mainBrowserState->GetSharedURLLoaderFactory(); self.mainBrowserState->GetSharedURLLoaderFactory();
bool is_first_run = FirstRun::IsChromeFirstRun(); bool is_first_run = FirstRun::IsChromeFirstRun();
ios::GetChromeBrowserProvider() ios::GetChromeBrowserProvider()
->GetAppDistributionProvider() ->GetAppDistributionProvider()
...@@ -1168,10 +1148,10 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -1168,10 +1148,10 @@ enum class EnterTabSwitcherSnapshotResult {
// ClearSessionCookies() is not synchronous. // ClearSessionCookies() is not synchronous.
if (cookie_util::ShouldClearSessionCookies()) { if (cookie_util::ShouldClearSessionCookies()) {
cookie_util::ClearSessionCookies( cookie_util::ClearSessionCookies(
_mainBrowserState->GetOriginalChromeBrowserState()); self.mainBrowserState->GetOriginalChromeBrowserState());
if (![self.otrTabModel isEmpty]) { if (![self.otrTabModel isEmpty]) {
cookie_util::ClearSessionCookies( cookie_util::ClearSessionCookies(
_mainBrowserState->GetOffTheRecordChromeBrowserState()); self.mainBrowserState->GetOffTheRecordChromeBrowserState());
} }
} }
...@@ -1201,12 +1181,12 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -1201,12 +1181,12 @@ enum class EnterTabSwitcherSnapshotResult {
enqueueBlockNamed:kMailtoHandlingInitialization enqueueBlockNamed:kMailtoHandlingInitialization
block:^{ block:^{
__strong __typeof(weakSelf) strongSelf = weakSelf; __strong __typeof(weakSelf) strongSelf = weakSelf;
if (!strongSelf || !strongSelf->_mainBrowserState) { if (!strongSelf || !strongSelf.mainBrowserState) {
return; return;
} }
ios::GetChromeBrowserProvider() ios::GetChromeBrowserProvider()
->GetMailtoHandlerProvider() ->GetMailtoHandlerProvider()
->PrepareMailtoHandling(strongSelf->_mainBrowserState); ->PrepareMailtoHandling(strongSelf.mainBrowserState);
}]; }];
} }
...@@ -1276,7 +1256,8 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -1276,7 +1256,8 @@ enum class EnterTabSwitcherSnapshotResult {
// Deferred tasks. // Deferred tasks.
[self schedulePrefObserverInitialization]; [self schedulePrefObserverInitialization];
[self scheduleMemoryDebuggingTools]; [self scheduleMemoryDebuggingTools];
[StartupTasks scheduleDeferredBrowserStateInitialization:_mainBrowserState]; [StartupTasks
scheduleDeferredBrowserStateInitialization:self.mainBrowserState];
[self scheduleAuthenticationServiceNotification]; [self scheduleAuthenticationServiceNotification];
[self sendQueuedFeedback]; [self sendQueuedFeedback];
[self scheduleSpotlightResync]; [self scheduleSpotlightResync];
...@@ -1294,7 +1275,7 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -1294,7 +1275,7 @@ enum class EnterTabSwitcherSnapshotResult {
if (GetApplicationContext()->WasLastShutdownClean()) { if (GetApplicationContext()->WasLastShutdownClean()) {
// Delay the cleanup of the unreferenced files to not impact startup // Delay the cleanup of the unreferenced files to not impact startup
// performance. // performance.
ExternalFileRemoverFactory::GetForBrowserState(_mainBrowserState) ExternalFileRemoverFactory::GetForBrowserState(self.mainBrowserState)
->RemoveAfterDelay( ->RemoveAfterDelay(
base::TimeDelta::FromSeconds(kExternalFilesCleanupDelaySeconds), base::TimeDelta::FromSeconds(kExternalFilesCleanupDelaySeconds),
base::OnceClosure()); base::OnceClosure());
...@@ -1361,7 +1342,7 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -1361,7 +1342,7 @@ enum class EnterTabSwitcherSnapshotResult {
} }
- (void)createInitialUI:(ApplicationMode)launchMode { - (void)createInitialUI:(ApplicationMode)launchMode {
DCHECK(_mainBrowserState); DCHECK(self.mainBrowserState);
// In order to correctly set the mode switch icon, we need to know how many // In order to correctly set the mode switch icon, we need to know how many
// tabs are in the other tab model. That means loading both models. They // tabs are in the other tab model. That means loading both models. They
...@@ -1395,8 +1376,8 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -1395,8 +1376,8 @@ enum class EnterTabSwitcherSnapshotResult {
ios::ChromeBrowserState* browserState = ios::ChromeBrowserState* browserState =
(launchMode == ApplicationMode::INCOGNITO) (launchMode == ApplicationMode::INCOGNITO)
? _mainBrowserState->GetOffTheRecordChromeBrowserState() ? self.mainBrowserState->GetOffTheRecordChromeBrowserState()
: _mainBrowserState; : self.mainBrowserState;
[self changeStorageFromBrowserState:nullptr toBrowserState:browserState]; [self changeStorageFromBrowserState:nullptr toBrowserState:browserState];
TabModel* tabModel; TabModel* tabModel;
...@@ -1444,7 +1425,7 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -1444,7 +1425,7 @@ enum class EnterTabSwitcherSnapshotResult {
WelcomeToChromeViewController* welcomeToChrome = WelcomeToChromeViewController* welcomeToChrome =
[[WelcomeToChromeViewController alloc] [[WelcomeToChromeViewController alloc]
initWithBrowserState:_mainBrowserState initWithBrowserState:self.mainBrowserState
tabModel:self.mainTabModel tabModel:self.mainTabModel
presenter:self.mainBVC presenter:self.mainBVC
dispatcher:self.mainBVC.dispatcher]; dispatcher:self.mainBVC.dispatcher];
...@@ -1486,9 +1467,9 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -1486,9 +1467,9 @@ enum class EnterTabSwitcherSnapshotResult {
// Show the sign-in promo if needed // Show the sign-in promo if needed
if ([SigninPromoViewController if ([SigninPromoViewController
shouldBePresentedForBrowserState:_mainBrowserState]) { shouldBePresentedForBrowserState:self.mainBrowserState]) {
UIViewController* promoController = [[SigninPromoViewController alloc] UIViewController* promoController = [[SigninPromoViewController alloc]
initWithBrowserState:_mainBrowserState initWithBrowserState:self.mainBrowserState
dispatcher:self.mainBVC.dispatcher]; dispatcher:self.mainBVC.dispatcher];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, dispatch_after(dispatch_time(DISPATCH_TIME_NOW,
...@@ -1533,14 +1514,14 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -1533,14 +1514,14 @@ enum class EnterTabSwitcherSnapshotResult {
} }
- (void)showHistory { - (void)showHistory {
_historyCoordinator = self.historyCoordinator = [[HistoryCoordinator alloc]
[[HistoryCoordinator alloc] initWithBaseViewController:self.currentBVC initWithBaseViewController:self.currentBVC
browserState:_mainBrowserState]; browserState:self.mainBrowserState];
_historyCoordinator.loadStrategy = [self currentPageIsIncognito] self.historyCoordinator.loadStrategy =
? UrlLoadStrategy::ALWAYS_IN_INCOGNITO [self currentPageIsIncognito] ? UrlLoadStrategy::ALWAYS_IN_INCOGNITO
: UrlLoadStrategy::NORMAL; : UrlLoadStrategy::NORMAL;
_historyCoordinator.dispatcher = self.mainBVC.dispatcher; self.historyCoordinator.dispatcher = self.mainBVC.dispatcher;
[_historyCoordinator start]; [self.historyCoordinator start];
} }
- (void)closeSettingsUIAndOpenURL:(OpenNewTabCommand*)command { - (void)closeSettingsUIAndOpenURL:(OpenNewTabCommand*)command {
...@@ -1582,14 +1563,14 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -1582,14 +1563,14 @@ enum class EnterTabSwitcherSnapshotResult {
- (void)displayTabSwitcher { - (void)displayTabSwitcher {
DCHECK(!_tabSwitcherIsActive); DCHECK(!_tabSwitcherIsActive);
if (!_isProcessingVoiceSearchCommand) { if (!self.isProcessingVoiceSearchCommand) {
[self.currentBVC userEnteredTabSwitcher]; [self.currentBVC userEnteredTabSwitcher];
[self showTabSwitcher]; [self showTabSwitcher];
_isProcessingTabSwitcherCommand = YES; self.isProcessingTabSwitcherCommand = YES;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, dispatch_after(dispatch_time(DISPATCH_TIME_NOW,
kExpectedTransitionDurationInNanoSeconds), kExpectedTransitionDurationInNanoSeconds),
dispatch_get_main_queue(), ^{ dispatch_get_main_queue(), ^{
_isProcessingTabSwitcherCommand = NO; self.isProcessingTabSwitcherCommand = NO;
}); });
} }
} }
...@@ -1642,7 +1623,7 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -1642,7 +1623,7 @@ enum class EnterTabSwitcherSnapshotResult {
params.from_chrome = command.fromChrome; params.from_chrome = command.fromChrome;
params.user_initiated = command.userInitiated; params.user_initiated = command.userInitiated;
params.should_focus_omnibox = command.shouldFocusOmnibox; params.should_focus_omnibox = command.shouldFocusOmnibox;
_appURLLoadingService->LoadUrlInNewTab(params); self.appURLLoadingService->LoadUrlInNewTab(params);
} }
// TODO(crbug.com/779791) : Do not pass |baseViewController| through dispatcher. // TODO(crbug.com/779791) : Do not pass |baseViewController| through dispatcher.
...@@ -1650,7 +1631,7 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -1650,7 +1631,7 @@ enum class EnterTabSwitcherSnapshotResult {
baseViewController:(UIViewController*)baseViewController { baseViewController:(UIViewController*)baseViewController {
if (!self.signinInteractionCoordinator) { if (!self.signinInteractionCoordinator) {
self.signinInteractionCoordinator = [[SigninInteractionCoordinator alloc] self.signinInteractionCoordinator = [[SigninInteractionCoordinator alloc]
initWithBrowserState:_mainBrowserState initWithBrowserState:self.mainBrowserState
dispatcher:self.mainBVC.dispatcher]; dispatcher:self.mainBVC.dispatcher];
} }
...@@ -1675,7 +1656,7 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -1675,7 +1656,7 @@ enum class EnterTabSwitcherSnapshotResult {
- (void)showAdvancedSigninSettingsFromViewController: - (void)showAdvancedSigninSettingsFromViewController:
(UIViewController*)baseViewController { (UIViewController*)baseViewController {
self.signinInteractionCoordinator = [[SigninInteractionCoordinator alloc] self.signinInteractionCoordinator = [[SigninInteractionCoordinator alloc]
initWithBrowserState:_mainBrowserState initWithBrowserState:self.mainBrowserState
dispatcher:self.mainBVC.dispatcher]; dispatcher:self.mainBVC.dispatcher];
[self.signinInteractionCoordinator [self.signinInteractionCoordinator
showAdvancedSigninSettingsWithPresentingViewController: showAdvancedSigninSettingsWithPresentingViewController:
...@@ -1686,7 +1667,7 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -1686,7 +1667,7 @@ enum class EnterTabSwitcherSnapshotResult {
- (void)showAddAccountFromViewController:(UIViewController*)baseViewController { - (void)showAddAccountFromViewController:(UIViewController*)baseViewController {
if (!self.signinInteractionCoordinator) { if (!self.signinInteractionCoordinator) {
self.signinInteractionCoordinator = [[SigninInteractionCoordinator alloc] self.signinInteractionCoordinator = [[SigninInteractionCoordinator alloc]
initWithBrowserState:_mainBrowserState initWithBrowserState:self.mainBrowserState
dispatcher:self.mainBVC.dispatcher]; dispatcher:self.mainBVC.dispatcher];
} }
...@@ -1959,7 +1940,7 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -1959,7 +1940,7 @@ enum class EnterTabSwitcherSnapshotResult {
// browser state. // browser state.
breakpad_helper::SetDestroyingAndRebuildingIncognitoBrowserState( breakpad_helper::SetDestroyingAndRebuildingIncognitoBrowserState(
/*in_progress=*/true); /*in_progress=*/true);
DCHECK(_mainBrowserState->HasOffTheRecordChromeBrowserState()); DCHECK(self.mainBrowserState->HasOffTheRecordChromeBrowserState());
[self clearIOSSpecificIncognitoData]; [self clearIOSSpecificIncognitoData];
// OffTheRecordProfileIOData cannot be deleted before all the requests are // OffTheRecordProfileIOData cannot be deleted before all the requests are
...@@ -2004,13 +1985,13 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -2004,13 +1985,13 @@ enum class EnterTabSwitcherSnapshotResult {
#pragma mark - Mode Switching #pragma mark - Mode Switching
- (void)startVoiceSearch { - (void)startVoiceSearch {
if (!_isProcessingTabSwitcherCommand) { if (!self.isProcessingTabSwitcherCommand) {
[self startVoiceSearchInCurrentBVC]; [self startVoiceSearchInCurrentBVC];
_isProcessingVoiceSearchCommand = YES; self.isProcessingVoiceSearchCommand = YES;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, dispatch_after(dispatch_time(DISPATCH_TIME_NOW,
kExpectedTransitionDurationInNanoSeconds), kExpectedTransitionDurationInNanoSeconds),
dispatch_get_main_queue(), ^{ dispatch_get_main_queue(), ^{
_isProcessingVoiceSearchCommand = NO; self.isProcessingVoiceSearchCommand = NO;
}); });
} }
} }
...@@ -2633,7 +2614,7 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -2633,7 +2614,7 @@ enum class EnterTabSwitcherSnapshotResult {
payments::IOSPaymentInstrumentLauncher* paymentAppLauncher = payments::IOSPaymentInstrumentLauncher* paymentAppLauncher =
payments::IOSPaymentInstrumentLauncherFactory::GetInstance() payments::IOSPaymentInstrumentLauncherFactory::GetInstance()
->GetForBrowserState(_mainBrowserState); ->GetForBrowserState(self.mainBrowserState);
if (!paymentAppLauncher->delegate()) if (!paymentAppLauncher->delegate())
return NO; return NO;
...@@ -2710,6 +2691,12 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -2710,6 +2691,12 @@ enum class EnterTabSwitcherSnapshotResult {
return username.empty() ? nil : base::SysUTF8ToNSString(username); return username.empty() ? nil : base::SysUTF8ToNSString(username);
} }
#pragma mark - MainControllerGuts
- (id<TabSwitcher>)tabSwitcher {
return _tabSwitcher;
}
@end @end
#pragma mark - TestingOnly #pragma mark - TestingOnly
...@@ -2720,10 +2707,6 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -2720,10 +2707,6 @@ enum class EnterTabSwitcherSnapshotResult {
return [_browserViewWrangler deviceSharingManager]; return [_browserViewWrangler deviceSharingManager];
} }
- (id<TabSwitcher>)tabSwitcher {
return _tabSwitcher;
}
- (void)setTabSwitcher:(id<TabSwitcher>)switcher { - (void)setTabSwitcher:(id<TabSwitcher>)switcher {
_tabSwitcher = switcher; _tabSwitcher = switcher;
} }
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_APP_MAIN_CONTROLLER_GUTS_H_
#define IOS_CHROME_APP_MAIN_CONTROLLER_GUTS_H_
#import <UIKit/UIKit.h>
#import "ios/chrome/browser/ui/settings/settings_navigation_controller.h"
#import "ios/public/provider/chrome/browser/user_feedback/user_feedback_provider.h"
@class HistoryCoordinator;
@class SigninInteractionCoordinator;
@class TabGridCoordinator;
@protocol BrowserInterfaceProvider;
@protocol TabSwitcher;
class AppUrlLoadingService;
// TODO(crbug.com/1012697): Remove this protocol when SceneController is
// operational. Move the private internals back into MainController, and pass
// ownership of Scene-related objects to SceneController.
@protocol MainControllerGuts <SettingsNavigationControllerDelegate,
UserFeedbackDataSource>
// Coordinator for displaying history.
@property(nonatomic, strong) HistoryCoordinator* historyCoordinator;
@property(nonatomic, strong)
SettingsNavigationController* settingsNavigationController;
// The application level component for url loading. Is passed down to
// browser state level UrlLoadingService instances.
@property(nonatomic, assign) AppUrlLoadingService* appURLLoadingService;
// The tab switcher command and the voice search commands can be sent by views
// that reside in a different UIWindow leading to the fact that the exclusive
// touch property will be ineffective and a command for processing both
// commands may be sent in the same run of the runloop leading to
// inconsistencies. Those two boolean indicate if one of those commands have
// been processed in the last 200ms in order to only allow processing one at
// a time.
// TODO(crbug.com/560296): Provide a general solution for handling mutually
// exclusive chrome commands sent at nearly the same time.
@property(nonatomic, assign) BOOL isProcessingTabSwitcherCommand;
@property(nonatomic, assign) BOOL isProcessingVoiceSearchCommand;
// The SigninInteractionCoordinator to present Sign In UI. It is created the
// first time Sign In UI is needed to be presented and should not be destroyed
// while the UI is presented.
@property(nonatomic, strong)
SigninInteractionCoordinator* signinInteractionCoordinator;
- (BOOL)isTabSwitcherActive;
- (id<TabSwitcher>)tabSwitcher;
- (ios::ChromeBrowserState*)mainBrowserState;
- (ios::ChromeBrowserState*)currentBrowserState;
- (BrowserViewController*)currentBVC;
- (BrowserViewController*)mainBVC;
- (BrowserViewController*)otrBVC;
- (TabGridCoordinator*)mainCoordinator;
- (id<BrowserInterfaceProvider>)interfaceProvider;
- (void)startVoiceSearchInCurrentBVC;
- (void)dismissModalDialogsWithCompletion:(ProceduralBlock)completion
dismissOmnibox:(BOOL)dismissOmnibox;
- (void)closeSettingsAnimated:(BOOL)animated
completion:(ProceduralBlock)completion;
- (void)dismissModalsAndOpenSelectedTabInMode:
(ApplicationModeForTabOpening)targetMode
withUrlLoadParams:
(const UrlLoadParams&)urlLoadParams
dismissOmnibox:(BOOL)dismissOmnibox
completion:(ProceduralBlock)completion;
- (void)showTabSwitcher;
@end
#endif // IOS_CHROME_APP_MAIN_CONTROLLER_GUTS_H_
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