1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 #include "base/command_line.h"
8 #include "base/logging.h"
9 #include "ui/base/resource/material_design/material_design_controller.h"
10 #include "ui/base/ui_base_switches.h"
14 bool MaterialDesignController::is_mode_initialized_
= false;
16 MaterialDesignController::Mode
MaterialDesignController::mode_
=
17 MaterialDesignController::Mode::NON_MATERIAL
;
19 MaterialDesignController::Mode
MaterialDesignController::GetMode() {
20 if (!is_mode_initialized_
)
22 CHECK(is_mode_initialized_
);
26 bool MaterialDesignController::IsModeMaterial() {
27 return GetMode() == Mode::MATERIAL_NORMAL
||
28 GetMode() == Mode::MATERIAL_HYBRID
;
31 void MaterialDesignController::InitializeMode() {
32 #if !defined(ENABLE_TOPCHROME_MD)
33 SetMode(Mode::NON_MATERIAL
);
35 const std::string switch_value
=
36 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
37 switches::kTopChromeMD
);
39 if (switch_value
== switches::kTopChromeMDMaterial
) {
40 SetMode(Mode::MATERIAL_NORMAL
);
41 } else if (switch_value
== switches::kTopChromeMDMaterialHybrid
) {
42 SetMode(Mode::MATERIAL_HYBRID
);
43 } else if (switch_value
== switches::kTopChromeMDNonMaterial
) {
44 SetMode(Mode::NON_MATERIAL
);
46 LOG(ERROR
) << "Invalid value='" << switch_value
47 << "' for command line switch '" << switches::kTopChromeMD
49 SetMode(Mode::NON_MATERIAL
);
51 #endif // !defined(ENABLE_TOPCHROME_MD)
54 void MaterialDesignController::UninitializeMode() {
55 MaterialDesignController::SetMode(
56 MaterialDesignController::Mode::NON_MATERIAL
);
57 is_mode_initialized_
= false;
60 void MaterialDesignController::SetMode(MaterialDesignController::Mode mode
) {
62 is_mode_initialized_
= true;