Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1936)

Unified Diff: ash/material_design/material_design_controller.cc

Issue 1921133002: Adds ash::MaterialDesignController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adds ash::MaterialDesignController (unit_tests) Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ash/material_design/material_design_controller.cc
diff --git a/ash/material_design/material_design_controller.cc b/ash/material_design/material_design_controller.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7f55b9fa9c633a507fe27146a0a809d8bfa259a7
--- /dev/null
+++ b/ash/material_design/material_design_controller.cc
@@ -0,0 +1,76 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <string>
+
+#include "ash/ash_switches.h"
+#include "ash/material_design/material_design_controller.h"
+#include "base/command_line.h"
+#include "base/logging.h"
+#include "base/trace_event/trace_event.h"
+
+namespace ash {
+
+namespace {
+MaterialDesignController::Mode g_mode =
oshima 2016/04/27 21:51:04 mode_ per https://www.chromium.org/developers/cod
varkha 2016/04/27 22:14:00 Done.
+ MaterialDesignController::Mode::UNINITIALIZED;
+} // namespace
+
+// static
+void MaterialDesignController::Initialize() {
+ TRACE_EVENT0("startup", "ash::MaterialDesignController::InitializeMode");
+ CHECK_EQ(Mode::UNINITIALIZED, g_mode);
+
+ const std::string switch_value =
+ base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ ash::switches::kAshMaterialDesign);
+
+ if (switch_value == ash::switches::kAshMaterialDesignExperimental) {
+ SetMode(Mode::MATERIAL_EXPERIMENTAL);
+ } else if (switch_value == ash::switches::kAshMaterialDesignEnabled) {
+ SetMode(Mode::MATERIAL_NORMAL);
+ } else if (switch_value == ash::switches::kAshMaterialDesignDisabled) {
+ SetMode(Mode::NON_MATERIAL);
+ } else {
+ if (!switch_value.empty()) {
+ LOG(ERROR) << "Invalid value='" << switch_value
+ << "' for command line switch '"
+ << ash::switches::kAshMaterialDesign << "'.";
+ }
+ SetMode(DefaultMode());
+ }
+}
+
+// static
+bool MaterialDesignController::IsMaterial() {
+ return IsMaterialExperimental() || g_mode == Mode::MATERIAL_NORMAL;
+}
+
+// static
+bool MaterialDesignController::IsMaterialExperimental() {
+ CHECK_NE(Mode::UNINITIALIZED, g_mode);
+ return g_mode == Mode::MATERIAL_EXPERIMENTAL;
+}
+
+// static
+MaterialDesignController::Mode mode() {
+ return g_mode;
+}
+
+// static
+MaterialDesignController::Mode MaterialDesignController::DefaultMode() {
+ return Mode::NON_MATERIAL;
+}
+
+// static
+void MaterialDesignController::SetMode(Mode mode) {
+ g_mode = mode;
+}
+
+// static
+void MaterialDesignController::Uninitialize() {
+ g_mode = Mode::UNINITIALIZED;
+}
+
+} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698