Index: ui/base/material_design/material_design_controller.cc |
diff --git a/ui/base/material_design/material_design_controller.cc b/ui/base/material_design/material_design_controller.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c9abccc4fa317fa78877ee156fead83b4cac2fd9 |
--- /dev/null |
+++ b/ui/base/material_design/material_design_controller.cc |
@@ -0,0 +1,61 @@ |
+// Copyright 2015 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 "base/command_line.h" |
+#include "base/logging.h" |
+#include "ui/base/material_design/material_design_controller.h" |
+#include "ui/base/ui_base_switches.h" |
+ |
+namespace ui { |
+ |
+bool MaterialDesignController::is_look_and_feel_initialized_ = false; |
+ |
+MaterialDesignController::LookAndFeel MaterialDesignController::look_and_feel_ = |
+ MaterialDesignController::LookAndFeel::CLASSIC; |
+ |
+MaterialDesignController::LookAndFeel |
+MaterialDesignController::GetLookAndFeel() { |
+ if (!is_look_and_feel_initialized_) |
+ InitializeLookAndFeel(); |
+ CHECK(is_look_and_feel_initialized_); |
+ return look_and_feel_; |
+} |
+ |
+void MaterialDesignController::InitializeLookAndFeel() { |
+#if !defined(ENABLE_TOPCHROME_MD) |
+ SetLookAndFeel(LookAndFeel::CLASSIC); |
+#else |
+ const std::string switch_value = |
+ base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
+ switches::kTopChromeMD); |
+ |
+ if (switch_value == switches::kTopChromeMDEnabled) { |
+ SetLookAndFeel(LookAndFeel::MATERIAL); |
+ } else if (switch_value == switches::kTopChromeMDHybridEnabled) { |
+ SetLookAndFeel(LookAndFeel::HYBRID); |
+ } else if (switch_value == switches::kTopChromeMDDisabled || |
+ switch_value == switches::kTopChromeMDDefault) { |
+ SetLookAndFeel(LookAndFeel::CLASSIC); |
+ } else { |
+ NOTREACHED(); |
tdanderson
2015/06/18 20:54:23
Consider including a message here (NOTREACHED() <<
bruthig
2015/06/22 18:51:11
Done.
|
+ SetLookAndFeel(LookAndFeel::CLASSIC); |
+ } |
+#endif // !defined(ENABLE_TOPCHROME_MD) |
+} |
+ |
+void MaterialDesignController::UninitializeLookAndFeel() { |
+ MaterialDesignController::SetLookAndFeel( |
+ MaterialDesignController::LookAndFeel::CLASSIC); |
+ is_look_and_feel_initialized_ = false; |
+} |
+ |
+void MaterialDesignController::SetLookAndFeel( |
+ MaterialDesignController::LookAndFeel look_and_feel) { |
+ look_and_feel_ = look_and_feel; |
+ is_look_and_feel_initialized_ = true; |
+} |
+ |
+} // namespace ui |