| OLD | NEW |
| 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/toolbar/toolbar_coordinator.h" | 5 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_coordinator.h" |
| 6 | 6 |
| 7 #import "ios/clean/chrome/browser/ui/commands/tools_menu_commands.h" | 7 #import "ios/clean/chrome/browser/ui/commands/tools_menu_commands.h" |
| 8 #import "ios/clean/chrome/browser/ui/omnibox/location_bar_coordinator.h" | 8 #import "ios/clean/chrome/browser/ui/omnibox/location_bar_coordinator.h" |
| 9 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_mediator.h" | 9 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_mediator.h" |
| 10 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_view_controller.h" | 10 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_view_controller.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 } | 43 } |
| 44 | 44 |
| 45 - (void)setWebState:(web::WebState*)webState { | 45 - (void)setWebState:(web::WebState*)webState { |
| 46 _webState = webState; | 46 _webState = webState; |
| 47 self.mediator.webState = self.webState; | 47 self.mediator.webState = self.webState; |
| 48 } | 48 } |
| 49 | 49 |
| 50 - (void)start { | 50 - (void)start { |
| 51 self.viewController = [[ToolbarViewController alloc] init]; | 51 self.viewController = [[ToolbarViewController alloc] init]; |
| 52 | 52 |
| 53 CommandDispatcher* dispatcher = self.browser->dispatcher(); | 53 [self.dispatcher startDispatchingToTarget:self |
| 54 [dispatcher startDispatchingToTarget:self | 54 forSelector:@selector(showToolsMenu)]; |
| 55 forSelector:@selector(showToolsMenu)]; | 55 [self.dispatcher startDispatchingToTarget:self |
| 56 [dispatcher startDispatchingToTarget:self | 56 forSelector:@selector(closeToolsMenu)]; |
| 57 forSelector:@selector(closeToolsMenu)]; | 57 [self.dispatcher startDispatchingToTarget:self forSelector:@selector(goBack)]; |
| 58 [dispatcher startDispatchingToTarget:self forSelector:@selector(goBack)]; | 58 [self.dispatcher startDispatchingToTarget:self |
| 59 [dispatcher startDispatchingToTarget:self forSelector:@selector(goForward)]; | 59 forSelector:@selector(goForward)]; |
| 60 [dispatcher startDispatchingToTarget:self forSelector:@selector(reloadPage)]; | 60 [self.dispatcher startDispatchingToTarget:self |
| 61 [dispatcher startDispatchingToTarget:self | 61 forSelector:@selector(reloadPage)]; |
| 62 forSelector:@selector(stopLoadingPage)]; | 62 [self.dispatcher startDispatchingToTarget:self |
| 63 forSelector:@selector(stopLoadingPage)]; |
| 63 | 64 |
| 64 self.viewController.dispatcher = static_cast<id>(self.browser->dispatcher()); | 65 self.viewController.dispatcher = self.callableDispatcher; |
| 65 self.mediator.consumer = self.viewController; | 66 self.mediator.consumer = self.viewController; |
| 66 self.mediator.webStateList = &self.browser->web_state_list(); | 67 self.mediator.webStateList = &self.browser->web_state_list(); |
| 67 | 68 |
| 68 [self.browser->broadcaster() | 69 [self.browser->broadcaster() |
| 69 addObserver:self.mediator | 70 addObserver:self.mediator |
| 70 forSelector:@selector(broadcastTabStripVisible:)]; | 71 forSelector:@selector(broadcastTabStripVisible:)]; |
| 71 LocationBarCoordinator* locationBarCoordinator = | 72 LocationBarCoordinator* locationBarCoordinator = |
| 72 [[LocationBarCoordinator alloc] init]; | 73 [[LocationBarCoordinator alloc] init]; |
| 73 self.locationBarCoordinator = locationBarCoordinator; | 74 self.locationBarCoordinator = locationBarCoordinator; |
| 74 [self addChildCoordinator:locationBarCoordinator]; | 75 [self addChildCoordinator:locationBarCoordinator]; |
| 75 [locationBarCoordinator start]; | 76 [locationBarCoordinator start]; |
| 76 | 77 |
| 77 [super start]; | 78 [super start]; |
| 78 } | 79 } |
| 79 | 80 |
| 80 - (void)stop { | 81 - (void)stop { |
| 81 [super stop]; | 82 [super stop]; |
| 82 [self.browser->broadcaster() | 83 [self.browser->broadcaster() |
| 83 removeObserver:self.mediator | 84 removeObserver:self.mediator |
| 84 forSelector:@selector(broadcastTabStripVisible:)]; | 85 forSelector:@selector(broadcastTabStripVisible:)]; |
| 85 [self.browser->dispatcher() stopDispatchingToTarget:self]; | 86 [self.dispatcher stopDispatchingToTarget:self]; |
| 86 } | 87 } |
| 87 | 88 |
| 88 - (void)childCoordinatorDidStart:(BrowserCoordinator*)childCoordinator { | 89 - (void)childCoordinatorDidStart:(BrowserCoordinator*)childCoordinator { |
| 89 if ([childCoordinator isKindOfClass:[LocationBarCoordinator class]]) { | 90 if ([childCoordinator isKindOfClass:[LocationBarCoordinator class]]) { |
| 90 self.viewController.locationBarViewController = | 91 self.viewController.locationBarViewController = |
| 91 self.locationBarCoordinator.viewController; | 92 self.locationBarCoordinator.viewController; |
| 92 } else if ([childCoordinator isKindOfClass:[ToolsCoordinator class]]) { | 93 } else if ([childCoordinator isKindOfClass:[ToolsCoordinator class]]) { |
| 93 [self.viewController presentViewController:childCoordinator.viewController | 94 [self.viewController presentViewController:childCoordinator.viewController |
| 94 animated:YES | 95 animated:YES |
| 95 completion:nil]; | 96 completion:nil]; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 - (void)stopLoadingPage { | 142 - (void)stopLoadingPage { |
| 142 self.webState->Stop(); | 143 self.webState->Stop(); |
| 143 } | 144 } |
| 144 | 145 |
| 145 - (void)reloadPage { | 146 - (void)reloadPage { |
| 146 self.webState->GetNavigationManager()->Reload(web::ReloadType::NORMAL, | 147 self.webState->GetNavigationManager()->Reload(web::ReloadType::NORMAL, |
| 147 false /*check_for_repost*/); | 148 false /*check_for_repost*/); |
| 148 } | 149 } |
| 149 | 150 |
| 150 @end | 151 @end |
| OLD | NEW |