Chromium Code Reviews| Index: ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_coordinator.mm |
| diff --git a/ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_coordinator.mm b/ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_coordinator.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8f362df46b0a49a2d8e26ae3566116d9a92e51c4 |
| --- /dev/null |
| +++ b/ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_coordinator.mm |
| @@ -0,0 +1,90 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#import "ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_coordinator.h" |
| + |
| +#import "ios/clean/chrome/browser/ui/commands/http_auth_dialog_commands.h" |
| +#import "ios/clean/chrome/browser/ui/commands/overlay_commands.h" |
| +#import "ios/clean/chrome/browser/ui/dialogs/dialog_view_controller.h" |
| +#import "ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_mediator.h" |
| +#import "ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_state.h" |
| +#import "ios/clean/chrome/browser/ui/overlays/overlay_queue.h" |
| +#import "ios/shared/chrome/browser/ui/browser_list/browser.h" |
| +#import "ios/shared/chrome/browser/ui/commands/command_dispatcher.h" |
| +#import "ios/shared/chrome/browser/ui/coordinators/browser_coordinator+internal.h" |
| + |
| +#if !defined(__has_feature) || !__has_feature(objc_arc) |
| +#error "This file requires ARC support." |
| +#endif |
| + |
| +@interface HTTPAuthDialogCoordinator ()<HTTPAuthDialogDismissalCommands> |
| + |
| +// The dispatcher for HTTPAuthDialogDismissalCommands. |
| +@property(nonatomic, readonly) id<DialogDismissalCommands> dismissalDispatcher; |
| +// The state used to configure this dialog. |
| +@property(nonatomic, strong) HTTPAuthDialogState* state; |
| +// The view controller used to display this dialog. |
| +@property(nonatomic, strong) DialogViewController* viewController; |
| +// The mediator used to set up |viewController|. |
| +@property(nonatomic, strong) HTTPAuthDialogMediator* mediator; |
| + |
| +@end |
| + |
| +@implementation HTTPAuthDialogCoordinator |
| + |
| +@synthesize state = _state; |
| +@synthesize viewController = _viewController; |
| +@synthesize mediator = _mediator; |
| + |
| +- (instancetype)initWithState:(HTTPAuthDialogState*)state { |
| + DCHECK(state.webState); |
| + if ((self = [super initWithWebState:state.webState])) { |
| + _state = state; |
| + } |
| + return self; |
| +} |
| + |
| +#pragma mark - Accessors |
| + |
| +- (id<DialogDismissalCommands>)dismissalDispatcher { |
| + return static_cast<id<DialogDismissalCommands>>(self.browser->dispatcher()); |
| +} |
| + |
| +#pragma mark - BrowserCoordinator |
| + |
| +- (void)start { |
| + self.viewController = |
| + [[DialogViewController alloc] initWithStyle:UIAlertControllerStyleAlert |
| + dispatcher:self.dismissalDispatcher]; |
| + self.mediator = [[HTTPAuthDialogMediator alloc] |
| + initWithDispatcher:self.browser->dispatcher() |
| + state:self.state]; |
| + [self.mediator updateConsumer:self.viewController]; |
| + [self.mediator dialogWillStart]; |
| + [self.browser->dispatcher() |
| + startDispatchingToTarget:self |
| + forProtocol:@protocol(HTTPAuthDialogDismissalCommands)]; |
| + [super start]; |
| +} |
| + |
| +- (void)stop { |
| + [self.mediator dialogWillStop]; |
| + [super stop]; |
| +} |
| + |
| +#pragma mark - OverlayCoordinator |
| + |
| +- (void)cancelOverlay { |
| + [self.state runCallbackWithUserName:nil password:nil]; |
| +} |
| + |
| +#pragma mark - HTTPAuthDialogDismissalCommands |
| + |
| +- (void)dismissHTTPAuthDialogWithUsername:(NSString*)username |
| + password:(NSString*)password { |
| + [self.state runCallbackWithUserName:username password:password]; |
|
marq (ping after 24h)
2017/06/14 11:19:15
I'd rather have the mediator handle stuff like run
kkhorimoto
2017/06/23 06:25:41
Done. We'll still need to run the callback here f
|
| + [self stop]; |
| +} |
| + |
| +@end |