Commit f39767d7 authored by edchin's avatar edchin Committed by Commit Bot

[ios] Add experiment flag for Tab Grid

This CL adds an experiment flag for Tab Grid,
and simply uses the flag to show a blank tab
grid when enabled.

Bug: 804496
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I9d24d64c77cba8889f2c699763d610617263b9cc
Reviewed-on: https://chromium-review.googlesource.com/917427
Commit-Queue: edchin <edchin@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#536751}
parent 3cb4b2b0
...@@ -200,6 +200,7 @@ source_set("app_internal") { ...@@ -200,6 +200,7 @@ source_set("app_internal") {
"//ios/chrome/browser/ui/settings", "//ios/chrome/browser/ui/settings",
"//ios/chrome/browser/ui/signin_interaction", "//ios/chrome/browser/ui/signin_interaction",
"//ios/chrome/browser/ui/stack_view", "//ios/chrome/browser/ui/stack_view",
"//ios/chrome/browser/ui/tab_grid",
"//ios/chrome/browser/ui/tab_switcher", "//ios/chrome/browser/ui/tab_switcher",
"//ios/chrome/browser/ui/tabs", "//ios/chrome/browser/ui/tabs",
"//ios/chrome/browser/ui/toolbar/clean:toolbar_ui", "//ios/chrome/browser/ui/toolbar/clean:toolbar_ui",
......
...@@ -133,6 +133,7 @@ ...@@ -133,6 +133,7 @@
#import "ios/chrome/browser/ui/settings/settings_navigation_controller.h" #import "ios/chrome/browser/ui/settings/settings_navigation_controller.h"
#import "ios/chrome/browser/ui/signin_interaction/signin_interaction_coordinator.h" #import "ios/chrome/browser/ui/signin_interaction/signin_interaction_coordinator.h"
#import "ios/chrome/browser/ui/stack_view/stack_view_controller.h" #import "ios/chrome/browser/ui/stack_view/stack_view_controller.h"
#include "ios/chrome/browser/ui/tab_grid/tab_grid_view_controller.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_switcher_controller.h" #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_controller.h"
#import "ios/chrome/browser/ui/toolbar/public/omnibox_focuser.h" #import "ios/chrome/browser/ui/toolbar/public/omnibox_focuser.h"
#include "ios/chrome/browser/ui/ui_util.h" #include "ios/chrome/browser/ui/ui_util.h"
...@@ -1871,20 +1872,7 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData( ...@@ -1871,20 +1872,7 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
} }
if (!_tabSwitcherController) { if (!_tabSwitcherController) {
if (IsIPadIdiom()) { _tabSwitcherController = [self newTabSwitcherController];
_tabSwitcherController = [[TabSwitcherController alloc]
initWithBrowserState:_mainBrowserState
mainTabModel:self.mainTabModel
otrTabModel:self.otrTabModel
activeTabModel:self.currentTabModel
applicationCommandEndpoint:self];
} else {
_tabSwitcherController =
[[StackViewController alloc] initWithMainTabModel:self.mainTabModel
otrTabModel:self.otrTabModel
activeTabModel:self.currentTabModel
applicationCommandEndpoint:self];
}
} else { } else {
// The StackViewController is kept in memory to avoid the performance hit of // The StackViewController is kept in memory to avoid the performance hit of
// loading from the nib on next showing, but clears out its card models to // loading from the nib on next showing, but clears out its card models to
...@@ -2522,6 +2510,29 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData( ...@@ -2522,6 +2510,29 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
[self.mainTabModel closeAllTabs]; [self.mainTabModel closeAllTabs];
} }
#pragma mark - Experimental flag
- (UIViewController<TabSwitcher>*)newTabSwitcherController {
if (IsTabSwitcherTabGridEnabled()) {
return [[TabGridViewController alloc] init];
} else {
if (IsIPadIdiom()) {
return [[TabSwitcherController alloc]
initWithBrowserState:_mainBrowserState
mainTabModel:self.mainTabModel
otrTabModel:self.otrTabModel
activeTabModel:self.currentTabModel
applicationCommandEndpoint:self];
} else {
return
[[StackViewController alloc] initWithMainTabModel:self.mainTabModel
otrTabModel:self.otrTabModel
activeTabModel:self.currentTabModel
applicationCommandEndpoint:self];
}
}
}
@end @end
#pragma mark - TestingOnly #pragma mark - TestingOnly
......
...@@ -233,6 +233,9 @@ const flags_ui::FeatureEntry kFeatureEntries[] = { ...@@ -233,6 +233,9 @@ const flags_ui::FeatureEntry kFeatureEntries[] = {
flag_descriptions::kMailtoHandlingWithGoogleUIName, flag_descriptions::kMailtoHandlingWithGoogleUIName,
flag_descriptions::kMailtoHandlingWithGoogleUIDescription, flag_descriptions::kMailtoHandlingWithGoogleUIDescription,
flags_ui::kOsIos, FEATURE_VALUE_TYPE(kMailtoHandledWithGoogleUI)}, flags_ui::kOsIos, FEATURE_VALUE_TYPE(kMailtoHandledWithGoogleUI)},
{"tab-switcher-tab-grid", flag_descriptions::kTabSwitcherTabGridName,
flag_descriptions::kTabSwitcherTabGridDescription, flags_ui::kOsIos,
FEATURE_VALUE_TYPE(kTabSwitcherTabGrid)},
}; };
// Add all switches from experimental flags to |command_line|. // Add all switches from experimental flags to |command_line|.
......
...@@ -126,6 +126,11 @@ const char kTabSwitcherPresentsBVCDescription[] = ...@@ -126,6 +126,11 @@ const char kTabSwitcherPresentsBVCDescription[] =
"BVC is visible, the tab switcher will remain in the VC hierarchy " "BVC is visible, the tab switcher will remain in the VC hierarchy "
"underneath it."; "underneath it.";
const char kTabSwitcherTabGridName[] = "TabSwitcher Tab Grid";
const char kTabSwitcherTabGridDescription[] =
"When enabled, the tab grid will be used as the tab switcher for both "
"phone and tablet.";
const char kUIRefreshPhase1Name[] = "UI Refresh Phase 1"; const char kUIRefreshPhase1Name[] = "UI Refresh Phase 1";
const char kUIRefreshPhase1Description[] = const char kUIRefreshPhase1Description[] =
"When enabled, the first phase of the iOS UI refresh will be displayed."; "When enabled, the first phase of the iOS UI refresh will be displayed.";
......
...@@ -113,6 +113,10 @@ extern const char kShowAutofillTypePredictionsDescription[]; ...@@ -113,6 +113,10 @@ extern const char kShowAutofillTypePredictionsDescription[];
extern const char kTabSwitcherPresentsBVCName[]; extern const char kTabSwitcherPresentsBVCName[];
extern const char kTabSwitcherPresentsBVCDescription[]; extern const char kTabSwitcherPresentsBVCDescription[];
// Title and description for the flag to enable the TabGrid as the tab switcher.
extern const char kTabSwitcherTabGridName[];
extern const char kTabSwitcherTabGridDescription[];
// Title and description for the flag to enable the phase 1 UI Refresh. // Title and description for the flag to enable the phase 1 UI Refresh.
extern const char kUIRefreshPhase1Name[]; extern const char kUIRefreshPhase1Name[];
extern const char kUIRefreshPhase1Description[]; extern const char kUIRefreshPhase1Description[];
......
...@@ -17,5 +17,6 @@ source_set("tab_grid") { ...@@ -17,5 +17,6 @@ source_set("tab_grid") {
deps = [ deps = [
"//base", "//base",
"//ios/chrome/browser/ui/coordinators:chrome_coordinators", "//ios/chrome/browser/ui/coordinators:chrome_coordinators",
"//ios/chrome/browser/ui/tab_switcher",
] ]
} }
...@@ -7,7 +7,9 @@ ...@@ -7,7 +7,9 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@interface TabGridViewController : UIViewController #import "ios/chrome/browser/ui/tab_switcher/tab_switcher.h"
@interface TabGridViewController : UIViewController<TabSwitcher>
@end @end
#endif // IOS_CHROME_BROWSER_UI_TAB_GRID_TAB_GRID_VIEW_CONTROLLER_H_ #endif // IOS_CHROME_BROWSER_UI_TAB_GRID_TAB_GRID_VIEW_CONTROLLER_H_
...@@ -9,4 +9,44 @@ ...@@ -9,4 +9,44 @@
#endif #endif
@implementation TabGridViewController @implementation TabGridViewController
@synthesize delegate = _delegate;
@synthesize animationDelegate = _animationDelegate;
@synthesize dispatcher = _dispatcher;
@synthesize transitionContext = _transitionContext;
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
}
#pragma mark - TabSwitcher
- (void)restoreInternalStateWithMainTabModel:(TabModel*)mainModel
otrTabModel:(TabModel*)otrModel
activeTabModel:(TabModel*)activeModel {
}
- (UIViewController*)viewController {
return self;
}
- (void)prepareForDisplayAtSize:(CGSize)size {
}
- (void)showWithSelectedTabAnimation {
}
- (Tab*)dismissWithNewTabAnimationToModel:(TabModel*)targetModel
withURL:(const GURL&)url
atIndex:(NSUInteger)position
transition:(ui::PageTransition)transition {
return nil;
}
- (void)setOtrTabModel:(TabModel*)otrModel {
}
- (void)tabSwitcherDismissWithModel:(TabModel*)model animated:(BOOL)animated {
}
@end @end
...@@ -6,3 +6,6 @@ ...@@ -6,3 +6,6 @@
const base::Feature kUIRefreshPhase1{"UIRefreshPhase1", const base::Feature kUIRefreshPhase1{"UIRefreshPhase1",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kTabSwitcherTabGrid{"TabSwitcherTabGrid",
base::FEATURE_DISABLED_BY_DEFAULT};
...@@ -11,4 +11,8 @@ ...@@ -11,4 +11,8 @@
// used directly. Instead use ui_util::IsUIRefreshPhase1Enabled(). // used directly. Instead use ui_util::IsUIRefreshPhase1Enabled().
extern const base::Feature kUIRefreshPhase1; extern const base::Feature kUIRefreshPhase1;
// Used to enable the tab grid on phone and tablet. This flag should not be
// used directly. Instead use ui_util::IsTabSwitcherTabGridEnabled().
extern const base::Feature kTabSwitcherTabGrid;
#endif // IOS_CHROME_BROWSER_UI_UI_FEATURE_FLAGS_H_ #endif // IOS_CHROME_BROWSER_UI_UI_FEATURE_FLAGS_H_
...@@ -39,9 +39,12 @@ CGFloat CurrentScreenWidth(); ...@@ -39,9 +39,12 @@ CGFloat CurrentScreenWidth();
// Returns true if the device is an iPhone X. // Returns true if the device is an iPhone X.
bool IsIPhoneX(); bool IsIPhoneX();
// Returns whether the first phase of the UI refresh will be displayed.. // Returns whether the first phase of the UI refresh will be displayed.
bool IsUIRefreshPhase1Enabled(); bool IsUIRefreshPhase1Enabled();
// Returns whether the tab grid will be displayed as the tab switcher.
bool IsTabSwitcherTabGridEnabled();
// Returns the height of the status bar, accounting for orientation. // Returns the height of the status bar, accounting for orientation.
CGFloat StatusBarHeight(); CGFloat StatusBarHeight();
......
...@@ -63,6 +63,10 @@ bool IsUIRefreshPhase1Enabled() { ...@@ -63,6 +63,10 @@ bool IsUIRefreshPhase1Enabled() {
return base::FeatureList::IsEnabled(kUIRefreshPhase1); return base::FeatureList::IsEnabled(kUIRefreshPhase1);
} }
bool IsTabSwitcherTabGridEnabled() {
return base::FeatureList::IsEnabled(kTabSwitcherTabGrid);
}
CGFloat StatusBarHeight() { CGFloat StatusBarHeight() {
// This is a temporary solution until usage of StatusBarHeight has been // This is a temporary solution until usage of StatusBarHeight has been
// replaced with topLayoutGuide. // replaced with topLayoutGuide.
......
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