Chromium Code Reviews| 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 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, mode_); | |
|
oshima
2016/04/27 22:26:22
nit: DCHECK_EQ (sorry if I typed this)
varkha
2016/04/27 22:30:05
I actually wanted this to assert in release builds
oshima
2016/04/27 22:58:44
CHECK is for security/privacy issue, or you need d
varkha
2016/04/27 23:10:31
Done.
| |
| 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 return IsMaterialExperimental() || mode_ == Mode::MATERIAL_NORMAL; | |
| 48 } | |
| 49 | |
| 50 // static | |
| 51 bool MaterialDesignController::IsMaterialExperimental() { | |
| 52 CHECK_NE(Mode::UNINITIALIZED, mode_); | |
|
oshima
2016/04/27 22:26:22
nit: ditto.
varkha
2016/04/27 22:30:05
Acknowledged.
| |
| 53 return mode_ == Mode::MATERIAL_EXPERIMENTAL; | |
| 54 } | |
| 55 | |
| 56 // static | |
| 57 MaterialDesignController::Mode MaterialDesignController::mode() { | |
| 58 return mode_; | |
| 59 } | |
| 60 | |
| 61 // static | |
| 62 MaterialDesignController::Mode MaterialDesignController::DefaultMode() { | |
| 63 return Mode::NON_MATERIAL; | |
| 64 } | |
| 65 | |
| 66 // static | |
| 67 void MaterialDesignController::SetMode(Mode mode) { | |
| 68 mode_ = mode; | |
| 69 } | |
| 70 | |
| 71 // static | |
| 72 void MaterialDesignController::Uninitialize() { | |
| 73 mode_ = Mode::UNINITIALIZED; | |
| 74 } | |
| 75 | |
| 76 } // namespace ui | |
| OLD | NEW |