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 @@ ...@@ -7,9 +7,7 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@protocol TabSwitcher; // Handles opening tabs from the tab switcher.
// Handles TabSwitcher interactions.
@protocol TabSwitching<NSObject> @protocol TabSwitching<NSObject>
// Opens a new tab with animation if presenting the tab switcher. // Opens a new tab with animation if presenting the tab switcher.
......
...@@ -325,7 +325,7 @@ enum class ShowTabSwitcherSnapshotResult { ...@@ -325,7 +325,7 @@ enum class ShowTabSwitcherSnapshotResult {
// Coordinator to display the Google services settings. // Coordinator to display the Google services settings.
GoogleServicesNavigationCoordinator* _googleServicesNavigationCoordinator; GoogleServicesNavigationCoordinator* _googleServicesNavigationCoordinator;
// TabSwitcher object -- the stack view, tablet switcher, etc. // TabSwitcher object -- the tab grid.
id<TabSwitcher> _tabSwitcher; id<TabSwitcher> _tabSwitcher;
// YES while animating the dismissal of tab switcher. // YES while animating the dismissal of tab switcher.
...@@ -424,8 +424,6 @@ enum class ShowTabSwitcherSnapshotResult { ...@@ -424,8 +424,6 @@ enum class ShowTabSwitcherSnapshotResult {
- (void)showTabSwitcher; - (void)showTabSwitcher;
// Starts a voice search on the current BVC. // Starts a voice search on the current BVC.
- (void)startVoiceSearchInCurrentBVC; - (void)startVoiceSearchInCurrentBVC;
// Dismisses the tab switcher UI without animation into the given model.
- (void)dismissTabSwitcherWithoutAnimationInModel:(TabModel*)tabModel;
// Dismisses |signinInteractionCoordinator|. // Dismisses |signinInteractionCoordinator|.
- (void)dismissSigninInteractionCoordinator; - (void)dismissSigninInteractionCoordinator;
// Called when the last incognito tab was closed. // Called when the last incognito tab was closed.
...@@ -1295,8 +1293,12 @@ enum class ShowTabSwitcherSnapshotResult { ...@@ -1295,8 +1293,12 @@ enum class ShowTabSwitcherSnapshotResult {
tabModel = mainTabModel; tabModel = mainTabModel;
self.currentBVC = self.mainBVC; self.currentBVC = self.mainBVC;
} }
if (_tabSwitcherIsActive) if (_tabSwitcherIsActive) {
[self dismissTabSwitcherWithoutAnimationInModel:self.mainTabModel]; DCHECK(!_dismissingTabSwitcher);
[self beginDismissingTabSwitcherWithCurrentModel:self.mainTabModel
focusOmnibox:NO];
[self finishDismissingTabSwitcher];
}
if (firstRun || [self shouldOpenNTPTabOnActivationOfTabModel:tabModel]) { if (firstRun || [self shouldOpenNTPTabOnActivationOfTabModel:tabModel]) {
OpenNewTabCommand* command = [OpenNewTabCommand OpenNewTabCommand* command = [OpenNewTabCommand
commandWithIncognito:(self.currentBVC == self.otrBVC)]; commandWithIncognito:(self.currentBVC == self.otrBVC)];
...@@ -2050,19 +2052,6 @@ enum class ShowTabSwitcherSnapshotResult { ...@@ -2050,19 +2052,6 @@ enum class ShowTabSwitcherSnapshotResult {
return YES; 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 #pragma mark - TabSwitcherDelegate
- (void)tabSwitcher:(id<TabSwitcher>)tabSwitcher - (void)tabSwitcher:(id<TabSwitcher>)tabSwitcher
...@@ -2108,9 +2097,6 @@ enum class ShowTabSwitcherSnapshotResult { ...@@ -2108,9 +2097,6 @@ enum class ShowTabSwitcherSnapshotResult {
_modeToDisplayOnTabSwitcherDismissal = TabSwitcherDismissalMode::NONE; _modeToDisplayOnTabSwitcherDismissal = TabSwitcherDismissalMode::NONE;
// Displaying the current BVC dismisses the tab switcher.
[self displayCurrentBVCAndFocusOmnibox:NO];
ProceduralBlock action = [self completionBlockForTriggeringAction: ProceduralBlock action = [self completionBlockForTriggeringAction:
self.NTPActionAfterTabSwitcherDismissal]; self.NTPActionAfterTabSwitcherDismissal];
self.NTPActionAfterTabSwitcherDismissal = NO_ACTION; self.NTPActionAfterTabSwitcherDismissal = NO_ACTION;
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
@protocol OmniboxFocuser; @protocol OmniboxFocuser;
@class Tab; @class Tab;
@class TabModel; @class TabModel;
@class TabSwitcherTransitionContext;
@protocol TabSwitcher; @protocol TabSwitcher;
@protocol ToolbarCommands; @protocol ToolbarCommands;
...@@ -23,30 +22,18 @@ ...@@ -23,30 +22,18 @@
// is a good example of the implementation of this delegate. // is a good example of the implementation of this delegate.
@protocol TabSwitcherDelegate<NSObject> @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. // active model.
- (void)tabSwitcher:(id<TabSwitcher>)tabSwitcher - (void)tabSwitcher:(id<TabSwitcher>)tabSwitcher
shouldFinishWithActiveModel:(TabModel*)tabModel shouldFinishWithActiveModel:(TabModel*)tabModel
focusOmnibox:(BOOL)focusOmnibox; 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. // dismissed.
- (void)tabSwitcherDismissTransitionDidEnd:(id<TabSwitcher>)tabSwitcher; - (void)tabSwitcherDismissTransitionDidEnd:(id<TabSwitcher>)tabSwitcher;
@end @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 // This protocol describes the common interface between the two implementations
// of the tab switcher. StackViewController for iPhone and TabSwitcherController // of the tab switcher. StackViewController for iPhone and TabSwitcherController
// for iPad are examples of implementers of this protocol. // for iPad are examples of implementers of this protocol.
...@@ -55,7 +42,6 @@ ...@@ -55,7 +42,6 @@
// This delegate must be set on the tab switcher in order to drive the tab // This delegate must be set on the tab switcher in order to drive the tab
// switcher. // switcher.
@property(nonatomic, weak) id<TabSwitcherDelegate> delegate; @property(nonatomic, weak) id<TabSwitcherDelegate> delegate;
@property(nonatomic, weak) id<TabSwitcherAnimationDelegate> animationDelegate;
// Dispatcher for anything that acts in a "browser" role. // Dispatcher for anything that acts in a "browser" role.
@property(nonatomic, readonly) @property(nonatomic, readonly)
...@@ -73,14 +59,6 @@ ...@@ -73,14 +59,6 @@
// Returns the view controller that displays the tab switcher. // Returns the view controller that displays the tab switcher.
- (UIViewController*)viewController; - (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 // Create a new tab in |targetModel| with the url |url| at |position|, using
// page transition |transition|. Implementors are expected to also // page transition |transition|. Implementors are expected to also
// perform an animation from the selected tab in the tab switcher to the // perform an animation from the selected tab in the tab switcher to the
...@@ -100,13 +78,6 @@ ...@@ -100,13 +78,6 @@
// the incognito browser state is deleted. // the incognito browser state is deleted.
- (void)setOtrTabModel:(TabModel*)otrModel; - (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 @end
#endif // IOS_CHROME_BROWSER_UI_MAIN_TAB_SWITCHER_H_ #endif // IOS_CHROME_BROWSER_UI_MAIN_TAB_SWITCHER_H_
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
@protocol TabGridPaging; @protocol TabGridPaging;
@class TabGridURLLoader; @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 // Consuming objects should be passed instances of this object as an
// id<TabSwitcher>. // id<TabSwitcher>.
// All of the methods and properties on this class are internal API fot the // All of the methods and properties on this class are internal API fot the
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
@implementation TabGridAdaptor @implementation TabGridAdaptor
// TabSwitcher properties. // TabSwitcher properties.
@synthesize delegate = _delegate; @synthesize delegate = _delegate;
@synthesize animationDelegate = _animationDelegate;
// Public properties // Public properties
@synthesize tabGridViewController = _tabGridViewController; @synthesize tabGridViewController = _tabGridViewController;
@synthesize adaptedDispatcher = _adaptedDispatcher; @synthesize adaptedDispatcher = _adaptedDispatcher;
...@@ -35,13 +34,6 @@ ...@@ -35,13 +34,6 @@
self.adaptedDispatcher); 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 - (void)restoreInternalStateWithMainTabModel:(TabModel*)mainModel
otrTabModel:(TabModel*)otrModel otrTabModel:(TabModel*)otrModel
activeTabModel:(TabModel*)activeModel { activeTabModel:(TabModel*)activeModel {
...@@ -54,14 +46,6 @@ ...@@ -54,14 +46,6 @@
} }
} }
- (void)prepareForDisplayAtSize:(CGSize)size {
NOTREACHED();
}
- (void)showWithSelectedTabAnimation {
NOTREACHED();
}
- (UIViewController*)viewController { - (UIViewController*)viewController {
return self.tabGridViewController; return self.tabGridViewController;
} }
...@@ -100,8 +84,4 @@ ...@@ -100,8 +84,4 @@
self.loader.incognitoBrowserState = otrModel.browserState; self.loader.incognitoBrowserState = otrModel.browserState;
} }
- (void)setTransitionContext:(TabSwitcherTransitionContext*)transitionContext {
// No-op. Tab grid will not use this iPad TabSwitcher-specific mechanism.
}
@end @end
...@@ -72,7 +72,7 @@ class TabGridCoordinatorTest : public BlockCleanupTest { ...@@ -72,7 +72,7 @@ class TabGridCoordinatorTest : public BlockCleanupTest {
} }
protected: 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. // this VC as the root VC for the window.
TabGridCoordinator* coordinator_; 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