Skip to content

Commit a23d6ce

Browse files
estadeCommit bot
estade
authored and
Commit bot
committed
Gut ash::MaterialDesignController, and remove the about:flags entry.
It's not removed completely because IsXXXMaterial() is still used in many places and serves as a good marker for code cleanup, but it no longer does anything useful. A bunch of tests are updated as well to remove parameterization. The amount of overlap with bug 685837 was not originally intended, but at a certain point it became easier to keep removing code than to carefully determine dependencies. BUG=690048,685837 Review-Url: https://codereview.chromium.org/2692663002 Cr-Commit-Position: refs/heads/master@{#450531}
1 parent 1645e63 commit a23d6ce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+339
-1181
lines changed

ash/BUILD.gn

-3
Original file line numberDiff line numberDiff line change
@@ -1167,9 +1167,6 @@ test("ash_unittests") {
11671167
"common/frame/custom_frame_view_ash_unittest.cc",
11681168
"common/frame/default_header_painter_unittest.cc",
11691169

1170-
# TODO: convert to use AshTest http://crbug.com/654491.
1171-
"common/material_design/material_design_controller_unittest.cc",
1172-
11731170
# TODO: convert to use AshTest http://crbug.com/654492.
11741171
"common/metrics/pointer_metrics_recorder_unittest.cc",
11751172

ash/common/ash_switches.cc

-7
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,6 @@ const char kAshForceEnablePalette[] = "ash-force-enable-palette";
7373
const char kAshHideNotificationsForFactory[] =
7474
"ash-hide-notifications-for-factory";
7575

76-
// Specifies if Material Design elements in Chrome OS system UI are enabled.
77-
// Can be disabled / enabled / experimental allowing to launch incrementally.
78-
const char kAshMaterialDesign[] = "ash-md";
79-
const char kAshMaterialDesignDisabled[] = "disabled";
80-
const char kAshMaterialDesignEnabled[] = "enabled";
81-
const char kAshMaterialDesignExperimental[] = "experimental";
82-
8376
// Enables the heads-up display for tracking touch points.
8477
const char kAshTouchHud[] = "ash-touch-hud";
8578

ash/common/ash_switches.h

-4
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ ASH_EXPORT extern const char kAshEnableTouchView[];
3131
ASH_EXPORT extern const char kAshEnableMirroredScreen[];
3232
ASH_EXPORT extern const char kAshForceEnablePalette[];
3333
ASH_EXPORT extern const char kAshHideNotificationsForFactory[];
34-
ASH_EXPORT extern const char kAshMaterialDesign[];
35-
ASH_EXPORT extern const char kAshMaterialDesignDisabled[];
36-
ASH_EXPORT extern const char kAshMaterialDesignEnabled[];
37-
ASH_EXPORT extern const char kAshMaterialDesignExperimental[];
3834
ASH_EXPORT extern const char kAshTouchHud[];
3935
ASH_EXPORT extern const char kAuraLegacyPowerButton[];
4036

ash/common/material_design/material_design_controller.cc

+6-81
Original file line numberDiff line numberDiff line change
@@ -2,105 +2,30 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
#include <string>
6-
7-
#include "ash/common/ash_switches.h"
85
#include "ash/common/material_design/material_design_controller.h"
9-
#include "base/command_line.h"
10-
#include "base/logging.h"
11-
#include "base/trace_event/trace_event.h"
12-
13-
namespace ash {
14-
15-
namespace {
16-
MaterialDesignController::Mode mode_ =
17-
MaterialDesignController::Mode::UNINITIALIZED;
18-
} // namespace
196

20-
// static
21-
void MaterialDesignController::Initialize() {
22-
TRACE_EVENT0("startup", "ash::MaterialDesignController::InitializeMode");
23-
DCHECK_EQ(mode_, Mode::UNINITIALIZED);
24-
25-
const std::string switch_value =
26-
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
27-
ash::switches::kAshMaterialDesign);
28-
29-
if (switch_value == ash::switches::kAshMaterialDesignExperimental) {
30-
SetMode(Mode::MATERIAL_EXPERIMENTAL);
31-
} else if (switch_value == ash::switches::kAshMaterialDesignEnabled) {
32-
SetMode(Mode::MATERIAL_NORMAL);
33-
} else if (switch_value == ash::switches::kAshMaterialDesignDisabled) {
34-
SetMode(Mode::NON_MATERIAL);
35-
} else {
36-
if (!switch_value.empty()) {
37-
LOG(ERROR) << "Invalid value='" << switch_value
38-
<< "' for command line switch '"
39-
<< ash::switches::kAshMaterialDesign << "'.";
40-
}
41-
SetMode(DefaultMode());
42-
}
43-
}
7+
#include <string>
448

45-
// static
46-
MaterialDesignController::Mode MaterialDesignController::GetMode() {
47-
DCHECK_NE(mode_, Mode::UNINITIALIZED);
48-
return mode_;
49-
}
9+
namespace ash {
5010

5111
// static
5212
bool MaterialDesignController::IsShelfMaterial() {
53-
return IsMaterial();
13+
return true;
5414
}
5515

5616
// static
5717
bool MaterialDesignController::IsImmersiveModeMaterial() {
58-
return IsMaterial();
18+
return true;
5919
}
6020

6121
// static
6222
bool MaterialDesignController::IsSystemTrayMenuMaterial() {
63-
return IsMaterial();
23+
return true;
6424
}
6525

6626
// static
6727
bool MaterialDesignController::UseMaterialDesignSystemIcons() {
68-
return IsMaterial();
69-
}
70-
71-
// static
72-
MaterialDesignController::Mode MaterialDesignController::mode() {
73-
return mode_;
74-
}
75-
76-
// static
77-
bool MaterialDesignController::IsMaterial() {
78-
return IsMaterialExperimental() || IsMaterialNormal();
79-
}
80-
81-
// static
82-
bool MaterialDesignController::IsMaterialNormal() {
83-
return GetMode() == Mode::MATERIAL_NORMAL;
84-
}
85-
86-
// static
87-
bool MaterialDesignController::IsMaterialExperimental() {
88-
return GetMode() == Mode::MATERIAL_EXPERIMENTAL;
89-
}
90-
91-
// static
92-
MaterialDesignController::Mode MaterialDesignController::DefaultMode() {
93-
return Mode::MATERIAL_NORMAL;
94-
}
95-
96-
// static
97-
void MaterialDesignController::SetMode(Mode mode) {
98-
mode_ = mode;
99-
}
100-
101-
// static
102-
void MaterialDesignController::Uninitialize() {
103-
mode_ = Mode::UNINITIALIZED;
28+
return true;
10429
}
10530

10631
} // namespace ash

ash/common/material_design/material_design_controller.h

+5-60
Original file line numberDiff line numberDiff line change
@@ -10,81 +10,26 @@
1010

1111
namespace ash {
1212

13-
namespace test {
14-
class MaterialDesignControllerTestAPI;
15-
} // namespace test
16-
17-
// Central controller to handle material design modes.
13+
// TODO(estade): deprecated, remove: crbug.com/690957
1814
class ASH_EXPORT MaterialDesignController {
1915
public:
20-
// The different material design modes for Chrome OS system UI.
21-
enum Mode {
22-
// Not initialized.
23-
UNINITIALIZED = -1,
24-
// Classic, non-material design.
25-
NON_MATERIAL = 0,
26-
// Basic material design.
27-
MATERIAL_NORMAL = 1,
28-
// Material design with experimental features.
29-
MATERIAL_EXPERIMENTAL = 2
30-
};
31-
32-
// Initializes |mode_|. Must be called before calling IsMaterial(),
33-
// IsMaterialExperimental(), IsMaterialNormal(), or GetMode().
34-
static void Initialize();
35-
36-
// Returns the currently initialized MaterialDesignController::Mode type for
37-
// Chrome OS system UI.
38-
static Mode GetMode();
39-
40-
// Returns true if Material Design features are enabled for Chrome OS shelf.
16+
// Returns true.
4117
static bool IsShelfMaterial();
4218

43-
// Returns true if Material Design features are enabled for Chrome OS
44-
// immersive mode.
19+
// Returns true.
4520
static bool IsImmersiveModeMaterial();
4621

47-
// Returns true if Material Design features are enabled for Chrome OS system
48-
// tray menu.
22+
// Returns true.
4923
static bool IsSystemTrayMenuMaterial();
5024

51-
// Returns true if material design versions of icons should be used in the
52-
// status tray and system menu.
25+
// Returns true.
5326
static bool UseMaterialDesignSystemIcons();
5427

5528
private:
56-
friend class test::MaterialDesignControllerTestAPI;
57-
5829
// Declarations only. Do not allow construction of an object.
5930
MaterialDesignController();
6031
~MaterialDesignController();
6132

62-
// Material Design |Mode| for Chrome OS system UI. Used only by tests.
63-
static Mode mode();
64-
65-
// Returns true if Material Design is enabled in Chrome OS system UI.
66-
// Maps to "ash-md" flag "enabled" or "experimental" values.
67-
static bool IsMaterial();
68-
69-
// Returns true if Material Design normal features are enabled in Chrome OS
70-
// system UI. Maps to "--ash-md=enabled" command line switch value.
71-
static bool IsMaterialNormal();
72-
73-
// Returns true if Material Design experimental features are enabled in
74-
// Chrome OS system UI. Maps to "--ash-md=experimental" command line switch
75-
// value.
76-
static bool IsMaterialExperimental();
77-
78-
// Returns the per-platform default material design variant.
79-
static Mode DefaultMode();
80-
81-
// Sets |mode_| to |mode|. Can be used by tests to directly set the mode.
82-
static void SetMode(Mode mode);
83-
84-
// Resets the initialization state to uninitialized. To be used by tests to
85-
// allow calling Initialize() more than once.
86-
static void Uninitialize();
87-
8833
DISALLOW_COPY_AND_ASSIGN(MaterialDesignController);
8934
};
9035

ash/common/material_design/material_design_controller_unittest.cc

-135
This file was deleted.

ash/common/shelf/shelf_constants.cc

+3-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#include "ash/common/shelf/shelf_constants.h"
66

7-
#include "ash/common/material_design/material_design_controller.h"
87
#include "base/logging.h"
98
#include "third_party/skia/include/core/SkColor.h"
109

@@ -32,10 +31,9 @@ int GetShelfConstant(ShelfConstant shelf_constant) {
3231
const int kShelfButtonSize[] = {44, 48, 48};
3332
const int kShelfInsetsForAutoHide[] = {3, 0, 0};
3433

35-
const int mode = MaterialDesignController::GetMode();
36-
DCHECK(mode >= MaterialDesignController::NON_MATERIAL &&
37-
mode <= MaterialDesignController::MATERIAL_EXPERIMENTAL);
38-
34+
// TODO(estade): clean this up --- remove unneeded constants and reduce
35+
// remaining arrays to a single constant.
36+
const int mode = 1;
3937
switch (shelf_constant) {
4038
case SHELF_SIZE:
4139
return kShelfSize[mode];

0 commit comments

Comments
 (0)