Commit 5a526d96 authored by tdanderson's avatar tdanderson Committed by Commit bot

Use browser top chrome material design by default on Chrome OS

Change the default value of the --top-chrome-md
flag to map to 'material' on Chrome OS, and
remain as 'non-material' on all other platforms.

On Chrome OS this will impact the assets, layout,
theming, and visual feedback of mouse/touch
interactions across the browser's UI surfaces,
namely:

* Tabstrip
* Toolbar
* Bookmarks bar
* Omnibox dropdown
* Incognito mode
* Bubbles
* Infobars

This CL does NOT make any changes to UI on other
platforms or non-browser UI on Chrome OS (shelf,
tray, etc). Furthermore, this CL should not
introduce any regressions in functionality.

Please use the label
Proj-MaterialDesign-NativeUI when filing bugs
in crbug.

BUG=581143,575270
TEST=MaterialDesignControllerTest.*

Review URL: https://codereview.chromium.org/1633733004

Cr-Commit-Position: refs/heads/master@{#371609}
parent 061f6ef7
...@@ -376,13 +376,17 @@ const FeatureEntry::Choice kFillOnAccountSelectChoices[] = { ...@@ -376,13 +376,17 @@ const FeatureEntry::Choice kFillOnAccountSelectChoices[] = {
#if defined(ENABLE_TOPCHROME_MD) #if defined(ENABLE_TOPCHROME_MD)
const FeatureEntry::Choice kTopChromeMaterialDesignChoices[] = { const FeatureEntry::Choice kTopChromeMaterialDesignChoices[] = {
{IDS_FLAGS_TOP_CHROME_MD_NON_MATERIAL, "", ""}, { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
{IDS_FLAGS_TOP_CHROME_MD_MATERIAL, { IDS_FLAGS_TOP_CHROME_MD_NON_MATERIAL,
switches::kTopChromeMD,
switches::kTopChromeMDNonMaterial },
{ IDS_FLAGS_TOP_CHROME_MD_MATERIAL,
switches::kTopChromeMD, switches::kTopChromeMD,
switches::kTopChromeMDMaterial}, switches::kTopChromeMDMaterial },
{IDS_FLAGS_TOP_CHROME_MD_MATERIAL_HYBRID, { IDS_FLAGS_TOP_CHROME_MD_MATERIAL_HYBRID,
switches::kTopChromeMD, switches::kTopChromeMD,
switches::kTopChromeMDMaterialHybrid}}; switches::kTopChromeMDMaterialHybrid },
};
#endif #endif
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
......
...@@ -28,6 +28,14 @@ bool MaterialDesignController::IsModeMaterial() { ...@@ -28,6 +28,14 @@ bool MaterialDesignController::IsModeMaterial() {
GetMode() == Mode::MATERIAL_HYBRID; GetMode() == Mode::MATERIAL_HYBRID;
} }
MaterialDesignController::Mode MaterialDesignController::DefaultMode() {
#if defined(OS_CHROMEOS)
return Mode::MATERIAL_NORMAL;
#else
return Mode::NON_MATERIAL;
#endif // defined(OS_CHROMEOS)
}
void MaterialDesignController::InitializeMode() { void MaterialDesignController::InitializeMode() {
#if !defined(ENABLE_TOPCHROME_MD) #if !defined(ENABLE_TOPCHROME_MD)
SetMode(Mode::NON_MATERIAL); SetMode(Mode::NON_MATERIAL);
...@@ -43,10 +51,12 @@ void MaterialDesignController::InitializeMode() { ...@@ -43,10 +51,12 @@ void MaterialDesignController::InitializeMode() {
} else if (switch_value == switches::kTopChromeMDNonMaterial) { } else if (switch_value == switches::kTopChromeMDNonMaterial) {
SetMode(Mode::NON_MATERIAL); SetMode(Mode::NON_MATERIAL);
} else { } else {
if (!switch_value.empty()) {
LOG(ERROR) << "Invalid value='" << switch_value LOG(ERROR) << "Invalid value='" << switch_value
<< "' for command line switch '" << switches::kTopChromeMD << "' for command line switch '" << switches::kTopChromeMD
<< "'."; << "'.";
SetMode(Mode::NON_MATERIAL); }
SetMode(DefaultMode());
} }
#endif // !defined(ENABLE_TOPCHROME_MD) #endif // !defined(ENABLE_TOPCHROME_MD)
} }
......
...@@ -34,6 +34,9 @@ class UI_BASE_EXPORT MaterialDesignController { ...@@ -34,6 +34,9 @@ class UI_BASE_EXPORT MaterialDesignController {
// Returns true if the current mode is a material design variant. // Returns true if the current mode is a material design variant.
static bool IsModeMaterial(); static bool IsModeMaterial();
// Returns the per-platform default material design variant.
static Mode DefaultMode();
private: private:
friend class test::MaterialDesignControllerTestAPI; friend class test::MaterialDesignControllerTestAPI;
......
...@@ -77,33 +77,33 @@ TEST_F( ...@@ -77,33 +77,33 @@ TEST_F(
MaterialDesignController::GetMode()); MaterialDesignController::GetMode());
} }
// Verify command line value "" maps to Mode::NON_MATERIAL when the compile time // Verify command line value "" maps to the default mode when the compile time
// flag is defined. // flag is defined.
TEST_F( TEST_F(
MaterialDesignControllerTest, MaterialDesignControllerTest,
DisabledCommandLineValueMapsToNonMaterialModeWhenCompileTimeFlagEnabled) { DisabledCommandLineValueMapsToNonMaterialModeWhenCompileTimeFlagEnabled) {
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kTopChromeMD, ""); switches::kTopChromeMD, "");
EXPECT_EQ(MaterialDesignController::Mode::NON_MATERIAL, EXPECT_EQ(MaterialDesignController::DefaultMode(),
MaterialDesignController::GetMode()); MaterialDesignController::GetMode());
} }
// Verify no command line value maps to Mode::NON_MATERIAL when the compile time // Verify the current mode is reported as the default mode when no command line
// flag is defined. // flag is defined.
TEST_F(MaterialDesignControllerTest, TEST_F(MaterialDesignControllerTest,
NoCommandLineValueMapsToNonMaterialModeWhenCompileTimeFlagEnabled) { NoCommandLineValueMapsToNonMaterialModeWhenCompileTimeFlagEnabled) {
ASSERT_FALSE(base::CommandLine::ForCurrentProcess()->HasSwitch( ASSERT_FALSE(base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kTopChromeMD)); switches::kTopChromeMD));
EXPECT_EQ(MaterialDesignController::Mode::NON_MATERIAL, EXPECT_EQ(MaterialDesignController::DefaultMode(),
MaterialDesignController::GetMode()); MaterialDesignController::GetMode());
} }
// Verify an invalid command line value uses the default NON_MATERIAL mode. // Verify an invalid command line value uses the default mode.
TEST_F(MaterialDesignControllerTest, InvalidCommandLineValue) { TEST_F(MaterialDesignControllerTest, InvalidCommandLineValue) {
const std::string kInvalidValue = "1nvalid-valu3"; const std::string kInvalidValue = "1nvalid-valu3";
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kTopChromeMD, kInvalidValue); switches::kTopChromeMD, kInvalidValue);
EXPECT_EQ(MaterialDesignController::Mode::NON_MATERIAL, EXPECT_EQ(MaterialDesignController::DefaultMode(),
MaterialDesignController::GetMode()); MaterialDesignController::GetMode());
} }
......
...@@ -79,7 +79,7 @@ const char kTopChromeMDMaterial[] = "material"; ...@@ -79,7 +79,7 @@ const char kTopChromeMDMaterial[] = "material";
const char kTopChromeMDMaterialHybrid[] = "material-hybrid"; const char kTopChromeMDMaterialHybrid[] = "material-hybrid";
// Classic, non-material, mode for the |kTopChromeMD| switch. // Classic, non-material, mode for the |kTopChromeMD| switch.
const char kTopChromeMDNonMaterial[] = ""; const char kTopChromeMDNonMaterial[] = "non-material";
#endif // defined(ENABLE_TOPCHROME_MD) #endif // defined(ENABLE_TOPCHROME_MD)
// On Windows only: requests that Chrome connect to the running Metro viewer // On Windows only: requests that Chrome connect to the running Metro viewer
......
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