Commit c9a4b056 authored by edchin's avatar edchin Committed by Commit Bot

[ios] Remove -topPresentedViewController from signin_interaction

-topPresentedViewController was used to present signin_interaction
above identity_interaction. Instead of doing the "VC walk", we
now keep track of the top view controller whenever identity_interaction
calls its delegate method to present a view controller.

Bug: 754642
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Idc9281c76953307741253bdf515f7fd7ed9d8b35
Reviewed-on: https://chromium-review.googlesource.com/760237
Commit-Queue: edchin <edchin@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Reviewed-by: default avatarJérôme Lebel <jlebel@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#516395}
parent 14011246
...@@ -21,7 +21,6 @@ source_set("signin_interaction") { ...@@ -21,7 +21,6 @@ source_set("signin_interaction") {
"//ios/chrome/browser/ui/alert_coordinator", "//ios/chrome/browser/ui/alert_coordinator",
"//ios/chrome/browser/ui/authentication", "//ios/chrome/browser/ui/authentication",
"//ios/chrome/browser/ui/commands", "//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/util",
"//ios/public/provider/chrome/browser", "//ios/public/provider/chrome/browser",
"//ios/public/provider/chrome/browser/signin", "//ios/public/provider/chrome/browser/signin",
] ]
......
...@@ -218,8 +218,8 @@ using signin_ui::CompletionCallback; ...@@ -218,8 +218,8 @@ using signin_ui::CompletionCallback;
- (void)dismissPresentedViewControllersAnimated:(BOOL)animated - (void)dismissPresentedViewControllersAnimated:(BOOL)animated
completion:(ProceduralBlock)completion { completion:(ProceduralBlock)completion {
if (self.presenter.isPresenting) { if (self.presenter.isPresenting) {
[self.presenter dismissViewControllerAnimated:animated [self.presenter dismissAllViewControllersAnimated:animated
completion:completion]; completion:completion];
} else if (completion) { } else if (completion) {
completion(); completion();
} }
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#import "ios/chrome/browser/ui/commands/application_commands.h" #import "ios/chrome/browser/ui/commands/application_commands.h"
#import "ios/chrome/browser/ui/signin_interaction/signin_interaction_controller.h" #import "ios/chrome/browser/ui/signin_interaction/signin_interaction_controller.h"
#import "ios/chrome/browser/ui/signin_interaction/signin_interaction_presenting.h" #import "ios/chrome/browser/ui/signin_interaction/signin_interaction_presenting.h"
#import "ios/chrome/browser/ui/util/top_view_controller.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support." #error "This file requires ARC support."
...@@ -34,6 +33,9 @@ ...@@ -34,6 +33,9 @@
// The UIViewController upon which UI should be presented. // The UIViewController upon which UI should be presented.
@property(nonatomic, strong) UIViewController* presentingViewController; @property(nonatomic, strong) UIViewController* presentingViewController;
// Bookkeeping for the top-most view controller.
@property(nonatomic, strong) UIViewController* topViewController;
@end @end
@implementation SigninInteractionCoordinator @implementation SigninInteractionCoordinator
...@@ -42,6 +44,7 @@ ...@@ -42,6 +44,7 @@
@synthesize controller = _controller; @synthesize controller = _controller;
@synthesize dispatcher = _dispatcher; @synthesize dispatcher = _dispatcher;
@synthesize presentingViewController = _presentingViewController; @synthesize presentingViewController = _presentingViewController;
@synthesize topViewController = _topViewController;
- (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState - (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState
dispatcher:(id<ApplicationCommands>)dispatcher { dispatcher:(id<ApplicationCommands>)dispatcher {
...@@ -125,37 +128,39 @@ ...@@ -125,37 +128,39 @@
- (void)presentViewController:(UIViewController*)viewController - (void)presentViewController:(UIViewController*)viewController
animated:(BOOL)animated animated:(BOOL)animated
completion:(ProceduralBlock)completion { completion:(ProceduralBlock)completion {
[self.presentingViewController presentViewController:viewController DCHECK_EQ(self.presentingViewController, self.topViewController);
animated:animated [self presentTopViewController:viewController
completion:completion]; animated:animated
completion:completion];
} }
- (void)presentTopViewController:(UIViewController*)viewController - (void)presentTopViewController:(UIViewController*)viewController
animated:(BOOL)animated animated:(BOOL)animated
completion:(ProceduralBlock)completion { completion:(ProceduralBlock)completion {
// TODO(crbug.com/754642): Stop using TopPresentedViewControllerFrom(). DCHECK(viewController);
UIViewController* topController = DCHECK(self.topViewController);
top_view_controller::TopPresentedViewControllerFrom( DCHECK(![self.topViewController presentedViewController]);
self.presentingViewController); [self.topViewController presentViewController:viewController
[topController presentViewController:viewController animated:animated
animated:animated completion:completion];
completion:completion]; self.topViewController = viewController;
} }
- (void)dismissViewControllerAnimated:(BOOL)animated - (void)dismissAllViewControllersAnimated:(BOOL)animated
completion:(ProceduralBlock)completion { completion:(ProceduralBlock)completion {
DCHECK([self isPresenting]);
[self.presentingViewController dismissViewControllerAnimated:animated [self.presentingViewController dismissViewControllerAnimated:animated
completion:completion]; completion:completion];
self.topViewController = self.presentingViewController;
} }
- (void)presentError:(NSError*)error - (void)presentError:(NSError*)error
dismissAction:(ProceduralBlock)dismissAction { dismissAction:(ProceduralBlock)dismissAction {
DCHECK(!self.alertCoordinator); DCHECK(!self.alertCoordinator);
// TODO(crbug.com/754642): Stop using TopPresentedViewControllerFrom(). DCHECK(self.topViewController);
DCHECK(![self.topViewController presentedViewController]);
self.alertCoordinator = self.alertCoordinator =
ErrorCoordinator(error, dismissAction, ErrorCoordinator(error, dismissAction, self.topViewController);
top_view_controller::TopPresentedViewControllerFrom(
self.presentingViewController));
[self.alertCoordinator start]; [self.alertCoordinator start];
} }
...@@ -182,7 +187,9 @@ setupForSigninOperationWithAccessPoint:(signin_metrics::AccessPoint)accessPoint ...@@ -182,7 +187,9 @@ setupForSigninOperationWithAccessPoint:(signin_metrics::AccessPoint)accessPoint
promoAction:(signin_metrics::PromoAction)promoAction promoAction:(signin_metrics::PromoAction)promoAction
presentingViewController: presentingViewController:
(UIViewController*)presentingViewController { (UIViewController*)presentingViewController {
DCHECK(![self isPresenting]);
self.presentingViewController = presentingViewController; self.presentingViewController = presentingViewController;
self.topViewController = presentingViewController;
self.controller = [[SigninInteractionController alloc] self.controller = [[SigninInteractionController alloc]
initWithBrowserState:self.browserState initWithBrowserState:self.browserState
...@@ -200,6 +207,7 @@ setupForSigninOperationWithAccessPoint:(signin_metrics::AccessPoint)accessPoint ...@@ -200,6 +207,7 @@ setupForSigninOperationWithAccessPoint:(signin_metrics::AccessPoint)accessPoint
signin_ui::CompletionCallback completionCallback = ^(BOOL success) { signin_ui::CompletionCallback completionCallback = ^(BOOL success) {
weakSelf.controller = nil; weakSelf.controller = nil;
weakSelf.presentingViewController = nil; weakSelf.presentingViewController = nil;
weakSelf.topViewController = nil;
weakSelf.alertCoordinator = nil; weakSelf.alertCoordinator = nil;
if (completion) { if (completion) {
completion(success); completion(success);
......
...@@ -23,9 +23,9 @@ ...@@ -23,9 +23,9 @@
animated:(BOOL)animated animated:(BOOL)animated
completion:(ProceduralBlock)completion; completion:(ProceduralBlock)completion;
// Dismisses the presented view controller. // Dismisses all view controllers presented via this protocol.
- (void)dismissViewControllerAnimated:(BOOL)animated - (void)dismissAllViewControllersAnimated:(BOOL)animated
completion:(ProceduralBlock)completion; completion:(ProceduralBlock)completion;
// Presents a dialog for |error| at the top of the presentation hierarchy. // Presents a dialog for |error| at the top of the presentation hierarchy.
// |dismissAction| is run when the dialog is dismissed. This method should not // |dismissAction| is run when the dialog is dismissed. This method should not
......
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