Index: ios/clean/chrome/browser/ui/context_menu/web_context_menu_coordinator.mm |
diff --git a/ios/clean/chrome/browser/ui/context_menu/web_context_menu_coordinator.mm b/ios/clean/chrome/browser/ui/context_menu/web_context_menu_coordinator.mm |
index 097c80552457c81497fffa2837335a10dfb56982..9a4cf0e0a870753b64e778151fcb45387a5b476e 100644 |
--- a/ios/clean/chrome/browser/ui/context_menu/web_context_menu_coordinator.mm |
+++ b/ios/clean/chrome/browser/ui/context_menu/web_context_menu_coordinator.mm |
@@ -4,6 +4,9 @@ |
#import "ios/clean/chrome/browser/ui/context_menu/web_context_menu_coordinator.h" |
+#include "base/logging.h" |
+#import "ios/clean/chrome/browser/ui/commands/context_menu_commands.h" |
+#import "ios/clean/chrome/browser/ui/context_menu/context_menu_context_impl.h" |
#import "ios/clean/chrome/browser/ui/context_menu/context_menu_mediator.h" |
#import "ios/clean/chrome/browser/ui/context_menu/context_menu_view_controller.h" |
#import "ios/shared/chrome/browser/ui/browser_list/browser.h" |
@@ -13,21 +16,55 @@ |
#error "This file requires ARC support." |
#endif |
-@interface WebContextMenuCoordinator () |
+@interface WebContextMenuCoordinator ()<ContextMenuCommands> |
+// The menu context. |
+@property(nonatomic, strong, readonly) ContextMenuContextImpl* context; |
+// The mediator that handles setting up |viewController|. |
@property(nonatomic, strong) ContextMenuMediator* mediator; |
+// The view controller that displayes the context menu UI. |
@property(nonatomic, strong) ContextMenuViewController* viewController; |
+ |
@end |
@implementation WebContextMenuCoordinator |
-@synthesize viewController = _viewController; |
+@synthesize context = _context; |
@synthesize mediator = _mediator; |
+@synthesize viewController = _viewController; |
+ |
+- (instancetype)initWithContext:(ContextMenuContextImpl*)context { |
+ if ((self = [super init])) { |
+ DCHECK(context); |
+ _context = context; |
+ } |
+ return self; |
+} |
+ |
+#pragma mark - BrowserCoordinator |
- (void)start { |
+ id<ContextMenuCommands> contextMenuDispatcher = |
+ static_cast<id<ContextMenuCommands>>(self.browser->dispatcher()); |
self.viewController = [[ContextMenuViewController alloc] |
- initWithDispatcher:static_cast<id>(self.browser->dispatcher())]; |
+ initWithDispatcher:contextMenuDispatcher]; |
self.mediator = |
edchin
2017/05/25 21:41:53
Since the mediator does its job in its initializer
kkhorimoto
2017/05/26 23:20:09
Doing that gave me an unused variable warning when
edchin
2017/05/27 15:59:03
Interesting question. This is the only mediator th
kkhorimoto
2017/05/27 23:09:03
I'm also working on the javascript dialog coordina
|
- [[ContextMenuMediator alloc] initWithConsumer:self.viewController]; |
+ [[ContextMenuMediator alloc] initWithConsumer:self.viewController |
+ context:self.context]; |
+ [self.browser->dispatcher() |
+ startDispatchingToTarget:self |
+ forSelector:@selector(hideContextMenu:)]; |
[super start]; |
} |
+- (void)stop { |
+ [self.browser->dispatcher() stopDispatchingToTarget:self]; |
+ [super stop]; |
+} |
+ |
+#pragma mark - ContextMenuCommands |
+ |
+- (void)hideContextMenu:(ContextMenuContext*)context { |
+ DCHECK_EQ(self.context, context); |
+ [self stop]; |
+} |
+ |
@end |