Chromium Code Reviews| Index: ios/clean/chrome/browser/ui/overlays/browser_coordinator+overlay_support.mm |
| diff --git a/ios/clean/chrome/browser/ui/overlays/browser_coordinator+overlay_support.mm b/ios/clean/chrome/browser/ui/overlays/browser_coordinator+overlay_support.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1348eff0f6bc4c18fab1183fa67c0ecac303edc5 |
| --- /dev/null |
| +++ b/ios/clean/chrome/browser/ui/overlays/browser_coordinator+overlay_support.mm |
| @@ -0,0 +1,53 @@ |
| +// 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/overlays/browser_coordinator+overlay_support.h" |
| + |
| +#import <objc/runtime.h> |
| + |
| +#include "base/logging.h" |
| +#import "ios/clean/chrome/browser/ui/overlays/overlay_queue.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 |
| + |
| +namespace { |
| +const void* const kOverlayQueuePropertyKey = &kOverlayQueuePropertyKey; |
| +} |
| + |
| +@implementation BrowserCoordinator (OverlaySupport) |
| + |
| +- (BOOL)supportsOverlaying { |
| + return NO; |
| +} |
| + |
| +- (void)setQueue:(OverlayQueue*)queue { |
| + NSValue* ptrValue = [NSValue valueWithPointer:queue]; |
| + objc_setAssociatedObject(self, kOverlayQueuePropertyKey, ptrValue, |
|
marq (ping after 24h)
2017/06/21 09:41:53
I don't think encapsulation is worth the complexit
kkhorimoto
2017/06/23 06:11:15
Done.
|
| + OBJC_ASSOCIATION_RETAIN_NONATOMIC); |
| +} |
| + |
| +- (OverlayQueue*)queue { |
| + NSValue* ptrValue = objc_getAssociatedObject(self, kOverlayQueuePropertyKey); |
| + return static_cast<OverlayQueue*>([ptrValue pointerValue]); |
| +} |
| + |
| +- (void)startOverlayingCoordinator:(BrowserCoordinator*)overlayParent { |
| + DCHECK(overlayParent); |
| + [overlayParent addChildCoordinator:self]; |
| + [self start]; |
| +} |
| + |
| +- (void)overlayWasStopped { |
| + [self.parentCoordinator removeChildCoordinator:self]; |
| + self.queue->OverlayWasStopped(self); |
| +} |
| + |
| +- (void)cancelOverlay { |
| + // Implemented by subclasses. |
| +} |
| + |
| +@end |