Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Unified Diff: ios/clean/chrome/browser/ui/tab/tab_coordinator.mm

Issue 2785893003: [ios clean] Add placeholder for NTP bookmarks, chrome home and open tabs. (Closed)
Patch Set: Rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..3f57ec3758a5687fd48d18b411bd79f9d40d860d 100644
--- a/ios/clean/chrome/browser/ui/tab/tab_coordinator.mm
+++ b/ios/clean/chrome/browser/ui/tab/tab_coordinator.mm
@@ -9,12 +9,15 @@
#include "base/mac/foundation_util.h"
#include "base/memory/ptr_util.h"
#import "ios/clean/chrome/browser/ui/animators/zoom_transition_animator.h"
-#import "ios/clean/chrome/browser/ui/ntp/new_tab_page_coordinator.h"
+#import "ios/clean/chrome/browser/ui/commands/tab_commands.h"
+#import "ios/clean/chrome/browser/ui/ntp/ntp_coordinator.h"
#import "ios/clean/chrome/browser/ui/tab/tab_container_view_controller.h"
#import "ios/clean/chrome/browser/ui/tab_strip/tab_strip_coordinator.h"
#import "ios/clean/chrome/browser/ui/toolbar/toolbar_coordinator.h"
#import "ios/clean/chrome/browser/ui/web_contents/web_coordinator.h"
#import "ios/shared/chrome/browser/coordinator_context/coordinator_context.h"
+#import "ios/shared/chrome/browser/ui/browser_list/browser.h"
+#import "ios/shared/chrome/browser/ui/commands/command_dispatcher.h"
#import "ios/shared/chrome/browser/ui/coordinators/browser_coordinator+internal.h"
#import "ios/web/public/web_state/web_state.h"
#import "ios/web/public/web_state/web_state_observer_bridge.h"
@@ -30,8 +33,11 @@ const BOOL kUseBottomToolbar = NO;
} // namespace
@interface TabCoordinator ()<CRWWebStateObserver,
+ TabCommands,
UIViewControllerTransitioningDelegate>
@property(nonatomic, strong) TabContainerViewController* viewController;
+@property(nonatomic, weak) NTPCoordinator* ntpCoordinator;
+@property(nonatomic, weak) WebCoordinator* webCoordinator;
@end
@implementation TabCoordinator {
@@ -41,6 +47,8 @@ const BOOL kUseBottomToolbar = NO;
@synthesize presentationKey = _presentationKey;
@synthesize viewController = _viewController;
@synthesize webState = _webState;
+@synthesize webCoordinator = _webCoordinator;
+@synthesize ntpCoordinator = _ntpCoordinator;
#pragma mark - BrowserCoordinator
@@ -51,6 +59,10 @@ const BOOL kUseBottomToolbar = NO;
_webStateObserver =
base::MakeUnique<web::WebStateObserverBridge>(self.webState, self);
+ CommandDispatcher* dispatcher = self.browser->dispatcher();
+ // TabCommands
+ [dispatcher startDispatchingToTarget:self forSelector:@selector(loadURL:)];
+
WebCoordinator* webCoordinator = [[WebCoordinator alloc] init];
webCoordinator.webState = self.webState;
[self addChildCoordinator:webCoordinator];
@@ -58,6 +70,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 +86,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.
+ if (self.webState->GetLastCommittedURL() == GURL("chrome://newtab/")) {
marq (ping after 24h) 2017/04/07 12:25:01 Use kChromeUINewTabURL from ios/chrome/browser/chr
justincohen 2017/04/07 15:27:30 Done.
+ self.viewController.contentViewController =
+ self.ntpCoordinator.viewController;
+ }
+
[self.context.baseViewController presentViewController:self.viewController
animated:self.context.animated
completion:nil];
+
[super start];
}
@@ -86,6 +109,7 @@ const BOOL kUseBottomToolbar = NO;
for (BrowserCoordinator* child in self.children) {
[child stop];
}
+
[self.viewController.presentingViewController
dismissViewControllerAnimated:self.context.animated
completion:nil];
@@ -99,9 +123,15 @@ 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;
}
}
+- (void)childCoordinatorWillStop:(BrowserCoordinator*)childCoordinator {
+ self.viewController.contentViewController = nil;
+}
+
- (BOOL)canAddOverlayCoordinator:(BrowserCoordinator*)overlayCoordinator {
// This coordinator will always accept overlay coordinators.
return YES;
@@ -130,7 +160,17 @@ const BOOL kUseBottomToolbar = NO;
[self addChildCoordinator:ntpCoordinator];
ntpCoordinator.context.baseViewController = nil;
[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;
}
}
@@ -156,4 +196,10 @@ animationControllerForDismissedController:(UIViewController*)dismissed {
return animator;
}
+#pragma mark - TabCommands
+
+- (void)loadURL:(web::NavigationManager::WebLoadParams)params {
+ self.webState->GetNavigationManager()->LoadURLWithParams(params);
+}
+
@end

Powered by Google App Engine
This is Rietveld 408576698