Commit f663b438 authored by Stepan Khapugin's avatar Stepan Khapugin Committed by Commit Bot

[iOS][multiball] Clean up MainControllerGuts

Moves a bunch of methdos and properties that aren't used in
MainController to SceneController and updates call sites.

Bug: none
Change-Id: Ib5b26f5cd402cb435426f23f060c53dac522104a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2012382
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Auto-Submit: Stepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#734533}
parent 02d5da92
......@@ -130,7 +130,6 @@
#include "ios/chrome/browser/ui/tab_grid/tab_grid_coordinator.h"
#import "ios/chrome/browser/ui/tab_grid/tab_switcher.h"
#import "ios/chrome/browser/ui/tab_grid/view_controller_swapping.h"
#import "ios/chrome/browser/ui/toolbar/public/omnibox_focuser.h"
#import "ios/chrome/browser/ui/ui_feature_flags.h"
#include "ios/chrome/browser/ui/util/ui_util.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h"
......@@ -348,8 +347,6 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
// browser has started up to the FOREGROUND stage.
@property(nonatomic, readonly) TabGridCoordinator* mainCoordinator;
// Starts a voice search on the current BVC.
- (void)startVoiceSearchInCurrentBVC;
// Returns whether the restore infobar should be displayed.
- (bool)mustShowRestoreInfobar;
// Switch all global states for the given mode (normal or incognito).
......@@ -430,10 +427,7 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
@implementation MainController
// Defined by MainControllerGuts.
@synthesize historyCoordinator;
@synthesize appURLLoadingService;
@synthesize isProcessingTabSwitcherCommand;
@synthesize isProcessingVoiceSearchCommand;
@synthesize dismissingTabSwitcher = _dismissingTabSwitcher;
@synthesize restoreHelper = _restoreHelper;
......@@ -448,11 +442,7 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
@synthesize appLaunchTime = _appLaunchTime;
// Defined in private interface
@synthesize mainCoordinator = _mainCoordinator;
@synthesize NTPActionAfterTabSwitcherDismissal =
_NTPActionAfterTabSwitcherDismissal;
@synthesize tabSwitcherIsActive;
@synthesize modeToDisplayOnTabSwitcherDismissal =
_modeToDisplayOnTabSwitcherDismissal;
#pragma mark - Application lifecycle
......@@ -815,9 +805,6 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
_extensionSearchEngineDataUpdater = nullptr;
[self.historyCoordinator stop];
self.historyCoordinator = nil;
ios::GetChromeBrowserProvider()
->GetMailtoHandlerProvider()
->RemoveMailtoHandling();
......@@ -1426,20 +1413,6 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
[self switchGlobalStateToMode:mode];
}
- (void)displayCurrentBVCAndFocusOmnibox:(BOOL)focusOmnibox {
ProceduralBlock completion = nil;
if (focusOmnibox) {
__weak BrowserViewController* weakCurrentBVC = self.currentBVC;
completion = ^{
[weakCurrentBVC.dispatcher focusOmnibox];
};
}
[self.mainCoordinator showTabViewController:self.currentBVC
completion:completion];
[self.currentBVC.dispatcher
setIncognitoContentVisible:(self.currentBVC == self.otrBVC)];
}
- (TabModel*)currentTabModel {
return self.currentBVC.tabModel;
}
......@@ -1452,29 +1425,6 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
return self.currentBVC.browserState;
}
#pragma mark - Tab opening utility methods.
- (ProceduralBlock)completionBlockForTriggeringAction:
(NTPTabOpeningPostOpeningAction)action {
switch (action) {
case START_VOICE_SEARCH:
return ^{
[self startVoiceSearchInCurrentBVC];
};
case START_QR_CODE_SCANNER:
return ^{
[self.currentBVC.dispatcher showQRScanner];
};
case FOCUS_OMNIBOX:
return ^{
[self.currentBVC.dispatcher focusOmnibox];
};
default:
return nil;
}
}
- (bool)mustShowRestoreInfobar {
if ([self isFirstLaunchAfterUpgrade])
return false;
......@@ -1513,18 +1463,6 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
}
#pragma mark - ApplicationCommands helpers
- (void)startVoiceSearchInCurrentBVC {
// If the background (non-current) BVC is playing TTS audio, call
// -startVoiceSearch on it to stop the TTS.
BrowserViewController* backgroundBVC =
self.mainBVC == self.currentBVC ? self.otrBVC : self.mainBVC;
if (backgroundBVC.playingTTS)
[backgroundBVC startVoiceSearch];
else
[self.currentBVC startVoiceSearch];
}
#pragma mark - SceneController plumbing
......
......@@ -13,46 +13,23 @@
#include "ios/chrome/browser/browser_state/chrome_browser_state_forward.h"
#include "ios/chrome/browser/browsing_data/browsing_data_remove_mask.h"
#import "ios/chrome/browser/crash_report/crash_restore_helper.h"
#import "ios/chrome/browser/ui/settings/settings_navigation_controller.h"
#import "ios/public/provider/chrome/browser/user_feedback/user_feedback_provider.h"
@class BrowserViewController;
@class BrowserViewWrangler;
@class HistoryCoordinator;
@class TabGridCoordinator;
@protocol BrowserInterfaceProvider;
@protocol TabSwitcher;
class AppUrlLoadingService;
// Used to update the current BVC mode if a new tab is added while the tab
// switcher view is being dismissed. This is different than ApplicationMode in
// that it can be set to |NONE| when not in use.
enum class TabSwitcherDismissalMode { NONE, NORMAL, INCOGNITO };
// 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
// Coordinator for displaying history.
@property(nonatomic, strong) HistoryCoordinator* historyCoordinator;
// 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;
// If YES, the tab switcher is currently active.
@property(nonatomic, assign, getter=isTabSwitcherActive)
BOOL tabSwitcherIsActive;
......@@ -60,24 +37,10 @@ enum class TabSwitcherDismissalMode { NONE, NORMAL, INCOGNITO };
// YES while animating the dismissal of tab switcher.
@property(nonatomic, assign) BOOL dismissingTabSwitcher;
// If not NONE, the current BVC should be switched to this BVC on completion
// of tab switcher dismissal.
@property(nonatomic, assign)
TabSwitcherDismissalMode modeToDisplayOnTabSwitcherDismissal;
// A property to track whether the QR Scanner should be started upon tab
// switcher dismissal. It can only be YES if the QR Scanner experiment is
// enabled.
@property(nonatomic, readwrite)
NTPTabOpeningPostOpeningAction NTPActionAfterTabSwitcherDismissal;
// Parameters received at startup time when the app is launched from another
// app.
@property(nonatomic, strong) AppStartupParameters* startupParameters;
- (ProceduralBlock)completionBlockForTriggeringAction:
(NTPTabOpeningPostOpeningAction)action;
// Keeps track of the restore state during startup.
@property(nonatomic, strong) CrashRestoreHelper* restoreHelper;
......@@ -91,10 +54,6 @@ enum class TabSwitcherDismissalMode { NONE, NORMAL, INCOGNITO };
- (BrowserViewController*)otrBVC;
- (TabGridCoordinator*)mainCoordinator;
- (id<BrowserInterfaceProvider>)interfaceProvider;
- (void)startVoiceSearchInCurrentBVC;
// Sets |currentBVC| as the root view controller for the window.
- (void)displayCurrentBVCAndFocusOmnibox:(BOOL)focusOmnibox;
- (void)removeBrowsingDataForBrowserState:(ios::ChromeBrowserState*)browserState
timePeriod:(browsing_data::TimePeriod)timePeriod
......
......@@ -59,6 +59,7 @@ source_set("scene") {
"//ios/chrome/browser/ui/settings:settings_root",
"//ios/chrome/browser/ui/signin_interaction",
"//ios/chrome/browser/ui/tab_grid",
"//ios/chrome/browser/ui/toolbar/public",
"//ios/chrome/browser/ui/util",
"//ios/chrome/browser/ui/util:multiwindow_util",
"//ios/chrome/browser/url_loading",
......
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