OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/ntp/ntp_coordinator.h" | 5 #import "ios/clean/chrome/browser/ui/ntp/ntp_coordinator.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ios/chrome/browser/ui/ui_util.h" | 8 #include "ios/chrome/browser/ui/ui_util.h" |
9 #import "ios/clean/chrome/browser/ui/bookmarks/bookmarks_coordinator.h" | 9 #import "ios/clean/chrome/browser/ui/bookmarks/bookmarks_coordinator.h" |
10 #import "ios/clean/chrome/browser/ui/commands/ntp_commands.h" | 10 #import "ios/clean/chrome/browser/ui/commands/ntp_commands.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 @end | 26 @end |
27 | 27 |
28 @implementation NTPCoordinator | 28 @implementation NTPCoordinator |
29 @synthesize mediator = _mediator; | 29 @synthesize mediator = _mediator; |
30 @synthesize viewController = _viewController; | 30 @synthesize viewController = _viewController; |
31 | 31 |
32 - (void)start { | 32 - (void)start { |
33 self.viewController = [[NTPViewController alloc] init]; | 33 self.viewController = [[NTPViewController alloc] init]; |
34 self.mediator = [[NTPMediator alloc] initWithConsumer:self.viewController]; | 34 self.mediator = [[NTPMediator alloc] initWithConsumer:self.viewController]; |
35 | 35 |
36 CommandDispatcher* dispatcher = self.browser->dispatcher(); | |
37 // NTPCommands | 36 // NTPCommands |
38 [dispatcher startDispatchingToTarget:self | 37 [self.dispatcher startDispatchingToTarget:self |
39 forSelector:@selector(showNTPHomePanel)]; | 38 forSelector:@selector(showNTPHomePanel)]; |
40 [dispatcher startDispatchingToTarget:self | 39 [self.dispatcher startDispatchingToTarget:self |
41 forSelector:@selector(showNTPBookmarksPanel)]; | 40 forSelector:@selector(showNTPBookmarksPanel)]; |
42 [dispatcher startDispatchingToTarget:self | 41 [self.dispatcher startDispatchingToTarget:self |
43 forSelector:@selector(showNTPRecentTabsPanel)]; | 42 forSelector:@selector(showNTPRecentTabsPanel)]; |
44 self.viewController.dispatcher = static_cast<id>(self.browser->dispatcher()); | 43 self.viewController.dispatcher = self.callableDispatcher; |
45 [super start]; | 44 [super start]; |
46 } | 45 } |
47 | 46 |
48 - (void)stop { | 47 - (void)stop { |
49 [super stop]; | 48 [super stop]; |
50 [self.browser->dispatcher() stopDispatchingToTarget:self]; | 49 [self.dispatcher stopDispatchingToTarget:self]; |
51 } | 50 } |
52 | 51 |
53 - (void)childCoordinatorDidStart:(BrowserCoordinator*)coordinator { | 52 - (void)childCoordinatorDidStart:(BrowserCoordinator*)coordinator { |
54 if ([coordinator isKindOfClass:[NTPHomeCoordinator class]]) { | 53 if ([coordinator isKindOfClass:[NTPHomeCoordinator class]]) { |
55 self.viewController.homeViewController = coordinator.viewController; | 54 self.viewController.homeViewController = coordinator.viewController; |
56 | 55 |
57 } else if ([coordinator isKindOfClass:[BookmarksCoordinator class]]) { | 56 } else if ([coordinator isKindOfClass:[BookmarksCoordinator class]]) { |
58 if (IsIPadIdiom()) { | 57 if (IsIPadIdiom()) { |
59 self.viewController.bookmarksViewController = coordinator.viewController; | 58 self.viewController.bookmarksViewController = coordinator.viewController; |
60 } else { | 59 } else { |
(...skipping 28 matching lines...) Expand all Loading... |
89 } | 88 } |
90 | 89 |
91 - (void)showNTPRecentTabsPanel { | 90 - (void)showNTPRecentTabsPanel { |
92 RecentTabsCoordinator* panelCoordinator = | 91 RecentTabsCoordinator* panelCoordinator = |
93 [[RecentTabsCoordinator alloc] init]; | 92 [[RecentTabsCoordinator alloc] init]; |
94 [self addChildCoordinator:panelCoordinator]; | 93 [self addChildCoordinator:panelCoordinator]; |
95 [panelCoordinator start]; | 94 [panelCoordinator start]; |
96 } | 95 } |
97 | 96 |
98 @end | 97 @end |
OLD | NEW |