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/tab_grid/tab_grid_coordinator.h" | 5 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_coordinator.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
10 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 10 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
11 #import "ios/clean/chrome/browser/ui/commands/settings_commands.h" | 11 #import "ios/clean/chrome/browser/ui/commands/settings_commands.h" |
12 #import "ios/clean/chrome/browser/ui/commands/tab_commands.h" | 12 #import "ios/clean/chrome/browser/ui/commands/tab_commands.h" |
13 #import "ios/clean/chrome/browser/ui/commands/tab_grid_commands.h" | 13 #import "ios/clean/chrome/browser/ui/commands/tab_grid_commands.h" |
14 #import "ios/clean/chrome/browser/ui/settings/settings_coordinator.h" | 14 #import "ios/clean/chrome/browser/ui/settings/settings_coordinator.h" |
15 #import "ios/clean/chrome/browser/ui/tab/tab_coordinator.h" | 15 #import "ios/clean/chrome/browser/ui/tab/tab_coordinator.h" |
16 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_mediator.h" | 16 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_mediator.h" |
17 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_view_controller.h" | 17 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_view_controller.h" |
18 #import "ios/shared/chrome/browser/coordinator_context/coordinator_context.h" | 18 #import "ios/shared/chrome/browser/coordinator_context/coordinator_context.h" |
19 #import "ios/shared/chrome/browser/tabs/web_state_list.h" | 19 #import "ios/shared/chrome/browser/tabs/web_state_list.h" |
20 #import "ios/shared/chrome/browser/ui/browser_list/browser.h" | 20 #import "ios/shared/chrome/browser/ui/browser_list/browser.h" |
21 #import "ios/shared/chrome/browser/ui/commands/command_dispatcher.h" | |
21 #import "ios/shared/chrome/browser/ui/coordinators/browser_coordinator+internal. h" | 22 #import "ios/shared/chrome/browser/ui/coordinators/browser_coordinator+internal. h" |
22 #import "ios/web/public/navigation_manager.h" | 23 #import "ios/web/public/navigation_manager.h" |
23 #include "ios/web/public/web_state/web_state.h" | 24 #include "ios/web/public/web_state/web_state.h" |
24 #import "net/base/mac/url_conversions.h" | 25 #import "net/base/mac/url_conversions.h" |
25 #include "ui/base/page_transition_types.h" | 26 #include "ui/base/page_transition_types.h" |
26 | 27 |
27 #if !defined(__has_feature) || !__has_feature(objc_arc) | 28 #if !defined(__has_feature) || !__has_feature(objc_arc) |
28 #error "This file requires ARC support." | 29 #error "This file requires ARC support." |
29 #endif | 30 #endif |
30 | 31 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 // This object should only ever have at most one child. | 117 // This object should only ever have at most one child. |
117 DCHECK_LE(self.children.count, 1UL); | 118 DCHECK_LE(self.children.count, 1UL); |
118 BrowserCoordinator* child = [self.children anyObject]; | 119 BrowserCoordinator* child = [self.children anyObject]; |
119 [child stop]; | 120 [child stop]; |
120 [self removeChildCoordinator:child]; | 121 [self removeChildCoordinator:child]; |
121 } | 122 } |
122 | 123 |
123 #pragma mark - SettingsCommands | 124 #pragma mark - SettingsCommands |
124 | 125 |
125 - (void)showSettings { | 126 - (void)showSettings { |
127 CommandDispatcher* dispatcher = self.browser->dispatcher(); | |
128 [dispatcher startDispatchingToTarget:self | |
129 forSelector:@selector(closeSettings)]; | |
126 SettingsCoordinator* settingsCoordinator = [[SettingsCoordinator alloc] init]; | 130 SettingsCoordinator* settingsCoordinator = [[SettingsCoordinator alloc] init]; |
127 settingsCoordinator.settingsCommandHandler = self; | |
128 [self addOverlayCoordinator:settingsCoordinator]; | 131 [self addOverlayCoordinator:settingsCoordinator]; |
129 self.settingsCoordinator = settingsCoordinator; | 132 self.settingsCoordinator = settingsCoordinator; |
130 [settingsCoordinator start]; | 133 [settingsCoordinator start]; |
131 } | 134 } |
132 | 135 |
133 - (void)closeSettings { | 136 - (void)closeSettings { |
137 CommandDispatcher* dispatcher = self.browser->dispatcher(); | |
138 [dispatcher stopDispatchingToTarget:self]; | |
lpromero
2017/03/29 17:48:46
This will be problematic if this controller starts
marq (ping after 24h)
2017/03/30 07:53:33
Yes, or maybe (also?) -stopDispatchingToTarget:for
lpromero
2017/03/30 11:45:26
Done for the individual method. I don't pass the t
| |
134 [self.settingsCoordinator stop]; | 139 [self.settingsCoordinator stop]; |
135 [self.settingsCoordinator.parentCoordinator | 140 [self.settingsCoordinator.parentCoordinator |
136 removeChildCoordinator:self.settingsCoordinator]; | 141 removeChildCoordinator:self.settingsCoordinator]; |
137 // self.settingsCoordinator should be presumed to be nil after this point. | 142 // self.settingsCoordinator should be presumed to be nil after this point. |
138 } | 143 } |
139 | 144 |
140 #pragma mark - URLOpening | 145 #pragma mark - URLOpening |
141 | 146 |
142 - (void)openURL:(NSURL*)URL { | 147 - (void)openURL:(NSURL*)URL { |
143 if (self.webStateList.active_index() == WebStateList::kInvalidIndex) { | 148 if (self.webStateList.active_index() == WebStateList::kInvalidIndex) { |
144 return; | 149 return; |
145 } | 150 } |
146 [self.overlayCoordinator stop]; | 151 [self.overlayCoordinator stop]; |
147 [self removeOverlayCoordinator]; | 152 [self removeOverlayCoordinator]; |
148 web::WebState* activeWebState = self.webStateList.GetActiveWebState(); | 153 web::WebState* activeWebState = self.webStateList.GetActiveWebState(); |
149 web::NavigationManager::WebLoadParams params(net::GURLWithNSURL(URL)); | 154 web::NavigationManager::WebLoadParams params(net::GURLWithNSURL(URL)); |
150 params.transition_type = ui::PAGE_TRANSITION_LINK; | 155 params.transition_type = ui::PAGE_TRANSITION_LINK; |
151 activeWebState->GetNavigationManager()->LoadURLWithParams(params); | 156 activeWebState->GetNavigationManager()->LoadURLWithParams(params); |
152 if (!self.children.count) { | 157 if (!self.children.count) { |
153 [self showTabAtIndex:self.webStateList.active_index()]; | 158 [self showTabAtIndex:self.webStateList.active_index()]; |
154 } | 159 } |
155 } | 160 } |
156 | 161 |
157 @end | 162 @end |
OLD | NEW |