Commit ca4f14df authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

Add a switch for the bottom toolbar search icons

This CL adds a switch allowing the choose which icon to use for the
search button in the bottom toolbar.

Bug: 826192
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I363822bd9fa94606bf5422b0664febc91b81e03e
Reviewed-on: https://chromium-review.googlesource.com/980935
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarEric Noyau <noyau@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546099}
parent 9adb38cd
...@@ -131,6 +131,14 @@ const FeatureEntry::Choice kToolbarButtonPositionsChoices[] = { ...@@ -131,6 +131,14 @@ const FeatureEntry::Choice kToolbarButtonPositionsChoices[] = {
{"Top navigation", kToolbarButtonPositionsSwitch, "2"}, {"Top navigation", kToolbarButtonPositionsSwitch, "2"},
}; };
const FeatureEntry::Choice kSearchButtonIconChoices[] = {
{flags_ui::kGenericExperimentChoiceDefault, "", ""},
{"Grey search engine logo", kIconSearchButtonSwitch, kIconSearchButtonGrey},
{"Colorful search engine logo", kIconSearchButtonSwitch,
kIconSearchButtonColorful},
{"Magnifying glass", kIconSearchButtonSwitch, kIconSearchButtonMagnifying},
};
// To add a new entry, add to the end of kFeatureEntries. There are four // To add a new entry, add to the end of kFeatureEntries. There are four
// distinct types of entries: // distinct types of entries:
// . ENABLE_DISABLE_VALUE: entry is either enabled, disabled, or uses the // . ENABLE_DISABLE_VALUE: entry is either enabled, disabled, or uses the
...@@ -257,6 +265,9 @@ const flags_ui::FeatureEntry kFeatureEntries[] = { ...@@ -257,6 +265,9 @@ const flags_ui::FeatureEntry kFeatureEntries[] = {
{"toolbar-button-positions", flag_descriptions::kToolbarButtonPositionsName, {"toolbar-button-positions", flag_descriptions::kToolbarButtonPositionsName,
flag_descriptions::kToolbarButtonPositionsDescription, flags_ui::kOsIos, flag_descriptions::kToolbarButtonPositionsDescription, flags_ui::kOsIos,
MULTI_VALUE_TYPE(kToolbarButtonPositionsChoices)}, MULTI_VALUE_TYPE(kToolbarButtonPositionsChoices)},
{"search-icon-toggle", flag_descriptions::kSearchIconToggleName,
flag_descriptions::kSearchIconToggleDescription, flags_ui::kOsIos,
MULTI_VALUE_TYPE(kSearchButtonIconChoices)},
}; };
// Add all switches from experimental flags to |command_line|. // Add all switches from experimental flags to |command_line|.
......
...@@ -134,6 +134,10 @@ const char kUIRefreshPhase1Name[] = "UI Refresh Phase 1"; ...@@ -134,6 +134,10 @@ 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.";
const char kSearchIconToggleName[] = "Change the icon for the search button";
const char kSearchIconToggleDescription[] =
"Different icons for the search button.";
const char kUseDdljsonApiName[] = "Use new ddljson API for Doodles"; const char kUseDdljsonApiName[] = "Use new ddljson API for Doodles";
const char kUseDdljsonApiDescription[] = const char kUseDdljsonApiDescription[] =
"Enables the new ddljson API to fetch Doodles for the NTP."; "Enables the new ddljson API to fetch Doodles for the NTP.";
......
...@@ -123,6 +123,10 @@ extern const char kToolbarButtonPositionsDescription[]; ...@@ -123,6 +123,10 @@ extern const char kToolbarButtonPositionsDescription[];
extern const char kUIRefreshPhase1Name[]; extern const char kUIRefreshPhase1Name[];
extern const char kUIRefreshPhase1Description[]; extern const char kUIRefreshPhase1Description[];
// Title and description for the flag to toggle the flag of the search button.
extern const char kSearchIconToggleName[];
extern const char kSearchIconToggleDescription[];
// Title and description for the flag to enable the ddljson Doodle API. // Title and description for the flag to enable the ddljson Doodle API.
extern const char kUseDdljsonApiName[]; extern const char kUseDdljsonApiName[];
extern const char kUseDdljsonApiDescription[]; extern const char kUseDdljsonApiDescription[];
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#import "ios/chrome/browser/ui/toolbar/buttons/toolbar_tab_grid_button.h" #import "ios/chrome/browser/ui/toolbar/buttons/toolbar_tab_grid_button.h"
#import "ios/chrome/browser/ui/toolbar/buttons/toolbar_tools_menu_button.h" #import "ios/chrome/browser/ui/toolbar/buttons/toolbar_tools_menu_button.h"
#import "ios/chrome/browser/ui/toolbar/public/omnibox_focuser.h" #import "ios/chrome/browser/ui/toolbar/public/omnibox_focuser.h"
#import "ios/chrome/browser/ui/toolbar/public/toolbar_controller_base_feature.h"
#import "ios/third_party/material_components_ios/src/components/ProgressView/src/MaterialProgressView.h" #import "ios/third_party/material_components_ios/src/components/ProgressView/src/MaterialProgressView.h"
#import "ios/third_party/material_components_ios/src/components/Typography/src/MaterialTypography.h" #import "ios/third_party/material_components_ios/src/components/Typography/src/MaterialTypography.h"
...@@ -145,6 +146,8 @@ ...@@ -145,6 +146,8 @@
} }
- (void)setSearchIcon:(UIImage*)searchIcon { - (void)setSearchIcon:(UIImage*)searchIcon {
if (IconForSearchButton() == ToolbarSearchButtonIconMagnifying)
return;
[self.view.omniboxButton setImage:searchIcon forState:UIControlStateNormal]; [self.view.omniboxButton setImage:searchIcon forState:UIControlStateNormal];
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#import "ios/chrome/browser/ui/toolbar/buttons/toolbar_configuration.h" #import "ios/chrome/browser/ui/toolbar/buttons/toolbar_configuration.h"
#import "ios/chrome/browser/ui/toolbar/buttons/toolbar_tab_grid_button.h" #import "ios/chrome/browser/ui/toolbar/buttons/toolbar_tab_grid_button.h"
#import "ios/chrome/browser/ui/toolbar/buttons/toolbar_tools_menu_button.h" #import "ios/chrome/browser/ui/toolbar/buttons/toolbar_tools_menu_button.h"
#import "ios/chrome/browser/ui/toolbar/public/toolbar_controller_base_feature.h"
#import "ios/chrome/browser/ui/util/constraints_ui_util.h" #import "ios/chrome/browser/ui/util/constraints_ui_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
...@@ -96,8 +97,9 @@ ...@@ -96,8 +97,9 @@
AddSameConstraints(self.blur, self); AddSameConstraints(self.blur, self);
UIView* contentView = self; UIView* contentView = self;
if (UIVisualEffect* vibrancy = [self.buttonFactory.toolbarConfiguration UIVisualEffect* vibrancy = [self.buttonFactory.toolbarConfiguration
vibrancyEffectForBlurEffect:blurEffect]) { vibrancyEffectForBlurEffect:blurEffect];
if (vibrancy && IconForSearchButton() != ToolbarSearchButtonIconColorful) {
// Add vibrancy only if we have a vibrancy effect. // Add vibrancy only if we have a vibrancy effect.
UIVisualEffectView* vibrancyView = UIVisualEffectView* vibrancyView =
[[UIVisualEffectView alloc] initWithEffect:vibrancy]; [[UIVisualEffectView alloc] initWithEffect:vibrancy];
......
...@@ -9,6 +9,13 @@ ...@@ -9,6 +9,13 @@
#include "base/feature_list.h" #include "base/feature_list.h"
// Enum for the different icons for the search button.
typedef NS_ENUM(NSUInteger, ToolbarSearchButtonIcon) {
ToolbarSearchButtonIconGrey,
ToolbarSearchButtonIconColorful,
ToolbarSearchButtonIconMagnifying,
};
// Enum for the different positions of the toolbars' buttons. // Enum for the different positions of the toolbars' buttons.
typedef NS_ENUM(NSUInteger, ToolbarButtonPosition) { typedef NS_ENUM(NSUInteger, ToolbarButtonPosition) {
ToolbarButtonPositionNavigationBottomNoTop, ToolbarButtonPositionNavigationBottomNoTop,
...@@ -25,4 +32,15 @@ extern const char kToolbarButtonPositionsSwitch[]; ...@@ -25,4 +32,15 @@ extern const char kToolbarButtonPositionsSwitch[];
ToolbarButtonPosition PositionForCurrentProcess(); ToolbarButtonPosition PositionForCurrentProcess();
// Switch with the different value for thesearch icon on the bottom adaptive
// toolbar.
// TODO(crbug.com/826192): Remove this.
extern const char kIconSearchButtonSwitch[];
extern const char kIconSearchButtonGrey[];
extern const char kIconSearchButtonColorful[];
extern const char kIconSearchButtonMagnifying[];
ToolbarSearchButtonIcon IconForSearchButton();
#endif // IOS_CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_CONTROLLER_BASE_FEATURE_H_ #endif // IOS_CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_CONTROLLER_BASE_FEATURE_H_
...@@ -31,3 +31,27 @@ ToolbarButtonPosition PositionForCurrentProcess() { ...@@ -31,3 +31,27 @@ ToolbarButtonPosition PositionForCurrentProcess() {
} }
return ToolbarButtonPositionNavigationBottomNoTop; return ToolbarButtonPositionNavigationBottomNoTop;
} }
const char kIconSearchButtonSwitch[] = "icon-search-button-switch";
extern const char kIconSearchButtonGrey[] = "icon-search-button-grey";
extern const char kIconSearchButtonColorful[] = "icon-search-button-colorful";
extern const char kIconSearchButtonMagnifying[] =
"icon-search-button-magnifying";
ToolbarSearchButtonIcon IconForSearchButton() {
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(kIconSearchButtonSwitch)) {
if (command_line->GetSwitchValueASCII(kIconSearchButtonSwitch) ==
kIconSearchButtonColorful) {
return ToolbarSearchButtonIconColorful;
} else if (command_line->GetSwitchValueASCII(kIconSearchButtonSwitch) ==
kIconSearchButtonMagnifying) {
return ToolbarSearchButtonIconMagnifying;
} else {
return ToolbarSearchButtonIconGrey;
}
}
return ToolbarSearchButtonIconGrey;
}
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