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") {
"//ios/chrome/browser/ui/alert_coordinator",
"//ios/chrome/browser/ui/authentication",
"//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/util",
"//ios/public/provider/chrome/browser",
"//ios/public/provider/chrome/browser/signin",
]
......
......@@ -218,8 +218,8 @@ using signin_ui::CompletionCallback;
- (void)dismissPresentedViewControllersAnimated:(BOOL)animated
completion:(ProceduralBlock)completion {
if (self.presenter.isPresenting) {
[self.presenter dismissViewControllerAnimated:animated
completion:completion];
[self.presenter dismissAllViewControllersAnimated:animated
completion:completion];
} else if (completion) {
completion();
}
......
......@@ -11,7 +11,6 @@
#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_presenting.h"
#import "ios/chrome/browser/ui/util/top_view_controller.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
......@@ -34,6 +33,9 @@
// The UIViewController upon which UI should be presented.
@property(nonatomic, strong) UIViewController* presentingViewController;
// Bookkeeping for the top-most view controller.
@property(nonatomic, strong) UIViewController* topViewController;
@end
@implementation SigninInteractionCoordinator
......@@ -42,6 +44,7 @@
@synthesize controller = _controller;
@synthesize dispatcher = _dispatcher;
@synthesize presentingViewController = _presentingViewController;
@synthesize topViewController = _topViewController;
- (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState
dispatcher:(id<ApplicationCommands>)dispatcher {
......@@ -125,37 +128,39 @@
- (void)presentViewController:(UIViewController*)viewController
animated:(BOOL)animated
completion:(ProceduralBlock)completion {
[self.presentingViewController presentViewController:viewController
animated:animated
completion:completion];
DCHECK_EQ(self.presentingViewController, self.topViewController);
[self presentTopViewController:viewController
animated:animated
completion:completion];
}
- (void)presentTopViewController:(UIViewController*)viewController
animated:(BOOL)animated
completion:(ProceduralBlock)completion {
// TODO(crbug.com/754642): Stop using TopPresentedViewControllerFrom().
UIViewController* topController =
top_view_controller::TopPresentedViewControllerFrom(
self.presentingViewController);
[topController presentViewController:viewController
animated:animated
completion:completion];
}
- (void)dismissViewControllerAnimated:(BOOL)animated
completion:(ProceduralBlock)completion {
DCHECK(viewController);
DCHECK(self.topViewController);
DCHECK(![self.topViewController presentedViewController]);
[self.topViewController presentViewController:viewController
animated:animated
completion:completion];
self.topViewController = viewController;
}
- (void)dismissAllViewControllersAnimated:(BOOL)animated
completion:(ProceduralBlock)completion {
DCHECK([self isPresenting]);
[self.presentingViewController dismissViewControllerAnimated:animated
completion:completion];
self.topViewController = self.presentingViewController;
}
- (void)presentError:(NSError*)error
dismissAction:(ProceduralBlock)dismissAction {
DCHECK(!self.alertCoordinator);
// TODO(crbug.com/754642): Stop using TopPresentedViewControllerFrom().
DCHECK(self.topViewController);
DCHECK(![self.topViewController presentedViewController]);
self.alertCoordinator =
ErrorCoordinator(error, dismissAction,
top_view_controller::TopPresentedViewControllerFrom(
self.presentingViewController));
ErrorCoordinator(error, dismissAction, self.topViewController);
[self.alertCoordinator start];
}
......@@ -182,7 +187,9 @@ setupForSigninOperationWithAccessPoint:(signin_metrics::AccessPoint)accessPoint
promoAction:(signin_metrics::PromoAction)promoAction
presentingViewController:
(UIViewController*)presentingViewController {
DCHECK(![self isPresenting]);
self.presentingViewController = presentingViewController;
self.topViewController = presentingViewController;
self.controller = [[SigninInteractionController alloc]
initWithBrowserState:self.browserState
......@@ -200,6 +207,7 @@ setupForSigninOperationWithAccessPoint:(signin_metrics::AccessPoint)accessPoint
signin_ui::CompletionCallback completionCallback = ^(BOOL success) {
weakSelf.controller = nil;
weakSelf.presentingViewController = nil;
weakSelf.topViewController = nil;
weakSelf.alertCoordinator = nil;
if (completion) {
completion(success);
......
......@@ -23,9 +23,9 @@
animated:(BOOL)animated
completion:(ProceduralBlock)completion;
// Dismisses the presented view controller.
- (void)dismissViewControllerAnimated:(BOOL)animated
completion:(ProceduralBlock)completion;
// Dismisses all view controllers presented via this protocol.
- (void)dismissAllViewControllersAnimated:(BOOL)animated
completion:(ProceduralBlock)completion;
// Presents a dialog for |error| at the top of the presentation hierarchy.
// |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