Chromium Code Reviews| Index: ios/chrome/browser/ui/browser_view_controller.mm |
| diff --git a/ios/chrome/browser/ui/browser_view_controller.mm b/ios/chrome/browser/ui/browser_view_controller.mm |
| index f38c59b5587cf128b375369858b3fd2eba327e9d..d2956f91ef3579bdf82b960f0299d917365c752e 100644 |
| --- a/ios/chrome/browser/ui/browser_view_controller.mm |
| +++ b/ios/chrome/browser/ui/browser_view_controller.mm |
| @@ -115,7 +115,6 @@ |
| #import "ios/chrome/browser/ui/fullscreen_controller.h" |
| #import "ios/chrome/browser/ui/history/tab_history_cell.h" |
| #import "ios/chrome/browser/ui/key_commands_provider.h" |
| -#import "ios/chrome/browser/ui/no_tabs/no_tabs_controller.h" |
| #import "ios/chrome/browser/ui/ntp/new_tab_page_controller.h" |
| #import "ios/chrome/browser/ui/ntp/recent_tabs/recent_tabs_panel_view_controller.h" |
| #include "ios/chrome/browser/ui/omnibox/page_info_model.h" |
| @@ -239,9 +238,6 @@ void Record(NSInteger action, bool is_image, bool is_link) { |
| } |
| } |
| -// Duration to show or hide the No-Tabs UI. |
| -const NSTimeInterval kNoTabsAnimationDuration = 0.25; |
| - |
| const CGFloat kVoiceSearchBarHeight = 59.0; |
| // Dimensions to use when downsizing an image for search-by-image. |
| @@ -393,9 +389,6 @@ NSString* const kNativeControllerTemporaryKey = @"NativeControllerTemporaryKey"; |
| // Used to display the Find In Page UI. Nil if not visible. |
| base::scoped_nsobject<FindBarControllerIOS> _findBarController; |
| - // Used to display the No-Tabs UI for iPads. Nil if not visible. |
| - base::scoped_nsobject<NoTabsController> _noTabsController; |
| - |
| // Used to display the Print UI. Nil if not visible. |
| base::scoped_nsobject<PrintController> _printController; |
| @@ -450,10 +443,6 @@ NSString* const kNativeControllerTemporaryKey = @"NativeControllerTemporaryKey"; |
| // Card side swipe view. |
| base::scoped_nsobject<CardSideSwipeView> _sideSwipeView; |
| - // Used to cache value of |hasModeToggleSwitch| if set before the tab strip |
| - // controller has been created. |
| - BOOL _modeToggleNeedsSetting; |
| - |
| // Dominant color cache. Key: (NSString*)url, val: (UIColor*)dominantColor. |
| base::scoped_nsobject<NSMutableDictionary> _dominantColorCache; |
| @@ -586,11 +575,6 @@ NSString* const kNativeControllerTemporaryKey = @"NativeControllerTemporaryKey"; |
| // Initializes the bookmark interaction controller if not already initialized. |
| - (void)initializeBookmarkInteractionController; |
| -// Shows the No-Tabs UI with animation. |
| -- (void)showNoTabsUI; |
| -// Dismisses the No-Tabs UI with animation. |
| -- (void)dismissNoTabsUI; |
| - |
| // Shows the tools menu popup. |
| - (void)showToolsMenuPopup; |
| // Add all delegates to the provided |tab|. |
| @@ -965,27 +949,6 @@ class BrowserBookmarkModelBridge : public bookmarks::BookmarkModelObserver { |
| #pragma mark - Properties |
| -// Implements |hasModeToggleSwitch| property as pass-throughs to tab strip |
| -// controller and no-tabs controller. If set before the controller has been |
| -// created, cache it. |
| -- (void)setHasModeToggleSwitch:(BOOL)hasModeToggleSwitch { |
| - if (!experimental_flags::IsTabSwitcherEnabled()) { |
| - if (_tabStripController) |
| - _tabStripController.get().hasModeToggleSwitch = hasModeToggleSwitch; |
| - else |
| - _modeToggleNeedsSetting = hasModeToggleSwitch; |
| - } |
| - [_noTabsController setHasModeToggleSwitch:hasModeToggleSwitch]; |
| -} |
| - |
| -// Implements |hasModeToggleSwitch| property as pass-throughs to tab strip |
| -// controller, unless it hasn't been created in which return the cached version. |
| -- (BOOL)hasModeToggleSwitch { |
| - if (_tabStripController) |
| - return _tabStripController.get().hasModeToggleSwitch; |
| - return _modeToggleNeedsSetting; |
| -} |
| - |
| - (void)setActive:(BOOL)active { |
| if (_active == active) { |
| return; |
| @@ -1165,9 +1128,7 @@ class BrowserBookmarkModelBridge : public bookmarks::BookmarkModelObserver { |
| if (currentTab) { |
| BOOL isChromeScheme = |
| web::GetWebClient()->IsAppSpecificURL([currentTab url]); |
| - BOOL snapshotOnIpad = |
| - (!IsIPadIdiom() || experimental_flags::IsTabSwitcherEnabled()); |
| - if (snapshotOnIpad || !isChromeScheme) { |
| + if (!IsIPadIdiom() || !isChromeScheme) { |
|
rohitrao (ping after 24h)
2017/02/01 18:34:34
I believe under the old logic this was always true
jif
2017/02/03 12:55:51
Done.
|
| [currentTab updateSnapshotWithOverlay:YES visibleFrameOnly:YES]; |
| } |
| } |
| @@ -1235,7 +1196,7 @@ class BrowserBookmarkModelBridge : public bookmarks::BookmarkModelObserver { |
| self.visible = YES; |
| // Restore hidden infobars. |
| - if (IsIPadIdiom() && experimental_flags::IsTabSwitcherEnabled()) { |
| + if (IsIPadIdiom()) { |
| _infoBarContainer->RestoreInfobars(); |
| } |
| @@ -1256,7 +1217,7 @@ class BrowserBookmarkModelBridge : public bookmarks::BookmarkModelObserver { |
| [[_model currentTab] updateFullscreenWithToolbarVisible:YES]; |
| [[_model currentTab] wasHidden]; |
| [_bookmarkInteractionController dismissSnackbar]; |
| - if (IsIPadIdiom() && experimental_flags::IsTabSwitcherEnabled()) { |
| + if (IsIPadIdiom()) { |
| _infoBarContainer->SuspendInfobars(); |
| } |
| [super viewWillDisappear:animated]; |
| @@ -1312,7 +1273,6 @@ class BrowserBookmarkModelBridge : public bookmarks::BookmarkModelObserver { |
| _toolbarModelDelegate.reset(); |
| _toolbarModelIOS.reset(); |
| _tabStripController.reset(); |
| - _noTabsController.reset(); |
| _sideSwipeController.reset(); |
| } |
| } |
| @@ -1745,20 +1705,9 @@ class BrowserBookmarkModelBridge : public bookmarks::BookmarkModelObserver { |
| // If needed, create the tabstrip. |
| if (IsIPadIdiom()) { |
| - // Determine if it's incognito. Whether or not the toggle button is |
| - // visible is consolidated in logic elsewhere so it doesn't need to be set |
| - // here. |
| _tabStripController.reset( |
| [_dependencyFactory newTabStripControllerWithTabModel:_model]); |
| _tabStripController.get().fullscreenDelegate = self; |
| - [_tabStripController setHasTabSwitcherToggleSwitch: |
| - experimental_flags::IsTabSwitcherEnabled()]; |
| - |
| - // If set before the views are loaded, pass the mode toggle to the |
| - // toolbar controller (only needed if YES, defaults to NO). |
| - if (_modeToggleNeedsSetting) { |
| - _tabStripController.get().hasModeToggleSwitch = _modeToggleNeedsSetting; |
| - } |
| } |
| // Create infobar container. |
| @@ -1962,10 +1911,7 @@ class BrowserBookmarkModelBridge : public bookmarks::BookmarkModelObserver { |
| } |
| - (void)dismissPopups { |
| - if (_noTabsController.get()) |
| - [_noTabsController dismissToolsMenuPopup]; |
| - else |
| - [_toolbarController dismissToolsMenuPopup]; |
| + [_toolbarController dismissToolsMenuPopup]; |
| [self hidePageInfoPopupForView:nil]; |
| [_toolbarController dismissTabHistoryPopup]; |
| [[_model currentTab].webController recordStateInHistory]; |
| @@ -3268,98 +3214,11 @@ class BrowserBookmarkModelBridge : public bookmarks::BookmarkModelObserver { |
| } |
| } |
| -#pragma mark - No-tabs UI methods |
| - |
| -// Show the No-Tabs UI (hiding normal tab/web ui). |
| -- (void)showNoTabsUI { |
| - // The No-Tabs UI is only shown on tablet for non-incognito BVCs. (Incognito |
| - // mode does not have a No-Tabs UI; the user is simply shown the non-incognito |
| - // BVC when the last incognito tab is closed.) |
| - DCHECK(IsIPadIdiom()); |
| - DCHECK(!_isOffTheRecord); |
| - |
| - // The method showNoTabsUI is called asynchronously when the number of tabs |
| - // reaches zero. Do not show the no tabs UI if a tab was added in the mean |
| - // time. |
| - if ([_model count]) |
| - return; |
| - |
| - DCHECK([_model currentTab] == nil); |
| - DCHECK([_contentArea subviews].count == 0 || |
| - experimental_flags::IsTabSwitcherEnabled()); |
| - _noTabsController.reset([[NoTabsController alloc] initWithView:self.view]); |
| - |
| - // Close the tools popup menu if it is open, as its contents/location were |
| - // specific to being in the tabs UI. |
| - [_toolbarController dismissToolsMenuPopup]; |
| - |
| - // Immediately hide the web, toolbar, and tabstrip. |
| - [[_toolbarController view] setHidden:YES]; |
| - [[_tabStripController view] setHidden:YES]; |
| - |
| - // Set up the toggle switch animation, if needed. |
| - if ([self hasModeToggleSwitch]) { |
| - UIButton* animationStartButton = [_tabStripController modeToggleButton]; |
| - [_noTabsController installAnimationImageForButton:animationStartButton |
| - inView:self.view |
| - show:YES]; |
| - } |
| - |
| - [_noTabsController prepareForShowAnimation]; |
| - [UIView animateWithDuration:kNoTabsAnimationDuration |
| - animations:^{ |
| - [_noTabsController showNoTabsUI]; |
| - } |
| - completion:^(BOOL finished) { |
| - [_noTabsController showAnimationDidFinish]; |
| - [_noTabsController setHasModeToggleSwitch:[self hasModeToggleSwitch]]; |
| - }]; |
| -} |
| - |
| -// Hide the No-Tabs UI (restoring normal tab/web ui). |
| -- (void)dismissNoTabsUI { |
| - // The No-Tabs UI is only shown on tablet for non-incognito BVCs, so there is |
| - // no need to dismiss it for an incognito BVC. |
| - DCHECK(IsIPadIdiom()); |
| - if (_isOffTheRecord) |
| - return; |
| - |
| - // Set up the toggle switch animation, if needed. |
| - if ([self hasModeToggleSwitch]) { |
| - UIButton* animationEndButton = [_tabStripController modeToggleButton]; |
| - [_noTabsController installAnimationImageForButton:animationEndButton |
| - inView:self.view |
| - show:NO]; |
| - } |
| - |
| - [_noTabsController prepareForDismissAnimation]; |
| - |
| - // Pull the controller out of the scoped_nsobject so the animation blocks can |
| - // retain it. |
| - NoTabsController* noTabsController = _noTabsController.get(); |
| - [UIView animateWithDuration:kNoTabsAnimationDuration |
| - animations:^{ |
| - [noTabsController dismissNoTabsUI]; |
| - } |
| - completion:^(BOOL finished) { |
| - // When the animation is finished, remove all of the No-Tabs UI and |
| - // reshow the tabstrip, web toolbar, and web. |
| - [noTabsController dismissAnimationDidFinish]; |
| - [[_toolbarController view] setHidden:NO]; |
| - [[_tabStripController view] setHidden:NO]; |
| - }]; |
| - // Nullify the instance variable. The controller is retained by the animation. |
| - // Nullifying this variable prevents button press performed during the |
| - // animation to be routed to the noTabController. |
| - _noTabsController.reset(); |
| -} |
| - |
| #pragma mark - Showing popups |
| - (void)showToolsMenuPopup { |
| DCHECK(_browserState); |
| DCHECK(self.visible || self.dismissingModal); |
| - DCHECK(!_noTabsController); |
| // Dismiss the omnibox (if open). |
| [_toolbarController cancelOmniboxEdit]; |
| @@ -3456,7 +3315,6 @@ class BrowserBookmarkModelBridge : public bookmarks::BookmarkModelObserver { |
| - (void)showTabHistoryPopupForBackwardHistory { |
| DCHECK(self.visible || self.dismissingModal); |
| - DCHECK(!_noTabsController); |
| // Dismiss the omnibox (if open). |
| [_toolbarController cancelOmniboxEdit]; |
| @@ -3473,7 +3331,6 @@ class BrowserBookmarkModelBridge : public bookmarks::BookmarkModelObserver { |
| - (void)showTabHistoryPopupForForwardHistory { |
| DCHECK(self.visible || self.dismissingModal); |
| - DCHECK(!_noTabsController); |
| // Dismiss the omnibox (if open). |
| [_toolbarController cancelOmniboxEdit]; |
| @@ -4030,15 +3887,7 @@ class BrowserBookmarkModelBridge : public bookmarks::BookmarkModelObserver { |
| [self enableDesktopUserAgent]; |
| break; |
| case IDC_SHOW_TOOLS_MENU: { |
| - // TODO(blundell): Change this if/else to |
| - // |DCHECK(!_noTabsController)| if/when the no tabs controller |
| - // becomes part of the responder chain. |
| - // The no tabs controller's toolbar should open the menu when in the |
| - // no-tabs UI. |
| - if (_noTabsController.get()) |
| - [_noTabsController showToolsMenuPopup]; |
| - else |
| - [self showToolsMenuPopup]; |
| + [self showToolsMenuPopup]; |
| break; |
| } |
| case IDC_SHOW_BOOKMARK_MANAGER: { |
| @@ -4141,13 +3990,7 @@ class BrowserBookmarkModelBridge : public bookmarks::BookmarkModelObserver { |
| if (tabIndex == NSNotFound) |
| return; |
| - // Take snapshot on iPad only if Tab switcher is enabled, if not just close |
| - // the tab. |
| - if (IsIPadIdiom() && !experimental_flags::IsTabSwitcherEnabled()) { |
| - [_model closeTabAtIndex:tabIndex]; |
| - return; |
| - } |
| - |
| + // TODO(xxx): Evaluate if a screenshot of the tab is needed on iPad. |
|
rohitrao (ping after 24h)
2017/02/01 18:34:34
Is there a bug for this?
jif
2017/02/03 12:55:51
Done.
|
| // Create image of tab for close animation. |
| UIImageView* exitingPage = [self pageOpenCloseAnimationView]; |
| exitingPage.image = |
| @@ -4226,10 +4069,7 @@ class BrowserBookmarkModelBridge : public bookmarks::BookmarkModelObserver { |
| [_printController dismissAnimated:YES]; |
| _printController.reset(); |
| - if (_noTabsController.get()) |
| - [_noTabsController dismissToolsMenuPopup]; |
| - else |
| - [_toolbarController dismissToolsMenuPopup]; |
| + [_toolbarController dismissToolsMenuPopup]; |
| [_contextMenuCoordinator stop]; |
| [self dismissRateThisAppDialog]; |
| @@ -4630,26 +4470,7 @@ class BrowserBookmarkModelBridge : public bookmarks::BookmarkModelObserver { |
| // Called when the number of tabs changes. Update the toolbar accordingly. |
| - (void)tabModelDidChangeTabCount:(TabModel*)model { |
| DCHECK(model == _model); |
| - if ([_model count] == 1 && _noTabsController.get()) { |
| - [self dismissNoTabsUI]; |
| - } |
| - |
| [_toolbarController setTabCount:[_model count]]; |
| - // If the iPad tab switcher feature is enabled, the tab switcher is shown |
| - // instead of the no tabs UI. Showing the tab switcher in that case is |
| - // done from the main controller. |
| - // If the iPad tab switcher feature is disabled and the number of tabs is |
| - // zero, ensure the no-tabs UI is visible (such as if the last tab was closed |
| - // programmatically from JS). This is done on a delay because the |
| - // notification happens while the tab is going away and trying to trigger a |
| - // change during teardown causes problems. |
| - BOOL showNoTabsUIOnIPad = |
| - IsIPadIdiom() && !experimental_flags::IsTabSwitcherEnabled(); |
| - if (![_model count] && showNoTabsUIOnIPad && !_isOffTheRecord) { |
| - [self performSelector:@selector(showNoTabsUI) |
| - withObject:nil |
| - afterDelay:0.01]; |
| - } |
| } |
| #pragma mark - Upgrade Detection |