Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(487)

Side by Side Diff: ios/clean/chrome/browser/ui/web_contents/web_coordinator.mm

Issue 2935653002: [ios clean] Move dispatcher out of Browser.
Patch Set: Dispatcher out of Browser. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ios/clean/chrome/browser/ui/web_contents/web_coordinator.h" 5 #import "ios/clean/chrome/browser/ui/web_contents/web_coordinator.h"
6 6
7 #include "base/mac/foundation_util.h" 7 #include "base/mac/foundation_util.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #import "ios/clean/chrome/browser/ui/commands/context_menu_commands.h" 9 #import "ios/clean/chrome/browser/ui/commands/context_menu_commands.h"
10 #import "ios/clean/chrome/browser/ui/context_menu/context_menu_context_impl.h" 10 #import "ios/clean/chrome/browser/ui/context_menu/context_menu_context_impl.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 } 57 }
58 58
59 - (void)stop { 59 - (void)stop {
60 [super stop]; 60 [super stop];
61 [self.mediator disconnect]; 61 [self.mediator disconnect];
62 } 62 }
63 63
64 - (void)childCoordinatorDidStart:(BrowserCoordinator*)childCoordinator { 64 - (void)childCoordinatorDidStart:(BrowserCoordinator*)childCoordinator {
65 // Register to receive relevant ContextMenuCommands. 65 // Register to receive relevant ContextMenuCommands.
66 if ([childCoordinator isKindOfClass:[WebContextMenuCoordinator class]]) { 66 if ([childCoordinator isKindOfClass:[WebContextMenuCoordinator class]]) {
67 [self.browser->dispatcher() 67 [self.dispatcher
68 startDispatchingToTarget:self 68 startDispatchingToTarget:self
69 forSelector:@selector(executeContextMenuScript:)]; 69 forSelector:@selector(executeContextMenuScript:)];
70 [self.browser->dispatcher() 70 [self.dispatcher startDispatchingToTarget:self
71 startDispatchingToTarget:self 71 forSelector:@selector(openContextMenuImage:)];
72 forSelector:@selector(openContextMenuImage:)];
73 } 72 }
74 [self.viewController presentViewController:childCoordinator.viewController 73 [self.viewController presentViewController:childCoordinator.viewController
75 animated:YES 74 animated:YES
76 completion:nil]; 75 completion:nil];
77 } 76 }
78 77
79 - (void)childCoordinatorWillStop:(BrowserCoordinator*)childCoordinator { 78 - (void)childCoordinatorWillStop:(BrowserCoordinator*)childCoordinator {
80 // Unregister ContextMenuCommands once the UI has been dismissed. 79 // Unregister ContextMenuCommands once the UI has been dismissed.
81 if ([childCoordinator isKindOfClass:[WebContextMenuCoordinator class]]) { 80 if ([childCoordinator isKindOfClass:[WebContextMenuCoordinator class]]) {
82 [self.browser->dispatcher() 81 [self.dispatcher
83 stopDispatchingForSelector:@selector(executeContextMenuScript:)]; 82 stopDispatchingForSelector:@selector(executeContextMenuScript:)];
84 [self.browser->dispatcher() 83 [self.dispatcher
85 stopDispatchingForSelector:@selector(openContextMenuImage:)]; 84 stopDispatchingForSelector:@selector(openContextMenuImage:)];
86 } 85 }
87 } 86 }
88 87
89 #pragma mark - ContextMenuCommand 88 #pragma mark - ContextMenuCommand
90 89
91 - (void)executeContextMenuScript:(ContextMenuContext*)context { 90 - (void)executeContextMenuScript:(ContextMenuContext*)context {
92 ContextMenuContextImpl* contextImpl = 91 ContextMenuContextImpl* contextImpl =
93 base::mac::ObjCCastStrict<ContextMenuContextImpl>(context); 92 base::mac::ObjCCastStrict<ContextMenuContextImpl>(context);
94 self.webState->ExecuteJavaScript(contextImpl.script); 93 self.webState->ExecuteJavaScript(contextImpl.script);
(...skipping 13 matching lines...) Expand all
108 ContextMenuContextImpl* context = 107 ContextMenuContextImpl* context =
109 [[ContextMenuContextImpl alloc] initWithParams:params]; 108 [[ContextMenuContextImpl alloc] initWithParams:params];
110 WebContextMenuCoordinator* contextMenu = 109 WebContextMenuCoordinator* contextMenu =
111 [[WebContextMenuCoordinator alloc] initWithContext:context]; 110 [[WebContextMenuCoordinator alloc] initWithContext:context];
112 [self addChildCoordinator:contextMenu]; 111 [self addChildCoordinator:contextMenu];
113 [contextMenu start]; 112 [contextMenu start];
114 return YES; 113 return YES;
115 } 114 }
116 115
117 @end 116 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698