| Index: ios/clean/chrome/browser/ui/dialogs/dialog_coordinator.mm
|
| diff --git a/ios/clean/chrome/browser/ui/dialogs/dialog_coordinator.mm b/ios/clean/chrome/browser/ui/dialogs/dialog_coordinator.mm
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..309389501c99494fc54cfd017cf8a57ba9cfbf05
|
| --- /dev/null
|
| +++ b/ios/clean/chrome/browser/ui/dialogs/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/dialog_coordinator.h"
|
| +
|
| +#include "base/logging.h"
|
| +#import "ios/clean/chrome/browser/ui/dialogs/dialog_coordinator+subclassing.h"
|
| +#import "ios/clean/chrome/browser/ui/dialogs/dialog_mediator.h"
|
| +#import "ios/clean/chrome/browser/ui/dialogs/dialog_view_controller.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"
|
| +
|
| +#if !defined(__has_feature) || !__has_feature(objc_arc)
|
| +#error "This file requires ARC support."
|
| +#endif
|
| +
|
| +@interface DialogCoordinator () {
|
| + // Backing variable for property of same name (from OverlaySupport category).
|
| + OverlayQueue* _overlayQueue;
|
| +}
|
| +
|
| +// The dispatcher for DialogDismissalCommands.
|
| +@property(nonatomic, readonly) id<DialogDismissalCommands> dismissalDispatcher;
|
| +// The view controller used to display this dialog.
|
| +@property(nonatomic, strong) DialogViewController* viewController;
|
| +
|
| +@end
|
| +
|
| +@implementation DialogCoordinator
|
| +@synthesize viewController = _viewController;
|
| +
|
| +#pragma mark - Accessors
|
| +
|
| +- (id<DialogDismissalCommands>)dismissalDispatcher {
|
| + return static_cast<id<DialogDismissalCommands>>(self.browser->dispatcher());
|
| +}
|
| +
|
| +#pragma mark - BrowserCoordinator
|
| +
|
| +- (void)start {
|
| + DCHECK(self.overlayQueue);
|
| + DCHECK(self.mediator);
|
| + self.viewController =
|
| + [[DialogViewController alloc] initWithStyle:self.alertStyle
|
| + dispatcher:self.dismissalDispatcher];
|
| + [self.mediator updateConsumer:self.viewController];
|
| + [self.browser->dispatcher()
|
| + startDispatchingToTarget:self.mediator
|
| + forProtocol:@protocol(DialogDismissalCommands)];
|
| + [super start];
|
| +}
|
| +
|
| +- (void)stop {
|
| + [self.browser->dispatcher() stopDispatchingToTarget:self.mediator];
|
| + [super stop];
|
| + [self overlayWasStopped];
|
| +}
|
| +
|
| +@end
|
| +
|
| +@implementation DialogCoordinator (OverlaySupport)
|
| +
|
| +- (BOOL)supportsOverlaying {
|
| + return YES;
|
| +}
|
| +
|
| +- (void)setOverlayQueue:(OverlayQueue*)overlayQueue {
|
| + _overlayQueue = overlayQueue;
|
| +}
|
| +
|
| +- (OverlayQueue*)overlayQueue {
|
| + return _overlayQueue;
|
| +}
|
| +
|
| +@end
|
| +
|
| +@implementation DialogCoordinator (Subclassing)
|
| +
|
| +- (UIAlertControllerStyle)alertStyle {
|
| + return UIAlertControllerStyleAlert;
|
| +}
|
| +
|
| +- (DialogMediator*)mediator {
|
| + // Subclasses implement.
|
| + return nil;
|
| +}
|
| +
|
| +@end
|
|
|