Commit 44aa3a7f authored by Peter Laurens's avatar Peter Laurens Committed by Commit Bot

Encapsulate dismissal cleanup within SettingsNavigationController

Bug: 782943
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: If5ebc06503448526b57f42ea6543b5373efe2c90
Reviewed-on: https://chromium-review.googlesource.com/826024Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Commit-Queue: Peter Laurens <peterlaurens@chromium.org>
Cr-Commit-Position: refs/heads/master@{#525372}
parent 003ab0a1
...@@ -2066,7 +2066,6 @@ const int kExternalFilesCleanupDelaySeconds = 60; ...@@ -2066,7 +2066,6 @@ const int kExternalFilesCleanupDelaySeconds = 60;
- (void)closeSettingsAnimated:(BOOL)animated - (void)closeSettingsAnimated:(BOOL)animated
completion:(ProceduralBlock)completion { completion:(ProceduralBlock)completion {
DCHECK(_settingsNavigationController); DCHECK(_settingsNavigationController);
[_settingsNavigationController settingsWillBeDismissed];
UIViewController* presentingViewController = UIViewController* presentingViewController =
[_settingsNavigationController presentingViewController]; [_settingsNavigationController presentingViewController];
DCHECK(presentingViewController); DCHECK(presentingViewController);
......
...@@ -92,7 +92,6 @@ const int64_t kAuthenticationFlowTimeoutSeconds = 10; ...@@ -92,7 +92,6 @@ const int64_t kAuthenticationFlowTimeoutSeconds = 10;
[_alertCoordinator executeCancelHandler]; [_alertCoordinator executeCancelHandler];
[_alertCoordinator stop]; [_alertCoordinator stop];
if (_navigationController) { if (_navigationController) {
[_navigationController settingsWillBeDismissed];
_navigationController = nil; _navigationController = nil;
[[_delegate presentingViewController] dismissViewControllerAnimated:NO [[_delegate presentingViewController] dismissViewControllerAnimated:NO
completion:nil]; completion:nil];
...@@ -409,7 +408,6 @@ const int64_t kAuthenticationFlowTimeoutSeconds = 10; ...@@ -409,7 +408,6 @@ const int64_t kAuthenticationFlowTimeoutSeconds = 10;
strongSelf->_navigationController = nil; strongSelf->_navigationController = nil;
[[strongSelf delegate] didChooseClearDataPolicy:shouldClearData]; [[strongSelf delegate] didChooseClearDataPolicy:shouldClearData];
}; };
[_navigationController settingsWillBeDismissed];
[[_delegate presentingViewController] dismissViewControllerAnimated:YES [[_delegate presentingViewController] dismissViewControllerAnimated:YES
completion:block]; completion:block];
} }
...@@ -427,7 +425,6 @@ const int64_t kAuthenticationFlowTimeoutSeconds = 10; ...@@ -427,7 +425,6 @@ const int64_t kAuthenticationFlowTimeoutSeconds = 10;
strongSelf->_navigationController = nil; strongSelf->_navigationController = nil;
[[strongSelf delegate] didChooseCancel]; [[strongSelf delegate] didChooseCancel];
}; };
[_navigationController settingsWillBeDismissed];
[[_delegate presentingViewController] dismissViewControllerAnimated:YES [[_delegate presentingViewController] dismissViewControllerAnimated:YES
completion:block]; completion:block];
} }
......
...@@ -41,7 +41,8 @@ class ChromeBrowserState; ...@@ -41,7 +41,8 @@ class ChromeBrowserState;
// Controller to modify user settings. // Controller to modify user settings.
@interface SettingsNavigationController @interface SettingsNavigationController
: UINavigationController<ApplicationSettingsCommands> : UINavigationController<ApplicationSettingsCommands,
SettingsControllerProtocol>
// Whether sync changes should be committed when the settings are being // Whether sync changes should be committed when the settings are being
// dismissed. Defaults to YES. // dismissed. Defaults to YES.
...@@ -138,10 +139,6 @@ initWithRootViewController:(UIViewController*)rootViewController ...@@ -138,10 +139,6 @@ initWithRootViewController:(UIViewController*)rootViewController
// Returns the current main browser state. // Returns the current main browser state.
- (ios::ChromeBrowserState*)mainBrowserState; - (ios::ChromeBrowserState*)mainBrowserState;
// Notifies this |SettingsNavigationController| that it will be dismissed such
// that it has a possibility to do necessary clean up.
- (void)settingsWillBeDismissed;
// Closes this |SettingsNavigationController| by asking its delegate. // Closes this |SettingsNavigationController| by asking its delegate.
- (void)closeSettings; - (void)closeSettings;
......
...@@ -312,6 +312,13 @@ initWithRootViewController:(UIViewController*)rootViewController ...@@ -312,6 +312,13 @@ initWithRootViewController:(UIViewController*)rootViewController
return self; return self;
} }
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
if (self.isBeingDismissed) {
[self settingsWillBeDismissed];
}
}
- (void)settingsWillBeDismissed { - (void)settingsWillBeDismissed {
// Notify all controllers that settings are about to be dismissed. // Notify all controllers that settings are about to be dismissed.
for (UIViewController* controller in [self viewControllers]) { for (UIViewController* controller in [self viewControllers]) {
......
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