blob: 6fdffbb9ab0a571717550028cde5fc616ef9b637 [file] [log] [blame]
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/macros.h"
#include "ui/base/ui_base_export.h"
namespace ui {
namespace test {
class MaterialDesignControllerTestAPI;
} // namespace test
// Central controller to handle material design modes.
class UI_BASE_EXPORT MaterialDesignController {
// The different material design modes. The order cannot be changed without
// updating references as these are used as array indices.
enum Mode {
// Basic material design.
// Material design targeted at mouse/touch hybrid devices.
// Initializes |mode_|. Must be called before checking |mode_|.
static void Initialize();
// Get the current Mode that should be used by the system.
static Mode GetMode();
// Returns true if the current mode is a material design variant and this mode
// should be extended to cover secondary UI.
static bool IsSecondaryUiMaterial();
// Returns the per-platform default material design variant.
static Mode DefaultMode();
static bool is_mode_initialized() { return is_mode_initialized_; }
friend class test::MaterialDesignControllerTestAPI;
// Tracks whether |mode_| has been initialized. This is necessary to avoid
// checking the |mode_| early in initialization before a call to Initialize().
// Tests can use it to reset the state back to a clean state during tear down.
static bool is_mode_initialized_;
// The current Mode to be used by the system.
static Mode mode_;
// True when |mode_| applies beyond the primary UI (toolbar, tabstrip,
// etc.). For example, this controls use of MD inside bubbles and dialogs.
static bool include_secondary_ui_;
// Declarations only. Do not allow construction of an object.
// Resets the initialization state to uninitialized. To be used by tests to
// allow calling Initialize() more than once.
static void Uninitialize();
// Set |mode_| to |mode| and updates |is_mode_initialized_| to true. Can be
// used by tests to directly set the mode.
static void SetMode(Mode mode);
} // namespace ui