| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/common/material_design/material_design_controller.h" |
| 6 |
| 5 #include <string> | 7 #include <string> |
| 6 | 8 |
| 7 #include "ash/common/ash_switches.h" | |
| 8 #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 { | 9 namespace ash { |
| 14 | 10 |
| 15 namespace { | |
| 16 MaterialDesignController::Mode mode_ = | |
| 17 MaterialDesignController::Mode::UNINITIALIZED; | |
| 18 } // namespace | |
| 19 | |
| 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 } | |
| 44 | |
| 45 // static | |
| 46 MaterialDesignController::Mode MaterialDesignController::GetMode() { | |
| 47 DCHECK_NE(mode_, Mode::UNINITIALIZED); | |
| 48 return mode_; | |
| 49 } | |
| 50 | |
| 51 // static | 11 // static |
| 52 bool MaterialDesignController::IsShelfMaterial() { | 12 bool MaterialDesignController::IsShelfMaterial() { |
| 53 return IsMaterial(); | 13 return true; |
| 54 } | 14 } |
| 55 | 15 |
| 56 // static | 16 // static |
| 57 bool MaterialDesignController::IsImmersiveModeMaterial() { | 17 bool MaterialDesignController::IsImmersiveModeMaterial() { |
| 58 return IsMaterial(); | 18 return true; |
| 59 } | 19 } |
| 60 | 20 |
| 61 // static | 21 // static |
| 62 bool MaterialDesignController::IsSystemTrayMenuMaterial() { | 22 bool MaterialDesignController::IsSystemTrayMenuMaterial() { |
| 63 return IsMaterial(); | 23 return true; |
| 64 } | 24 } |
| 65 | 25 |
| 66 // static | 26 // static |
| 67 bool MaterialDesignController::UseMaterialDesignSystemIcons() { | 27 bool MaterialDesignController::UseMaterialDesignSystemIcons() { |
| 68 return IsMaterial(); | 28 return true; |
| 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; | |
| 104 } | 29 } |
| 105 | 30 |
| 106 } // namespace ash | 31 } // namespace ash |
| OLD | NEW |