Index: ios/clean/chrome/browser/ui/tab/tab_coordinator.mm |
diff --git a/ios/clean/chrome/browser/ui/tab/tab_coordinator.mm b/ios/clean/chrome/browser/ui/tab/tab_coordinator.mm |
index 59497cb2e159e0165b1fa94e3b025c0ca8759c21..e96fac04c9e050c5bba7e7e33f9d0b34f4731e3d 100644 |
--- a/ios/clean/chrome/browser/ui/tab/tab_coordinator.mm |
+++ b/ios/clean/chrome/browser/ui/tab/tab_coordinator.mm |
@@ -32,6 +32,8 @@ const BOOL kUseBottomToolbar = NO; |
@interface TabCoordinator ()<CRWWebStateObserver, |
UIViewControllerTransitioningDelegate> |
@property(nonatomic, strong) TabContainerViewController* viewController; |
+@property(nonatomic, weak) NTPCoordinator* ntpCoordinator; |
+@property(nonatomic, weak) WebCoordinator* webCoordinator; |
@end |
@implementation TabCoordinator { |
@@ -41,6 +43,8 @@ const BOOL kUseBottomToolbar = NO; |
@synthesize presentationKey = _presentationKey; |
@synthesize viewController = _viewController; |
@synthesize webState = _webState; |
+@synthesize webCoordinator = _webCoordinator; |
+@synthesize ntpCoordinator = _ntpCoordinator; |
#pragma mark - BrowserCoordinator |
@@ -58,6 +62,7 @@ const BOOL kUseBottomToolbar = NO; |
// view controller. |
webCoordinator.context.baseViewController = nil; |
[webCoordinator start]; |
+ self.webCoordinator = webCoordinator; |
ToolbarCoordinator* toolbarCoordinator = [[ToolbarCoordinator alloc] init]; |
toolbarCoordinator.webState = self.webState; |
@@ -73,9 +78,19 @@ const BOOL kUseBottomToolbar = NO; |
tabStripCoordinator.context.baseViewController = nil; |
[tabStripCoordinator start]; |
+ // PLACEHOLDER: Fix the order of events here. The ntpCoordinator was already |
+ // created above when |webCoordinator.webState = self.webState;| triggers |
+ // a load event, but then the webCoordinator stomps on the |
+ // contentViewController when it starts afterwards. |
lpromero
2017/04/06 13:01:06
Should we then delay starting the webCoordinator t
justincohen
2017/04/06 18:25:11
Perhaps, saving for a followup.
|
+ if (self.webState->GetLastCommittedURL() == GURL("chrome://newtab/")) { |
+ self.viewController.contentViewController = |
+ self.ntpCoordinator.viewController; |
+ } |
+ |
[self.context.baseViewController presentViewController:self.viewController |
animated:self.context.animated |
completion:nil]; |
+ |
[super start]; |
} |
@@ -86,6 +101,9 @@ const BOOL kUseBottomToolbar = NO; |
for (BrowserCoordinator* child in self.children) { |
[child stop]; |
} |
+ |
+ [self.viewController setContentViewController:nil]; |
lpromero
2017/04/06 13:01:06
Use self.viewController.contentViewController = ni
lpromero
2017/04/06 13:01:06
Why this call? Seems like you expect a side effect
justincohen
2017/04/06 18:25:11
Done.
justincohen
2017/04/06 18:25:11
Moved to childCoordinatorWillStop
|
+ |
[self.viewController.presentingViewController |
dismissViewControllerAnimated:self.context.animated |
completion:nil]; |
@@ -99,6 +117,8 @@ const BOOL kUseBottomToolbar = NO; |
self.viewController.contentViewController = coordinator.viewController; |
} else if ([coordinator isKindOfClass:[TabStripCoordinator class]]) { |
self.viewController.tabStripViewController = coordinator.viewController; |
+ } else if ([coordinator isKindOfClass:[NTPCoordinator class]]) { |
+ self.viewController.contentViewController = coordinator.viewController; |
} |
} |
@@ -129,8 +149,19 @@ const BOOL kUseBottomToolbar = NO; |
NTPCoordinator* ntpCoordinator = [[NTPCoordinator alloc] init]; |
[self addChildCoordinator:ntpCoordinator]; |
ntpCoordinator.context.baseViewController = nil; |
+ ntpCoordinator.webState = self.webState; |
[ntpCoordinator start]; |
- self.viewController.contentViewController = ntpCoordinator.viewController; |
+ self.ntpCoordinator = ntpCoordinator; |
+ } |
+} |
+ |
+- (void)webState:(web::WebState*)webState |
+ didStartProvisionalNavigationForURL:(const GURL&)URL { |
+ if (self.ntpCoordinator) { |
+ [self.ntpCoordinator stop]; |
+ [self removeChildCoordinator:self.ntpCoordinator]; |
+ self.viewController.contentViewController = |
+ self.webCoordinator.viewController; |
} |
} |