OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include <string> |
| 6 |
| 7 #include "ash/ash_switches.h" |
| 8 #include "ash/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 { |
| 14 |
| 15 namespace { |
| 16 MaterialDesignController::Mode g_mode = |
| 17 MaterialDesignController::Mode::UNINITIALIZED; |
| 18 } // namespace |
| 19 |
| 20 // static |
| 21 void MaterialDesignController::Initialize() { |
| 22 TRACE_EVENT0("startup", "ash::MaterialDesignController::InitializeMode"); |
| 23 CHECK_EQ(Mode::UNINITIALIZED, g_mode); |
| 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 bool MaterialDesignController::IsMaterial() { |
| 47 CHECK_NE(Mode::UNINITIALIZED, g_mode); |
| 48 return g_mode == Mode::MATERIAL_NORMAL || |
| 49 g_mode == Mode::MATERIAL_EXPERIMENTAL; |
| 50 } |
| 51 |
| 52 // static |
| 53 bool MaterialDesignController::IsMaterialExperimental() { |
| 54 CHECK_NE(Mode::UNINITIALIZED, g_mode); |
| 55 return g_mode == Mode::MATERIAL_EXPERIMENTAL; |
| 56 } |
| 57 |
| 58 // static |
| 59 MaterialDesignController::Mode mode() { |
| 60 return g_mode; |
| 61 } |
| 62 |
| 63 // static |
| 64 MaterialDesignController::Mode MaterialDesignController::DefaultMode() { |
| 65 return Mode::NON_MATERIAL; |
| 66 } |
| 67 |
| 68 // static |
| 69 void MaterialDesignController::SetMode(Mode mode) { |
| 70 g_mode = mode; |
| 71 } |
| 72 |
| 73 // static |
| 74 void MaterialDesignController::Uninitialize() { |
| 75 g_mode = Mode::UNINITIALIZED; |
| 76 } |
| 77 |
| 78 } // namespace ui |
OLD | NEW |