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

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 (CHECK_* -> DCHECK_*) 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..de6bab83290d20b47ea101f9ddf3b47d5b3edfb1
--- /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 mode_ =
+ MaterialDesignController::Mode::UNINITIALIZED;
+} // namespace
+
+// static
+void MaterialDesignController::Initialize() {
+ TRACE_EVENT0("startup", "ash::MaterialDesignController::InitializeMode");
+ DCHECK_EQ(mode_, Mode::UNINITIALIZED);
+
+ 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() || mode_ == Mode::MATERIAL_NORMAL;
+}
+
+// static
+bool MaterialDesignController::IsMaterialExperimental() {
+ DCHECK_NE(mode_, Mode::UNINITIALIZED);
+ return mode_ == Mode::MATERIAL_EXPERIMENTAL;
+}
+
+// static
+MaterialDesignController::Mode MaterialDesignController::mode() {
+ return mode_;
+}
+
+// static
+MaterialDesignController::Mode MaterialDesignController::DefaultMode() {
+ return Mode::NON_MATERIAL;
+}
+
+// static
+void MaterialDesignController::SetMode(Mode mode) {
+ mode_ = mode;
+}
+
+// static
+void MaterialDesignController::Uninitialize() {
+ mode_ = Mode::UNINITIALIZED;
+}
+
+} // namespace ui
« no previous file with comments | « ash/material_design/material_design_controller.h ('k') | ash/material_design/material_design_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698