Commit 0a9b6224 authored by Stepan Khapugin's avatar Stepan Khapugin Committed by Commit Bot

[iOS][multiball] Move AppNavigation to SceneController.

Moves AppNavigation protocol implementation to SceneController.

Bug: none
Change-Id: I41732781203fae618ce5b5651a1f3be47576a816
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2002521Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732858}
parent 9b365a74
...@@ -19,7 +19,7 @@ class ChromeBrowserState; ...@@ -19,7 +19,7 @@ class ChromeBrowserState;
@protocol AppNavigation<NSObject> @protocol AppNavigation<NSObject>
// Navigation View controller for the settings. // Navigation View controller for the settings.
@property(nonatomic, retain) @property(nonatomic, strong)
SettingsNavigationController* settingsNavigationController; SettingsNavigationController* settingsNavigationController;
// Presents a SignedInAccountsViewController for |browserState| on the top view // Presents a SignedInAccountsViewController for |browserState| on the top view
......
...@@ -74,7 +74,6 @@ ...@@ -74,7 +74,6 @@
_appState = [[AppState alloc] initWithBrowserLauncher:_browserLauncher _appState = [[AppState alloc] initWithBrowserLauncher:_browserLauncher
startupInformation:_startupInformation startupInformation:_startupInformation
applicationDelegate:self]; applicationDelegate:self];
_appNavigation = _mainController;
[_mainController setAppState:_appState]; [_mainController setAppState:_appState];
if (!IsMultiwindowSupported()) { if (!IsMultiwindowSupported()) {
...@@ -91,6 +90,7 @@ ...@@ -91,6 +90,7 @@
_mainController.sceneController = _sceneController; _mainController.sceneController = _sceneController;
_tabSwitcherProtocol = _sceneController; _tabSwitcherProtocol = _sceneController;
_tabOpener = _sceneController; _tabOpener = _sceneController;
_appNavigation = _sceneController;
} }
} }
return self; return self;
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "ios/chrome/app/application_delegate/app_navigation.h"
#import "ios/chrome/app/application_delegate/browser_launcher.h" #import "ios/chrome/app/application_delegate/browser_launcher.h"
#import "ios/chrome/app/application_delegate/startup_information.h" #import "ios/chrome/app/application_delegate/startup_information.h"
#import "ios/chrome/app/main_controller_guts.h" #import "ios/chrome/app/main_controller_guts.h"
...@@ -28,8 +27,7 @@ ...@@ -28,8 +27,7 @@
// //
// 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 <AppNavigation, @interface MainController : NSObject <BrowserLauncher,
BrowserLauncher,
MainControllerGuts, MainControllerGuts,
StartupInformation, StartupInformation,
BrowsingDataCommands> BrowsingDataCommands>
......
...@@ -129,7 +129,6 @@ ...@@ -129,7 +129,6 @@
#import "ios/chrome/browser/ui/tab_grid/view_controller_swapping.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/toolbar/public/omnibox_focuser.h"
#import "ios/chrome/browser/ui/ui_feature_flags.h" #import "ios/chrome/browser/ui/ui_feature_flags.h"
#import "ios/chrome/browser/ui/util/top_view_controller.h"
#include "ios/chrome/browser/ui/util/ui_util.h" #include "ios/chrome/browser/ui/util/ui_util.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h" #import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/browser/ui/webui/chrome_web_ui_ios_controller_factory.h" #import "ios/chrome/browser/ui/webui/chrome_web_ui_ios_controller_factory.h"
...@@ -441,7 +440,6 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData( ...@@ -441,7 +440,6 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
@implementation MainController @implementation MainController
// Defined by MainControllerGuts. // Defined by MainControllerGuts.
@synthesize historyCoordinator; @synthesize historyCoordinator;
@synthesize settingsNavigationController;
@synthesize appURLLoadingService; @synthesize appURLLoadingService;
@synthesize isProcessingTabSwitcherCommand; @synthesize isProcessingTabSwitcherCommand;
@synthesize isProcessingVoiceSearchCommand; @synthesize isProcessingVoiceSearchCommand;
...@@ -819,7 +817,7 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData( ...@@ -819,7 +817,7 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
} }
- (BOOL)isSettingsViewPresented { - (BOOL)isSettingsViewPresented {
return self.settingsNavigationController || return [self.sceneController hasSettingsNavigationController] ||
self.signinInteractionCoordinator.isSettingsViewPresented; self.signinInteractionCoordinator.isSettingsViewPresented;
} }
...@@ -999,7 +997,7 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData( ...@@ -999,7 +997,7 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
if ([SignedInAccountsViewController if ([SignedInAccountsViewController
shouldBePresentedForBrowserState: shouldBePresentedForBrowserState:
[self currentBrowserState]]) { [self currentBrowserState]]) {
[self [self.sceneController
presentSignedInAccountsViewControllerForBrowserState: presentSignedInAccountsViewControllerForBrowserState:
[self currentBrowserState]]; [self currentBrowserState]];
} }
...@@ -1557,25 +1555,6 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData( ...@@ -1557,25 +1555,6 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
[self.mainCoordinator showTabSwitcher:_tabSwitcher]; [self.mainCoordinator showTabSwitcher:_tabSwitcher];
} }
#pragma mark - App Navigation
- (void)presentSignedInAccountsViewControllerForBrowserState:
(ios::ChromeBrowserState*)browserState {
UIViewController* accountsViewController =
[[SignedInAccountsViewController alloc]
initWithBrowserState:browserState
dispatcher:self.mainBVC.dispatcher];
[[self topPresentedViewController]
presentViewController:accountsViewController
animated:YES
completion:nil];
}
- (void)closeSettingsAnimated:(BOOL)animated
completion:(ProceduralBlock)completion {
[self.sceneController closeSettingsAnimated:animated completion:completion];
}
#pragma mark - WebStateListObserving #pragma mark - WebStateListObserving
// Called when a WebState is removed. Triggers the switcher view when the last // Called when a WebState is removed. Triggers the switcher view when the last
...@@ -1763,13 +1742,6 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData( ...@@ -1763,13 +1742,6 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
_tabSwitcher = switcher; _tabSwitcher = switcher;
} }
- (UIViewController*)topPresentedViewController {
// TODO(crbug.com/754642): Implement TopPresentedViewControllerFrom()
// privately.
return top_view_controller::TopPresentedViewControllerFrom(
self.mainCoordinator.viewController);
}
- (void)setTabSwitcherActive:(BOOL)active { - (void)setTabSwitcherActive:(BOOL)active {
self.tabSwitcherIsActive = active; self.tabSwitcherIsActive = active;
} }
......
...@@ -36,8 +36,6 @@ enum class TabSwitcherDismissalMode { NONE, NORMAL, INCOGNITO }; ...@@ -36,8 +36,6 @@ enum class TabSwitcherDismissalMode { NONE, NORMAL, INCOGNITO };
// Coordinator for displaying history. // Coordinator for displaying history.
@property(nonatomic, strong) HistoryCoordinator* historyCoordinator; @property(nonatomic, strong) HistoryCoordinator* historyCoordinator;
@property(nonatomic, strong)
SettingsNavigationController* settingsNavigationController;
// The application level component for url loading. Is passed down to // The application level component for url loading. Is passed down to
// browser state level UrlLoadingService instances. // browser state level UrlLoadingService instances.
......
...@@ -32,9 +32,6 @@ class GURL; ...@@ -32,9 +32,6 @@ class GURL;
@property(nonatomic, readonly) DeviceSharingManager* deviceSharingManager; @property(nonatomic, readonly) DeviceSharingManager* deviceSharingManager;
@property(nonatomic, retain) id<TabSwitcher> tabSwitcher; @property(nonatomic, retain) id<TabSwitcher> tabSwitcher;
// The top presented view controller that is not currently being dismissed.
@property(nonatomic, readonly) UIViewController* topPresentedViewController;
// Tab switcher state. // Tab switcher state.
@property(nonatomic, getter=isTabSwitcherActive) BOOL tabSwitcherActive; @property(nonatomic, getter=isTabSwitcherActive) BOOL tabSwitcherActive;
......
...@@ -46,6 +46,7 @@ source_set("scene") { ...@@ -46,6 +46,7 @@ source_set("scene") {
"//ios/chrome/browser/signin", "//ios/chrome/browser/signin",
"//ios/chrome/browser/snapshots", "//ios/chrome/browser/snapshots",
"//ios/chrome/browser/tabs:tabs", "//ios/chrome/browser/tabs:tabs",
"//ios/chrome/browser/ui/authentication",
"//ios/chrome/browser/ui/browser_view", "//ios/chrome/browser/ui/browser_view",
"//ios/chrome/browser/ui/commands:commands", "//ios/chrome/browser/ui/commands:commands",
"//ios/chrome/browser/ui/history", "//ios/chrome/browser/ui/history",
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "ios/chrome/app/application_delegate/app_navigation.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/browser/ui/commands/application_commands.h" #import "ios/chrome/browser/ui/commands/application_commands.h"
...@@ -18,7 +19,8 @@ ...@@ -18,7 +19,8 @@
@protocol MainControllerGuts; @protocol MainControllerGuts;
// The controller object for a scene. Reacts to scene state changes. // The controller object for a scene. Reacts to scene state changes.
@interface SceneController : NSObject <AppURLLoadingServiceDelegate, @interface SceneController : NSObject <AppNavigation,
AppURLLoadingServiceDelegate,
SceneStateObserver, SceneStateObserver,
ApplicationCommands, ApplicationCommands,
TabSwitcherDelegate, TabSwitcherDelegate,
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "ios/chrome/browser/signin/identity_manager_factory.h" #include "ios/chrome/browser/signin/identity_manager_factory.h"
#import "ios/chrome/browser/snapshots/snapshot_tab_helper.h" #import "ios/chrome/browser/snapshots/snapshot_tab_helper.h"
#import "ios/chrome/browser/tabs/tab_model.h" #import "ios/chrome/browser/tabs/tab_model.h"
#import "ios/chrome/browser/ui/authentication/signed_in_accounts_view_controller.h"
#import "ios/chrome/browser/ui/browser_view/browser_view_controller.h" #import "ios/chrome/browser/ui/browser_view/browser_view_controller.h"
#import "ios/chrome/browser/ui/commands/browser_commands.h" #import "ios/chrome/browser/ui/commands/browser_commands.h"
#import "ios/chrome/browser/ui/commands/command_dispatcher.h" #import "ios/chrome/browser/ui/commands/command_dispatcher.h"
...@@ -42,6 +43,7 @@ ...@@ -42,6 +43,7 @@
#import "ios/chrome/browser/ui/signin_interaction/signin_interaction_coordinator.h" #import "ios/chrome/browser/ui/signin_interaction/signin_interaction_coordinator.h"
#include "ios/chrome/browser/ui/tab_grid/tab_grid_coordinator.h" #include "ios/chrome/browser/ui/tab_grid/tab_grid_coordinator.h"
#import "ios/chrome/browser/ui/util/multi_window_support.h" #import "ios/chrome/browser/ui/util/multi_window_support.h"
#import "ios/chrome/browser/ui/util/top_view_controller.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h" #import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/browser/url_loading/app_url_loading_service.h" #import "ios/chrome/browser/url_loading/app_url_loading_service.h"
#import "ios/chrome/browser/url_loading/url_loading_params.h" #import "ios/chrome/browser/url_loading/url_loading_params.h"
...@@ -96,6 +98,7 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -96,6 +98,7 @@ enum class EnterTabSwitcherSnapshotResult {
@end @end
@implementation SceneController @implementation SceneController
@synthesize settingsNavigationController; //< From AppNavigation protocol.
- (instancetype)initWithSceneState:(SceneState*)sceneState { - (instancetype)initWithSceneState:(SceneState*)sceneState {
self = [super init]; self = [super init];
...@@ -147,6 +150,12 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -147,6 +150,12 @@ enum class EnterTabSwitcherSnapshotResult {
self.hasInitializedUI = YES; self.hasInitializedUI = YES;
} }
#pragma mark - Guts
- (BOOL)hasSettingsNavigationController {
return self.settingsNavigationController != nil;
}
#pragma mark - ApplicationCommands #pragma mark - ApplicationCommands
- (void)dismissModalDialogs { - (void)dismissModalDialogs {
...@@ -223,15 +232,14 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -223,15 +232,14 @@ enum class EnterTabSwitcherSnapshotResult {
(UIViewController*)baseViewController { (UIViewController*)baseViewController {
DCHECK(!self.mainController.signinInteractionCoordinator DCHECK(!self.mainController.signinInteractionCoordinator
.isSettingsViewPresented); .isSettingsViewPresented);
if (self.mainController.settingsNavigationController) if (self.settingsNavigationController)
return; return;
Browser* browser = self.mainInterface.browser; Browser* browser = self.mainInterface.browser;
self.mainController.settingsNavigationController = self.settingsNavigationController =
[SettingsNavigationController autofillProfileControllerForBrowser:browser [SettingsNavigationController autofillProfileControllerForBrowser:browser
delegate:self]; delegate:self];
[baseViewController [baseViewController presentViewController:self.settingsNavigationController
presentViewController:self.mainController.settingsNavigationController
animated:YES animated:YES
completion:nil]; completion:nil];
} }
...@@ -244,16 +252,15 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -244,16 +252,15 @@ enum class EnterTabSwitcherSnapshotResult {
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
DCHECK(!self.mainController.signinInteractionCoordinator DCHECK(!self.mainController.signinInteractionCoordinator
.isSettingsViewPresented); .isSettingsViewPresented);
if (self.mainController.settingsNavigationController) if (self.settingsNavigationController)
return; return;
Browser* browser = self.mainInterface.browser; Browser* browser = self.mainInterface.browser;
self.mainController.settingsNavigationController = self.settingsNavigationController =
[SettingsNavigationController userFeedbackControllerForBrowser:browser [SettingsNavigationController userFeedbackControllerForBrowser:browser
delegate:self delegate:self
feedbackDataSource:self feedbackDataSource:self
dispatcher:self]; dispatcher:self];
[baseViewController [baseViewController presentViewController:self.settingsNavigationController
presentViewController:self.mainController.settingsNavigationController
animated:YES animated:YES
completion:nil]; completion:nil];
}); });
...@@ -353,18 +360,17 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -353,18 +360,17 @@ enum class EnterTabSwitcherSnapshotResult {
- (void)showSettingsFromViewController:(UIViewController*)baseViewController { - (void)showSettingsFromViewController:(UIViewController*)baseViewController {
DCHECK(!self.mainController.signinInteractionCoordinator DCHECK(!self.mainController.signinInteractionCoordinator
.isSettingsViewPresented); .isSettingsViewPresented);
if (self.mainController.settingsNavigationController) if (self.settingsNavigationController)
return; return;
[[DeferredInitializationRunner sharedInstance] [[DeferredInitializationRunner sharedInstance]
runBlockIfNecessary:kPrefObserverInit]; runBlockIfNecessary:kPrefObserverInit];
Browser* browser = self.mainInterface.browser; Browser* browser = self.mainInterface.browser;
self.mainController.settingsNavigationController = self.settingsNavigationController =
[SettingsNavigationController mainSettingsControllerForBrowser:browser [SettingsNavigationController mainSettingsControllerForBrowser:browser
delegate:self]; delegate:self];
[baseViewController [baseViewController presentViewController:self.settingsNavigationController
presentViewController:self.mainController.settingsNavigationController
animated:YES animated:YES
completion:nil]; completion:nil];
} }
...@@ -386,18 +392,17 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -386,18 +392,17 @@ enum class EnterTabSwitcherSnapshotResult {
NOTREACHED(); NOTREACHED();
return; return;
} }
if (self.mainController.settingsNavigationController) { if (self.settingsNavigationController) {
[self.mainController.settingsNavigationController [self.settingsNavigationController
showAccountsSettingsFromViewController:baseViewController]; showAccountsSettingsFromViewController:baseViewController];
return; return;
} }
Browser* browser = self.mainInterface.browser; Browser* browser = self.mainInterface.browser;
self.mainController.settingsNavigationController = self.settingsNavigationController =
[SettingsNavigationController accountsControllerForBrowser:browser [SettingsNavigationController accountsControllerForBrowser:browser
delegate:self]; delegate:self];
[baseViewController [baseViewController presentViewController:self.settingsNavigationController
presentViewController:self.mainController.settingsNavigationController
animated:YES animated:YES
completion:nil]; completion:nil];
} }
...@@ -413,21 +418,20 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -413,21 +418,20 @@ enum class EnterTabSwitcherSnapshotResult {
baseViewController = self.mainController.currentBVC; baseViewController = self.mainController.currentBVC;
} }
if (self.mainController.settingsNavigationController) { if (self.settingsNavigationController) {
// Navigate to the Google services settings if the settings dialog is // Navigate to the Google services settings if the settings dialog is
// already opened. // already opened.
[self.mainController.settingsNavigationController [self.settingsNavigationController
showGoogleServicesSettingsFromViewController:baseViewController]; showGoogleServicesSettingsFromViewController:baseViewController];
return; return;
} }
Browser* browser = self.mainInterface.browser; Browser* browser = self.mainInterface.browser;
self.mainController.settingsNavigationController = self.settingsNavigationController =
[SettingsNavigationController googleServicesControllerForBrowser:browser [SettingsNavigationController googleServicesControllerForBrowser:browser
delegate:self]; delegate:self];
[baseViewController [baseViewController presentViewController:self.settingsNavigationController
presentViewController:self.mainController.settingsNavigationController
animated:YES animated:YES
completion:nil]; completion:nil];
} }
...@@ -437,18 +441,17 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -437,18 +441,17 @@ enum class EnterTabSwitcherSnapshotResult {
(UIViewController*)baseViewController { (UIViewController*)baseViewController {
DCHECK(!self.mainController.signinInteractionCoordinator DCHECK(!self.mainController.signinInteractionCoordinator
.isSettingsViewPresented); .isSettingsViewPresented);
if (self.mainController.settingsNavigationController) { if (self.settingsNavigationController) {
[self.mainController.settingsNavigationController [self.settingsNavigationController
showSyncPassphraseSettingsFromViewController:baseViewController]; showSyncPassphraseSettingsFromViewController:baseViewController];
return; return;
} }
Browser* browser = self.mainInterface.browser; Browser* browser = self.mainInterface.browser;
self.mainController.settingsNavigationController = self.settingsNavigationController =
[SettingsNavigationController syncPassphraseControllerForBrowser:browser [SettingsNavigationController syncPassphraseControllerForBrowser:browser
delegate:self]; delegate:self];
[baseViewController [baseViewController presentViewController:self.settingsNavigationController
presentViewController:self.mainController.settingsNavigationController
animated:YES animated:YES
completion:nil]; completion:nil];
} }
...@@ -458,17 +461,16 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -458,17 +461,16 @@ enum class EnterTabSwitcherSnapshotResult {
(UIViewController*)baseViewController { (UIViewController*)baseViewController {
DCHECK(!self.mainController.signinInteractionCoordinator DCHECK(!self.mainController.signinInteractionCoordinator
.isSettingsViewPresented); .isSettingsViewPresented);
if (self.mainController.settingsNavigationController) { if (self.settingsNavigationController) {
[self.mainController.settingsNavigationController [self.settingsNavigationController
showSavedPasswordsSettingsFromViewController:baseViewController]; showSavedPasswordsSettingsFromViewController:baseViewController];
return; return;
} }
Browser* browser = self.mainInterface.browser; Browser* browser = self.mainInterface.browser;
self.mainController.settingsNavigationController = self.settingsNavigationController =
[SettingsNavigationController savePasswordsControllerForBrowser:browser [SettingsNavigationController savePasswordsControllerForBrowser:browser
delegate:self]; delegate:self];
[baseViewController [baseViewController presentViewController:self.settingsNavigationController
presentViewController:self.mainController.settingsNavigationController
animated:YES animated:YES
completion:nil]; completion:nil];
} }
...@@ -478,18 +480,17 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -478,18 +480,17 @@ enum class EnterTabSwitcherSnapshotResult {
(UIViewController*)baseViewController { (UIViewController*)baseViewController {
DCHECK(!self.mainController.signinInteractionCoordinator DCHECK(!self.mainController.signinInteractionCoordinator
.isSettingsViewPresented); .isSettingsViewPresented);
if (self.mainController.settingsNavigationController) { if (self.settingsNavigationController) {
[self.mainController.settingsNavigationController [self.settingsNavigationController
showProfileSettingsFromViewController:baseViewController]; showProfileSettingsFromViewController:baseViewController];
return; return;
} }
Browser* browser = self.mainInterface.browser; Browser* browser = self.mainInterface.browser;
self.mainController.settingsNavigationController = self.settingsNavigationController =
[SettingsNavigationController autofillProfileControllerForBrowser:browser [SettingsNavigationController autofillProfileControllerForBrowser:browser
delegate:self]; delegate:self];
[baseViewController [baseViewController presentViewController:self.settingsNavigationController
presentViewController:self.mainController.settingsNavigationController
animated:YES animated:YES
completion:nil]; completion:nil];
} }
...@@ -499,19 +500,17 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -499,19 +500,17 @@ enum class EnterTabSwitcherSnapshotResult {
(UIViewController*)baseViewController { (UIViewController*)baseViewController {
DCHECK(!self.mainController.signinInteractionCoordinator DCHECK(!self.mainController.signinInteractionCoordinator
.isSettingsViewPresented); .isSettingsViewPresented);
if (self.mainController.settingsNavigationController) { if (self.settingsNavigationController) {
[self.mainController.settingsNavigationController [self.settingsNavigationController
showCreditCardSettingsFromViewController:baseViewController]; showCreditCardSettingsFromViewController:baseViewController];
return; return;
} }
Browser* browser = self.mainInterface.browser; Browser* browser = self.mainInterface.browser;
self.mainController.settingsNavigationController = self.settingsNavigationController = [SettingsNavigationController
[SettingsNavigationController
autofillCreditCardControllerForBrowser:browser autofillCreditCardControllerForBrowser:browser
delegate:self]; delegate:self];
[baseViewController [baseViewController presentViewController:self.settingsNavigationController
presentViewController:self.mainController.settingsNavigationController
animated:YES animated:YES
completion:nil]; completion:nil];
} }
...@@ -581,8 +580,8 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -581,8 +580,8 @@ enum class EnterTabSwitcherSnapshotResult {
} }
- (void)settingsWasDismissed { - (void)settingsWasDismissed {
[self.mainController.settingsNavigationController cleanUpSettings]; [self.settingsNavigationController cleanUpSettings];
self.mainController.settingsNavigationController = nil; self.settingsNavigationController = nil;
} }
- (id<ApplicationCommands, BrowserCommands>)dispatcherForSettings { - (id<ApplicationCommands, BrowserCommands>)dispatcherForSettings {
...@@ -1045,37 +1044,6 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -1045,37 +1044,6 @@ enum class EnterTabSwitcherSnapshotResult {
} }
} }
- (void)closeSettingsAnimated:(BOOL)animated
completion:(ProceduralBlock)completion {
if (self.mainController.settingsNavigationController) {
[self.mainController.settingsNavigationController cleanUpSettings];
UIViewController* presentingViewController =
[self.mainController
.settingsNavigationController presentingViewController];
// If presentingViewController is nil it means the VC was already dismissed
// by some other action like swiping down.
DCHECK(presentingViewController);
[presentingViewController dismissViewControllerAnimated:animated
completion:completion];
self.mainController.settingsNavigationController = nil;
return;
}
// |self.signinInteractionCoordinator| can also present settings, like
// the advanced sign-in settings navigation controller. If the settings has
// to be cloase, it is thus the responsibility of the main controller to
// dismiss the the advanced sign-in settings by dismssing the settings
// presented by |self.signinInteractionCoordinator|.
// To reproduce this case:
// - open Bookmark view
// - start sign-in
// - tap on "Settings" to open the advanced sign-in settings
// - tap on "Manage Your Google Account"
DCHECK(
self.mainController.signinInteractionCoordinator.isSettingsViewPresented);
[self.mainController.signinInteractionCoordinator
abortAndDismissSettingsViewAnimated:animated
completion:completion];
}
// Checks the target BVC's current tab's URL. If this URL is chrome://newtab, // Checks the target BVC's current tab's URL. If this URL is chrome://newtab,
// loads |urlLoadParams| in this tab. Otherwise, open |urlLoadParams| in a new // loads |urlLoadParams| in this tab. Otherwise, open |urlLoadParams| in a new
...@@ -1131,4 +1099,56 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -1131,4 +1099,56 @@ enum class EnterTabSwitcherSnapshotResult {
} }
} }
#pragma mark - AppNavigation
- (void)presentSignedInAccountsViewControllerForBrowserState:
(ios::ChromeBrowserState*)browserState {
UIViewController* accountsViewController =
[[SignedInAccountsViewController alloc]
initWithBrowserState:browserState
dispatcher:self.mainController.mainBVC.dispatcher];
[[self topPresentedViewController]
presentViewController:accountsViewController
animated:YES
completion:nil];
}
- (void)closeSettingsAnimated:(BOOL)animated
completion:(ProceduralBlock)completion {
if (self.settingsNavigationController) {
[self.settingsNavigationController cleanUpSettings];
UIViewController* presentingViewController =
[self.settingsNavigationController presentingViewController];
// If presentingViewController is nil it means the VC was already dismissed
// by some other action like swiping down.
DCHECK(presentingViewController);
[presentingViewController dismissViewControllerAnimated:animated
completion:completion];
self.settingsNavigationController = nil;
return;
}
// |self.signinInteractionCoordinator| can also present settings, like
// the advanced sign-in settings navigation controller. If the settings has
// to be cloase, it is thus the responsibility of the main controller to
// dismiss the the advanced sign-in settings by dismssing the settings
// presented by |self.signinInteractionCoordinator|.
// To reproduce this case:
// - open Bookmark view
// - start sign-in
// - tap on "Settings" to open the advanced sign-in settings
// - tap on "Manage Your Google Account"
DCHECK(
self.mainController.signinInteractionCoordinator.isSettingsViewPresented);
[self.mainController.signinInteractionCoordinator
abortAndDismissSettingsViewAnimated:animated
completion:completion];
}
- (UIViewController*)topPresentedViewController {
// TODO(crbug.com/754642): Implement TopPresentedViewControllerFrom()
// privately.
return top_view_controller::TopPresentedViewControllerFrom(
self.mainController.mainCoordinator.viewController);
}
@end @end
...@@ -14,10 +14,11 @@ ...@@ -14,10 +14,11 @@
@class TabModel; @class TabModel;
@protocol SceneControllerGuts namespace ios {
class ChromeBrowserState;
} // namespace ios
- (void)closeSettingsAnimated:(BOOL)animated @protocol SceneControllerGuts
completion:(ProceduralBlock)completion;
- (void)dismissModalDialogsWithCompletion:(ProceduralBlock)completion - (void)dismissModalDialogsWithCompletion:(ProceduralBlock)completion
dismissOmnibox:(BOOL)dismissOmnibox; dismissOmnibox:(BOOL)dismissOmnibox;
...@@ -51,6 +52,16 @@ ...@@ -51,6 +52,16 @@
// screen and showing the appropriate BVC. // screen and showing the appropriate BVC.
- (void)finishDismissingTabSwitcher; - (void)finishDismissingTabSwitcher;
#pragma mark - AppNavigation helpers
// Presents a SignedInAccountsViewController for |browserState| on the top view
// controller.
- (void)presentSignedInAccountsViewControllerForBrowserState:
(ios::ChromeBrowserState*)browserState;
// Returns YES if the settings navigation controller exists.
- (BOOL)hasSettingsNavigationController;
@end @end
#endif // IOS_CHROME_BROWSER_UI_MAIN_SCENE_CONTROLLER_GUTS_H_ #endif // IOS_CHROME_BROWSER_UI_MAIN_SCENE_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