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" |
11 #import "ios/clean/chrome/browser/ui/tools/tools_coordinator.h" | 11 #import "ios/clean/chrome/browser/ui/tools/tools_coordinator.h" |
12 #import "ios/shared/chrome/browser/coordinator_context/coordinator_context.h" | |
13 #import "ios/shared/chrome/browser/ui/browser_list/browser.h" | 12 #import "ios/shared/chrome/browser/ui/browser_list/browser.h" |
14 #import "ios/shared/chrome/browser/ui/commands/command_dispatcher.h" | 13 #import "ios/shared/chrome/browser/ui/commands/command_dispatcher.h" |
15 #import "ios/shared/chrome/browser/ui/coordinators/browser_coordinator+internal.
h" | 14 #import "ios/shared/chrome/browser/ui/coordinators/browser_coordinator+internal.
h" |
16 #import "ios/web/public/navigation_manager.h" | 15 #import "ios/web/public/navigation_manager.h" |
17 #include "ios/web/public/web_state/web_state.h" | 16 #include "ios/web/public/web_state/web_state.h" |
18 | 17 |
19 #if !defined(__has_feature) || !__has_feature(objc_arc) | 18 #if !defined(__has_feature) || !__has_feature(objc_arc) |
20 #error "This file requires ARC support." | 19 #error "This file requires ARC support." |
21 #endif | 20 #endif |
22 | 21 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 61 |
63 self.viewController.dispatcher = static_cast<id>(self.browser->dispatcher()); | 62 self.viewController.dispatcher = static_cast<id>(self.browser->dispatcher()); |
64 self.mediator.consumer = self.viewController; | 63 self.mediator.consumer = self.viewController; |
65 | 64 |
66 LocationBarCoordinator* locationBarCoordinator = | 65 LocationBarCoordinator* locationBarCoordinator = |
67 [[LocationBarCoordinator alloc] init]; | 66 [[LocationBarCoordinator alloc] init]; |
68 self.locationBarCoordinator = locationBarCoordinator; | 67 self.locationBarCoordinator = locationBarCoordinator; |
69 [self addChildCoordinator:locationBarCoordinator]; | 68 [self addChildCoordinator:locationBarCoordinator]; |
70 [locationBarCoordinator start]; | 69 [locationBarCoordinator start]; |
71 | 70 |
72 [self.context.baseViewController presentViewController:self.viewController | |
73 animated:self.context.animated | |
74 completion:nil]; | |
75 [super start]; | 71 [super start]; |
76 } | 72 } |
77 | 73 |
78 - (void)stop { | 74 - (void)stop { |
79 [super stop]; | 75 [super stop]; |
80 [self.browser->dispatcher() stopDispatchingToTarget:self]; | 76 [self.browser->dispatcher() stopDispatchingToTarget:self]; |
81 } | 77 } |
82 | 78 |
83 - (void)childCoordinatorDidStart:(BrowserCoordinator*)coordinator { | 79 - (void)childCoordinatorDidStart:(BrowserCoordinator*)childCoordinator { |
84 if ([coordinator isKindOfClass:[LocationBarCoordinator class]]) { | 80 if ([childCoordinator isKindOfClass:[LocationBarCoordinator class]]) { |
85 self.viewController.locationBarViewController = | 81 self.viewController.locationBarViewController = |
86 self.locationBarCoordinator.viewController; | 82 self.locationBarCoordinator.viewController; |
| 83 } else if ([childCoordinator isKindOfClass:[ToolsCoordinator class]]) { |
| 84 [self.viewController presentViewController:childCoordinator.viewController |
| 85 animated:YES |
| 86 completion:nil]; |
87 } | 87 } |
88 } | 88 } |
89 | 89 |
| 90 - (void)childCoordinatorWillStop:(BrowserCoordinator*)childCoordinator { |
| 91 if ([childCoordinator isKindOfClass:[ToolsCoordinator class]]) { |
| 92 [childCoordinator.viewController.presentingViewController |
| 93 dismissViewControllerAnimated:YES |
| 94 completion:nil]; |
| 95 } |
| 96 } |
| 97 |
90 #pragma mark - ToolsMenuCommands Implementation | 98 #pragma mark - ToolsMenuCommands Implementation |
91 | 99 |
92 - (void)showToolsMenu { | 100 - (void)showToolsMenu { |
93 ToolsCoordinator* toolsCoordinator = [[ToolsCoordinator alloc] init]; | 101 ToolsCoordinator* toolsCoordinator = [[ToolsCoordinator alloc] init]; |
94 [self addChildCoordinator:toolsCoordinator]; | 102 [self addChildCoordinator:toolsCoordinator]; |
95 [toolsCoordinator start]; | 103 [toolsCoordinator start]; |
96 self.toolsMenuCoordinator = toolsCoordinator; | 104 self.toolsMenuCoordinator = toolsCoordinator; |
97 } | 105 } |
98 | 106 |
99 - (void)closeToolsMenu { | 107 - (void)closeToolsMenu { |
(...skipping 15 matching lines...) Expand all Loading... |
115 - (void)stopLoadingPage { | 123 - (void)stopLoadingPage { |
116 self.webState->Stop(); | 124 self.webState->Stop(); |
117 } | 125 } |
118 | 126 |
119 - (void)reloadPage { | 127 - (void)reloadPage { |
120 self.webState->GetNavigationManager()->Reload(web::ReloadType::NORMAL, | 128 self.webState->GetNavigationManager()->Reload(web::ReloadType::NORMAL, |
121 false /*check_for_repost*/); | 129 false /*check_for_repost*/); |
122 } | 130 } |
123 | 131 |
124 @end | 132 @end |
OLD | NEW |