blob: 2ec2d5f631a9f119a13640924d4df07e98d9b158 [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 "base/observer_list.h"
#include "build/build_config.h"
#include "ui/base/ui_base_export.h"
namespace base {
template <typename T>
class NoDestructor;
namespace gfx {
class SingletonHwndObserver;
namespace ui {
class MaterialDesignControllerObserver;
namespace test {
class MaterialDesignControllerTestAPI;
} // namespace test
// Central controller to handle material design modes.
class UI_BASE_EXPORT MaterialDesignController {
// Initializes touch UI state based on command-line flags.
static void Initialize();
static bool touch_ui() { return touch_ui_; }
// Exposed for TabletModePageBehavior on ChromeOS + ash.
static void OnTabletModeToggled(bool enabled);
static MaterialDesignController* GetInstance();
void AddObserver(MaterialDesignControllerObserver* observer);
void RemoveObserver(MaterialDesignControllerObserver* observer);
friend class base::NoDestructor<MaterialDesignController>;
friend class test::MaterialDesignControllerTestAPI;
~MaterialDesignController() = delete;
// Sets the touch UI state and notifies observers of the state change.
static void SetTouchUi(bool touch_ui);
// Whether the UI layout should be touch-optimized.
static bool touch_ui_;
// Whether |touch_ui_| should toggle on and off depending on the tablet state.
static bool automatic_touch_ui_;
#if defined(OS_WIN)
std::unique_ptr<gfx::SingletonHwndObserver> singleton_hwnd_observer_;
base::ObserverList<MaterialDesignControllerObserver> observers_;
} // namespace ui