Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: ash/material_design/material_design_controller.cc

Issue 1921133002: Adds ash::MaterialDesignController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adds ash::MaterialDesignController (unit_tests) Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 =
oshima 2016/04/27 21:51:04 mode_ per https://www.chromium.org/developers/cod
varkha 2016/04/27 22:14:00 Done.
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 return IsMaterialExperimental() || g_mode == Mode::MATERIAL_NORMAL;
48 }
49
50 // static
51 bool MaterialDesignController::IsMaterialExperimental() {
52 CHECK_NE(Mode::UNINITIALIZED, g_mode);
53 return g_mode == Mode::MATERIAL_EXPERIMENTAL;
54 }
55
56 // static
57 MaterialDesignController::Mode mode() {
58 return g_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 g_mode = mode;
69 }
70
71 // static
72 void MaterialDesignController::Uninitialize() {
73 g_mode = Mode::UNINITIALIZED;
74 }
75
76 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698