Chromium Code Reviews| Index: ios/clean/chrome/browser/ui/web_contents/overlays/web_overlay_coordinator.mm |
| diff --git a/ios/clean/chrome/browser/ui/web_contents/overlays/web_overlay_coordinator.mm b/ios/clean/chrome/browser/ui/web_contents/overlays/web_overlay_coordinator.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8d1f4a913b42501357870eb1b1ecda6cbea07fb4 |
| --- /dev/null |
| +++ b/ios/clean/chrome/browser/ui/web_contents/overlays/web_overlay_coordinator.mm |
| @@ -0,0 +1,61 @@ |
| +// 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/web_contents/overlays/web_overlay_coordinator.h" |
| + |
| +#import "base/logging.h" |
| +#import "ios/clean/chrome/browser/ui/commands/web_overlay_commands.h" |
| +#import "ios/clean/chrome/browser/ui/web_contents/overlays/web_overlay_queue.h" |
| +#import "ios/shared/chrome/browser/ui/browser_list/browser.h" |
| +#import "ios/shared/chrome/browser/ui/coordinators/browser_coordinator+internal.h" |
| +#import "ios/web/public/web_state/web_state.h" |
| + |
| +#if !defined(__has_feature) || !__has_feature(objc_arc) |
| +#error "This file requires ARC support." |
| +#endif |
| + |
| +@interface WebOverlayCoordinator () { |
| + // The WebState requesting this overlay. |
| + web::WebState* _webState; |
| +} |
| + |
| +@end |
| + |
| +@implementation WebOverlayCoordinator |
| + |
| +- (instancetype)initWithWebState:(web::WebState*)webState { |
| + DCHECK(webState); |
| + if ((self = [super init])) |
|
marq (ping after 24h)
2017/06/02 16:14:11
Prefer to have {} around the conditional block in
kkhorimoto
2017/06/03 00:37:32
Acknowledged.
|
| + _webState = webState; |
| + return self; |
| +} |
| + |
| +#pragma mark - Public |
| + |
| +- (void)startOverlayingWebCoordinator:(BrowserCoordinator*)webCoordinator { |
| + DCHECK([webCoordinator canAddOverlayCoordinator:self]); |
| + [webCoordinator addOverlayCoordinator:self]; |
| + [self start]; |
| +} |
| + |
| +- (void)cancelWebKitCompletion { |
| + // Must be implemented in subclasses. |
| +} |
| + |
| +#pragma mark - BrowserCoordinator |
| + |
| +- (void)stop { |
| + // Notify the WebOverlayQueue that this coordinator has stopped so that it can |
| + // be dequeued. |
| + WebOverlayQueue::FromWebState(_webState)->WebOverlayWasStopped(self); |
| + // Notify the scheduler that the overlay has stopped. |
|
marq (ping after 24h)
2017/06/02 16:14:11
Move this comment after [super stop].
kkhorimoto
2017/06/03 00:37:32
Acknowledged.
|
| + [super stop]; |
| + id<WebOverlaySchedulerCommands> overlayDispatcher = |
| + static_cast<id<WebOverlaySchedulerCommands>>(self.browser->dispatcher()); |
| + [overlayDispatcher webOverlayWasStoppedForWebState:_webState]; |
| + // Remove as the overlay for its parent. |
| + [self.parentCoordinator removeOverlayCoordinator]; |
| +} |
| + |
| +@end |