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

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: Comment nit 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
« no previous file with comments | « ios/clean/chrome/browser/ui/tab/BUILD.gn ('k') | ios/clean/chrome/browser/ui/web_contents/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 faf15db3dab3897ec8370185d6179454d6d03511..8fe33ea895b431b8b23caa2ef362ecbdb2ab95f1 100644
--- a/ios/clean/chrome/browser/ui/tab/tab_coordinator.mm
+++ b/ios/clean/chrome/browser/ui/tab/tab_coordinator.mm
@@ -8,12 +8,16 @@
#include "base/mac/foundation_util.h"
#include "base/memory/ptr_util.h"
+#include "ios/chrome/browser/chrome_url_constants.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/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"
@@ -29,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 {
@@ -40,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
@@ -50,10 +59,15 @@ 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];
[webCoordinator start];
+ self.webCoordinator = webCoordinator;
ToolbarCoordinator* toolbarCoordinator = [[ToolbarCoordinator alloc] init];
toolbarCoordinator.webState = self.webState;
@@ -64,6 +78,15 @@ const BOOL kUseBottomToolbar = NO;
[self addChildCoordinator:tabStripCoordinator];
[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(kChromeUINewTabURL)) {
+ self.viewController.contentViewController =
+ self.ntpCoordinator.viewController;
+ }
+
[super start];
}
@@ -75,6 +98,7 @@ const BOOL kUseBottomToolbar = NO;
[child stop];
}
_webStateObserver.reset();
+ [self.browser->dispatcher() stopDispatchingToTarget:self];
}
- (void)childCoordinatorDidStart:(BrowserCoordinator*)childCoordinator {
@@ -89,6 +113,10 @@ const BOOL kUseBottomToolbar = NO;
}
}
+- (void)childCoordinatorWillStop:(BrowserCoordinator*)childCoordinator {
+ self.viewController.contentViewController = nil;
+}
+
- (BOOL)canAddOverlayCoordinator:(BrowserCoordinator*)overlayCoordinator {
// This coordinator will always accept overlay coordinators.
return YES;
@@ -112,10 +140,21 @@ const BOOL kUseBottomToolbar = NO;
// optimization in some equivalent to loadURL.
- (void)webState:(web::WebState*)webState
didCommitNavigationWithDetails:(const web::LoadCommittedDetails&)details {
- if (webState->GetLastCommittedURL() == GURL("chrome://newtab/")) {
+ if (webState->GetLastCommittedURL() == GURL(kChromeUINewTabURL)) {
NTPCoordinator* ntpCoordinator = [[NTPCoordinator alloc] init];
[self addChildCoordinator:ntpCoordinator];
[ntpCoordinator start];
+ 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;
}
}
@@ -141,4 +180,10 @@ animationControllerForDismissedController:(UIViewController*)dismissed {
return animator;
}
+#pragma mark - TabCommands
+
+- (void)loadURL:(web::NavigationManager::WebLoadParams)params {
+ self.webState->GetNavigationManager()->LoadURLWithParams(params);
+}
+
@end
« no previous file with comments | « ios/clean/chrome/browser/ui/tab/BUILD.gn ('k') | ios/clean/chrome/browser/ui/web_contents/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698