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

Unified Diff: ios/clean/chrome/browser/browser_coordinator.mm

Issue 2626033002: [Clean] Add unittest target and BrowserCoordinator tests. (Closed)
Patch Set: Review feedback. Created 3 years, 11 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/BUILD.gn ('k') | ios/clean/chrome/browser/browser_coordinator+internal.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/clean/chrome/browser/browser_coordinator.mm
diff --git a/ios/clean/chrome/browser/browser_coordinator.mm b/ios/clean/chrome/browser/browser_coordinator.mm
index 37c7928a0141b5260ea46b93fc05151e187a4a9e..42cd8a10d56ac280684d7b001e0ef18b6638f3da 100644
--- a/ios/clean/chrome/browser/browser_coordinator.mm
+++ b/ios/clean/chrome/browser/browser_coordinator.mm
@@ -63,9 +63,12 @@
}
- (void)addChildCoordinator:(BrowserCoordinator*)coordinator {
+ CHECK([self respondsToSelector:@selector(viewController)])
+ << "BrowserCoordinator implementations must provide a viewController "
+ "property.";
[self.childCoordinators addObject:coordinator];
- coordinator.browserState = self.browserState;
coordinator.parentCoordinator = self;
+ coordinator.browserState = self.browserState;
coordinator.rootViewController = self.viewController;
}
@@ -89,25 +92,36 @@
} else if (self.childCoordinators.count == 1) {
[[self.childCoordinators anyObject]
addOverlayCoordinator:overlayCoordinator];
- } else {
+ } else if (self.childCoordinators.count > 1) {
CHECK(NO) << "Coordinators with multiple children must explicitly "
<< "handle -addOverlayCoordinator: or return NO to "
<< "-canAddOverlayCoordinator:";
}
+ // If control reaches here, the terminal child of the coordinator hierarchy
+ // has returned NO to -canAddOverlayCoordinator, so no overlay can be added.
+ // This is by default a silent no-op.
}
- (void)removeOverlayCoordinator {
BrowserCoordinator* overlay = self.overlayCoordinator;
[overlay.parentCoordinator removeChildCoordinator:overlay];
+ overlay.overlaying = NO;
}
- (BOOL)canAddOverlayCoordinator:(BrowserCoordinator*)overlayCoordinator {
+ // By default, a hierarchy with an overlay can't add a new one.
+ // By default, coordinators with parents can't be added as overlays.
// By default, coordinators with no other children can add an overlay.
- return self.childCoordinators.count == 0;
+ return self.overlayCoordinator == nil &&
+ overlayCoordinator.parentCoordinator == nil &&
+ self.childCoordinators.count == 0;
}
- (void)removeChildCoordinator:(BrowserCoordinator*)coordinator {
+ if (![self.childCoordinators containsObject:coordinator])
+ return;
[self.childCoordinators removeObject:coordinator];
+ coordinator.parentCoordinator = nil;
}
@end
« no previous file with comments | « ios/clean/chrome/browser/BUILD.gn ('k') | ios/clean/chrome/browser/browser_coordinator+internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698