| 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..ba8d274d4adca40da1829c017a92a528a85e675a
|
| --- /dev/null
|
| +++ b/ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_coordinator.mm
|
| @@ -0,0 +1,92 @@
|
| +// 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"
|
| +
|
| +#include "base/logging.h"
|
| +#import "ios/clean/chrome/browser/ui/commands/http_auth_dialog_commands.h"
|
| +#import "ios/clean/chrome/browser/ui/dialogs/dialog_coordinator+subclassing.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_request.h"
|
| +#import "ios/clean/chrome/browser/ui/overlay_service/browser_coordinator+overlay_support.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> {
|
| + // Backing object for property of same name (from Subclassing category).
|
| + DialogMediator* _mediator;
|
| +}
|
| +
|
| +// The dispatcher to provide to the mediator.
|
| +@property(nonatomic, readonly, strong) id<HTTPAuthDialogDismissalCommands>
|
| + dismissalDispatcher;
|
| +// The request used for this dialog.
|
| +@property(nonatomic, strong) HTTPAuthDialogRequest* request;
|
| +
|
| +@end
|
| +
|
| +@implementation HTTPAuthDialogCoordinator
|
| +@synthesize request = _request;
|
| +
|
| +- (instancetype)initWithRequest:(HTTPAuthDialogRequest*)request {
|
| + DCHECK(request);
|
| + if ((self = [super init])) {
|
| + _request = request;
|
| + }
|
| + return self;
|
| +}
|
| +
|
| +#pragma mark - Accessors
|
| +
|
| +- (id<HTTPAuthDialogDismissalCommands>)dismissalDispatcher {
|
| + return static_cast<id<HTTPAuthDialogDismissalCommands>>(
|
| + self.browser->dispatcher());
|
| +}
|
| +
|
| +#pragma mark - BrowserCoordinator
|
| +
|
| +- (void)start {
|
| + _mediator =
|
| + [[HTTPAuthDialogMediator alloc] initWithRequest:self.request
|
| + dispatcher:self.dismissalDispatcher];
|
| + [self.browser->dispatcher()
|
| + startDispatchingToTarget:self
|
| + forProtocol:@protocol(HTTPAuthDialogDismissalCommands)];
|
| + [super start];
|
| +}
|
| +
|
| +- (void)stop {
|
| + if (self.started)
|
| + [self.browser->dispatcher() stopDispatchingToTarget:self];
|
| + [super stop];
|
| +}
|
| +
|
| +#pragma mark - HTTPAuthDialogDismissalCommands
|
| +
|
| +- (void)dismissHTTPAuthDialog {
|
| + [self stop];
|
| +}
|
| +
|
| +@end
|
| +
|
| +@implementation HTTPAuthDialogCoordinator (OverlaySupport)
|
| +
|
| +- (void)cancelOverlay {
|
| + [self.request completeAuthenticationWithUsername:nil password:nil];
|
| +}
|
| +
|
| +@end
|
| +
|
| +@implementation HTTPAuthDialogCoordinator (Subclassing)
|
| +
|
| +- (DialogMediator*)mediator {
|
| + return _mediator;
|
| +}
|
| +
|
| +@end
|
|
|