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[] = {
#if defined(ENABLE_TOPCHROME_MD)
const FeatureEntry::Choice kTopChromeMaterialDesignChoices[] = {
{IDS_FLAGS_TOP_CHROME_MD_NON_MATERIAL, "", ""},
{IDS_FLAGS_TOP_CHROME_MD_MATERIAL,
{ IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
{ IDS_FLAGS_TOP_CHROME_MD_NON_MATERIAL,
switches::kTopChromeMD,
switches::kTopChromeMDNonMaterial },
{ IDS_FLAGS_TOP_CHROME_MD_MATERIAL,
switches::kTopChromeMD,
switches::kTopChromeMDMaterial},
{IDS_FLAGS_TOP_CHROME_MD_MATERIAL_HYBRID,
switches::kTopChromeMDMaterial },
{ IDS_FLAGS_TOP_CHROME_MD_MATERIAL_HYBRID,
switches::kTopChromeMD,
switches::kTopChromeMDMaterialHybrid}};
switches::kTopChromeMDMaterialHybrid },
};
#endif
#if defined(OS_CHROMEOS)
......
......@@ -28,6 +28,14 @@ bool MaterialDesignController::IsModeMaterial() {
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() {
#if !defined(ENABLE_TOPCHROME_MD)
SetMode(Mode::NON_MATERIAL);
......@@ -43,10 +51,12 @@ void MaterialDesignController::InitializeMode() {
} else if (switch_value == switches::kTopChromeMDNonMaterial) {
SetMode(Mode::NON_MATERIAL);
} else {
if (!switch_value.empty()) {
LOG(ERROR) << "Invalid value='" << switch_value
<< "' for command line switch '" << switches::kTopChromeMD
<< "'.";
SetMode(Mode::NON_MATERIAL);
}
SetMode(DefaultMode());
}
#endif // !defined(ENABLE_TOPCHROME_MD)
}
......
......@@ -34,6 +34,9 @@ class UI_BASE_EXPORT MaterialDesignController {
// Returns true if the current mode is a material design variant.
static bool IsModeMaterial();
// Returns the per-platform default material design variant.
static Mode DefaultMode();
private:
friend class test::MaterialDesignControllerTestAPI;
......
......@@ -77,33 +77,33 @@ TEST_F(
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.
TEST_F(
MaterialDesignControllerTest,
DisabledCommandLineValueMapsToNonMaterialModeWhenCompileTimeFlagEnabled) {
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kTopChromeMD, "");
EXPECT_EQ(MaterialDesignController::Mode::NON_MATERIAL,
EXPECT_EQ(MaterialDesignController::DefaultMode(),
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.
TEST_F(MaterialDesignControllerTest,
NoCommandLineValueMapsToNonMaterialModeWhenCompileTimeFlagEnabled) {
ASSERT_FALSE(base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kTopChromeMD));
EXPECT_EQ(MaterialDesignController::Mode::NON_MATERIAL,
EXPECT_EQ(MaterialDesignController::DefaultMode(),
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) {
const std::string kInvalidValue = "1nvalid-valu3";
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kTopChromeMD, kInvalidValue);
EXPECT_EQ(MaterialDesignController::Mode::NON_MATERIAL,
EXPECT_EQ(MaterialDesignController::DefaultMode(),
MaterialDesignController::GetMode());
}
......
......@@ -79,7 +79,7 @@ const char kTopChromeMDMaterial[] = "material";
const char kTopChromeMDMaterialHybrid[] = "material-hybrid";
// Classic, non-material, mode for the |kTopChromeMD| switch.
const char kTopChromeMDNonMaterial[] = "";
const char kTopChromeMDNonMaterial[] = "non-material";
#endif // defined(ENABLE_TOPCHROME_MD)
// 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