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/dialog_coordinator.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #import "ios/clean/chrome/browser/ui/dialogs/dialog_coordinator+subclassing.h" |
| 9 #import "ios/clean/chrome/browser/ui/dialogs/dialog_mediator.h" |
| 10 #import "ios/clean/chrome/browser/ui/dialogs/dialog_view_controller.h" |
| 11 #import "ios/clean/chrome/browser/ui/overlay_service/browser_coordinator+overlay
_support.h" |
| 12 #import "ios/shared/chrome/browser/ui/browser_list/browser.h" |
| 13 #import "ios/shared/chrome/browser/ui/commands/command_dispatcher.h" |
| 14 |
| 15 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 16 #error "This file requires ARC support." |
| 17 #endif |
| 18 |
| 19 @interface DialogCoordinator () { |
| 20 // Backing variable for property of same name (from OverlaySupport category). |
| 21 OverlayQueue* _overlayQueue; |
| 22 } |
| 23 |
| 24 // The dispatcher for DialogDismissalCommands. |
| 25 @property(nonatomic, readonly) id<DialogDismissalCommands> dismissalDispatcher; |
| 26 // The view controller used to display this dialog. |
| 27 @property(nonatomic, strong) DialogViewController* viewController; |
| 28 |
| 29 @end |
| 30 |
| 31 @implementation DialogCoordinator |
| 32 @synthesize viewController = _viewController; |
| 33 |
| 34 #pragma mark - Accessors |
| 35 |
| 36 - (id<DialogDismissalCommands>)dismissalDispatcher { |
| 37 return static_cast<id<DialogDismissalCommands>>(self.browser->dispatcher()); |
| 38 } |
| 39 |
| 40 #pragma mark - BrowserCoordinator |
| 41 |
| 42 - (void)start { |
| 43 DCHECK(self.overlayQueue); |
| 44 DCHECK(self.mediator); |
| 45 self.viewController = |
| 46 [[DialogViewController alloc] initWithStyle:self.alertStyle |
| 47 dispatcher:self.dismissalDispatcher]; |
| 48 [self.mediator updateConsumer:self.viewController]; |
| 49 [self.browser->dispatcher() |
| 50 startDispatchingToTarget:self.mediator |
| 51 forProtocol:@protocol(DialogDismissalCommands)]; |
| 52 [super start]; |
| 53 } |
| 54 |
| 55 - (void)stop { |
| 56 [self.browser->dispatcher() stopDispatchingToTarget:self.mediator]; |
| 57 [super stop]; |
| 58 [self overlayWasStopped]; |
| 59 } |
| 60 |
| 61 @end |
| 62 |
| 63 @implementation DialogCoordinator (OverlaySupport) |
| 64 |
| 65 - (BOOL)supportsOverlaying { |
| 66 return YES; |
| 67 } |
| 68 |
| 69 - (void)setOverlayQueue:(OverlayQueue*)overlayQueue { |
| 70 _overlayQueue = overlayQueue; |
| 71 } |
| 72 |
| 73 - (OverlayQueue*)overlayQueue { |
| 74 return _overlayQueue; |
| 75 } |
| 76 |
| 77 @end |
| 78 |
| 79 @implementation DialogCoordinator (Subclassing) |
| 80 |
| 81 - (UIAlertControllerStyle)alertStyle { |
| 82 return UIAlertControllerStyleAlert; |
| 83 } |
| 84 |
| 85 - (DialogMediator*)mediator { |
| 86 // Subclasses implement. |
| 87 return nil; |
| 88 } |
| 89 |
| 90 @end |
OLD | NEW |