OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import "ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_
coordinator.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #import "ios/clean/chrome/browser/ui/commands/http_auth_dialog_commands.h" |
| 9 #import "ios/clean/chrome/browser/ui/dialogs/dialog_coordinator+subclassing.h" |
| 10 #import "ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_
mediator.h" |
| 11 #import "ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_
request.h" |
| 12 #import "ios/clean/chrome/browser/ui/overlay_service/browser_coordinator+overlay
_support.h" |
| 13 #import "ios/shared/chrome/browser/ui/browser_list/browser.h" |
| 14 #import "ios/shared/chrome/browser/ui/commands/command_dispatcher.h" |
| 15 #import "ios/shared/chrome/browser/ui/coordinators/browser_coordinator+internal.
h" |
| 16 |
| 17 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 18 #error "This file requires ARC support." |
| 19 #endif |
| 20 |
| 21 @interface HTTPAuthDialogCoordinator ()<HTTPAuthDialogDismissalCommands> { |
| 22 // Backing object for property of same name (from Subclassing category). |
| 23 DialogMediator* _mediator; |
| 24 } |
| 25 |
| 26 // The dispatcher to provide to the mediator. |
| 27 @property(nonatomic, readonly, strong) id<HTTPAuthDialogDismissalCommands> |
| 28 dismissalDispatcher; |
| 29 // The request used for this dialog. |
| 30 @property(nonatomic, strong) HTTPAuthDialogRequest* request; |
| 31 |
| 32 @end |
| 33 |
| 34 @implementation HTTPAuthDialogCoordinator |
| 35 @synthesize request = _request; |
| 36 |
| 37 - (instancetype)initWithRequest:(HTTPAuthDialogRequest*)request { |
| 38 DCHECK(request); |
| 39 if ((self = [super init])) { |
| 40 _request = request; |
| 41 } |
| 42 return self; |
| 43 } |
| 44 |
| 45 #pragma mark - Accessors |
| 46 |
| 47 - (id<HTTPAuthDialogDismissalCommands>)dismissalDispatcher { |
| 48 return static_cast<id<HTTPAuthDialogDismissalCommands>>( |
| 49 self.browser->dispatcher()); |
| 50 } |
| 51 |
| 52 #pragma mark - BrowserCoordinator |
| 53 |
| 54 - (void)start { |
| 55 _mediator = |
| 56 [[HTTPAuthDialogMediator alloc] initWithRequest:self.request |
| 57 dispatcher:self.dismissalDispatcher]; |
| 58 [self.browser->dispatcher() |
| 59 startDispatchingToTarget:self |
| 60 forProtocol:@protocol(HTTPAuthDialogDismissalCommands)]; |
| 61 [super start]; |
| 62 } |
| 63 |
| 64 - (void)stop { |
| 65 if (self.started) |
| 66 [self.browser->dispatcher() stopDispatchingToTarget:self]; |
| 67 [super stop]; |
| 68 } |
| 69 |
| 70 #pragma mark - HTTPAuthDialogDismissalCommands |
| 71 |
| 72 - (void)dismissHTTPAuthDialog { |
| 73 [self stop]; |
| 74 } |
| 75 |
| 76 @end |
| 77 |
| 78 @implementation HTTPAuthDialogCoordinator (OverlaySupport) |
| 79 |
| 80 - (void)cancelOverlay { |
| 81 [self.request completeAuthenticationWithUsername:nil password:nil]; |
| 82 } |
| 83 |
| 84 @end |
| 85 |
| 86 @implementation HTTPAuthDialogCoordinator (Subclassing) |
| 87 |
| 88 - (DialogMediator*)mediator { |
| 89 return _mediator; |
| 90 } |
| 91 |
| 92 @end |
OLD | NEW |