Commit ab7c15df authored by Mark Cogan's avatar Mark Cogan Committed by Commit Bot

[iOS] TabSwitcher cleanup, part one

This CL starts to clean up the TabSwitcher interactions. It:

- removes unused methods from TabSwitcher
- Clarifies in MainController that the tab switcher is always the tab grid.
- Factors away the dismissTabSwitcherWithoutAnimationInModel: method in MainController, which was only called from one place.
- Removes a call to displayCurrentBVCAndFocusOmnibox: which was always a no-op for the tab grid.

Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
Change-Id: Id911796f0e0d419da79aaf2181c7adca64f6c558
Reviewed-on: https://chromium-review.googlesource.com/c/1249088Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Mark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601587}
parent 7acd0b52
......@@ -7,9 +7,7 @@
#import <UIKit/UIKit.h>
@protocol TabSwitcher;
// Handles TabSwitcher interactions.
// Handles opening tabs from the tab switcher.
@protocol TabSwitching<NSObject>
// Opens a new tab with animation if presenting the tab switcher.
......
......@@ -325,7 +325,7 @@ enum class ShowTabSwitcherSnapshotResult {
// Coordinator to display the Google services settings.
GoogleServicesNavigationCoordinator* _googleServicesNavigationCoordinator;
// TabSwitcher object -- the stack view, tablet switcher, etc.
// TabSwitcher object -- the tab grid.
id<TabSwitcher> _tabSwitcher;
// YES while animating the dismissal of tab switcher.
......@@ -424,8 +424,6 @@ enum class ShowTabSwitcherSnapshotResult {
- (void)showTabSwitcher;
// Starts a voice search on the current BVC.
- (void)startVoiceSearchInCurrentBVC;
// Dismisses the tab switcher UI without animation into the given model.
- (void)dismissTabSwitcherWithoutAnimationInModel:(TabModel*)tabModel;
// Dismisses |signinInteractionCoordinator|.
- (void)dismissSigninInteractionCoordinator;
// Called when the last incognito tab was closed.
......@@ -1295,8 +1293,12 @@ enum class ShowTabSwitcherSnapshotResult {
tabModel = mainTabModel;
self.currentBVC = self.mainBVC;
}
if (_tabSwitcherIsActive)
[self dismissTabSwitcherWithoutAnimationInModel:self.mainTabModel];
if (_tabSwitcherIsActive) {
DCHECK(!_dismissingTabSwitcher);
[self beginDismissingTabSwitcherWithCurrentModel:self.mainTabModel
focusOmnibox:NO];
[self finishDismissingTabSwitcher];
}
if (firstRun || [self shouldOpenNTPTabOnActivationOfTabModel:tabModel]) {
OpenNewTabCommand* command = [OpenNewTabCommand
commandWithIncognito:(self.currentBVC == self.otrBVC)];
......@@ -2050,19 +2052,6 @@ enum class ShowTabSwitcherSnapshotResult {
return YES;
}
- (void)dismissTabSwitcherWithoutAnimationInModel:(TabModel*)tabModel {
DCHECK(_tabSwitcherIsActive);
DCHECK(!_dismissingTabSwitcher);
if ([_tabSwitcher respondsToSelector:@selector
(tabSwitcherDismissWithModel:animated:)]) {
[self dismissModalDialogsWithCompletion:nil dismissOmnibox:YES];
[_tabSwitcher tabSwitcherDismissWithModel:tabModel animated:NO];
} else {
[self beginDismissingTabSwitcherWithCurrentModel:tabModel focusOmnibox:NO];
[self finishDismissingTabSwitcher];
}
}
#pragma mark - TabSwitcherDelegate
- (void)tabSwitcher:(id<TabSwitcher>)tabSwitcher
......@@ -2108,9 +2097,6 @@ enum class ShowTabSwitcherSnapshotResult {
_modeToDisplayOnTabSwitcherDismissal = TabSwitcherDismissalMode::NONE;
// Displaying the current BVC dismisses the tab switcher.
[self displayCurrentBVCAndFocusOmnibox:NO];
ProceduralBlock action = [self completionBlockForTriggeringAction:
self.NTPActionAfterTabSwitcherDismissal];
self.NTPActionAfterTabSwitcherDismissal = NO_ACTION;
......
......@@ -14,7 +14,6 @@
@protocol OmniboxFocuser;
@class Tab;
@class TabModel;
@class TabSwitcherTransitionContext;
@protocol TabSwitcher;
@protocol ToolbarCommands;
......@@ -23,30 +22,18 @@
// is a good example of the implementation of this delegate.
@protocol TabSwitcherDelegate<NSObject>
// Informs the delegate the stack controller should be dismissed with the given
// Informs the delegate the tab switcher should be dismissed with the given
// active model.
- (void)tabSwitcher:(id<TabSwitcher>)tabSwitcher
shouldFinishWithActiveModel:(TabModel*)tabModel
focusOmnibox:(BOOL)focusOmnibox;
// Informs the delegate that the stack controller is done and should be
// Informs the delegate that the tab switcher is done and should be
// dismissed.
- (void)tabSwitcherDismissTransitionDidEnd:(id<TabSwitcher>)tabSwitcher;
@end
// This delegate is used to inform a transition animator object when the
// presentation and dismissal animations finish.
@protocol TabSwitcherAnimationDelegate<NSObject>
// Informs the delegate that a TabSwitcher presentation animation has completed.
- (void)tabSwitcherPresentationAnimationDidEnd:(id<TabSwitcher>)tabSwitcher;
// Informs the delegate that a TabSwitcher dismissal animation has completed.
- (void)tabSwitcherDismissalAnimationDidEnd:(id<TabSwitcher>)tabSwitcher;
@end
// This protocol describes the common interface between the two implementations
// of the tab switcher. StackViewController for iPhone and TabSwitcherController
// for iPad are examples of implementers of this protocol.
......@@ -55,7 +42,6 @@
// This delegate must be set on the tab switcher in order to drive the tab
// switcher.
@property(nonatomic, weak) id<TabSwitcherDelegate> delegate;
@property(nonatomic, weak) id<TabSwitcherAnimationDelegate> animationDelegate;
// Dispatcher for anything that acts in a "browser" role.
@property(nonatomic, readonly)
......@@ -73,14 +59,6 @@
// Returns the view controller that displays the tab switcher.
- (UIViewController*)viewController;
// Tells the tab switcher to prepare to be displayed at |size|.
- (void)prepareForDisplayAtSize:(CGSize)size;
// Performs an animation of the selected tab from its presented state to its
// place in the tab switcher. Should be called after the tab switcher's view has
// been presented.
- (void)showWithSelectedTabAnimation;
// Create a new tab in |targetModel| with the url |url| at |position|, using
// page transition |transition|. Implementors are expected to also
// perform an animation from the selected tab in the tab switcher to the
......@@ -100,13 +78,6 @@
// the incognito browser state is deleted.
- (void)setOtrTabModel:(TabModel*)otrModel;
@optional
@property(nonatomic, retain) TabSwitcherTransitionContext* transitionContext;
// Dismisses the tab switcher using the given tab model. The dismissal of the
// tab switcher will be animated if the |animated| parameter is set to YES.
- (void)tabSwitcherDismissWithModel:(TabModel*)model animated:(BOOL)animated;
@end
#endif // IOS_CHROME_BROWSER_UI_MAIN_TAB_SWITCHER_H_
......@@ -13,7 +13,7 @@
@protocol TabGridPaging;
@class TabGridURLLoader;
// An opque adaptor for the TabSwitcher protocol into the TabGrid.
// An opaque adaptor for the TabSwitcher protocol into the TabGrid.
// Consuming objects should be passed instances of this object as an
// id<TabSwitcher>.
// All of the methods and properties on this class are internal API fot the
......
......@@ -20,7 +20,6 @@
@implementation TabGridAdaptor
// TabSwitcher properties.
@synthesize delegate = _delegate;
@synthesize animationDelegate = _animationDelegate;
// Public properties
@synthesize tabGridViewController = _tabGridViewController;
@synthesize adaptedDispatcher = _adaptedDispatcher;
......@@ -35,13 +34,6 @@
self.adaptedDispatcher);
}
- (void)setAnimationDelegate:
(id<TabSwitcherAnimationDelegate>)animationDelegate {
NOTREACHED()
<< "The tab grid shouldn't need a tab switcher animation delegate.";
_animationDelegate = nil;
}
- (void)restoreInternalStateWithMainTabModel:(TabModel*)mainModel
otrTabModel:(TabModel*)otrModel
activeTabModel:(TabModel*)activeModel {
......@@ -54,14 +46,6 @@
}
}
- (void)prepareForDisplayAtSize:(CGSize)size {
NOTREACHED();
}
- (void)showWithSelectedTabAnimation {
NOTREACHED();
}
- (UIViewController*)viewController {
return self.tabGridViewController;
}
......@@ -100,8 +84,4 @@
self.loader.incognitoBrowserState = otrModel.browserState;
}
- (void)setTransitionContext:(TabSwitcherTransitionContext*)transitionContext {
// No-op. Tab grid will not use this iPad TabSwitcher-specific mechanism.
}
@end
......@@ -72,7 +72,7 @@ class TabGridCoordinatorTest : public BlockCleanupTest {
}
protected:
// The MainPresentingViewController that is under test. The test fixture sets
// The TabGridCoordinator that is under test. The test fixture sets
// this VC as the root VC for the window.
TabGridCoordinator* coordinator_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment