1 // Copyright 2016 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef ASH_SHUTDOWN_CONTROLLER_IMPL_H_
6 #define ASH_SHUTDOWN_CONTROLLER_IMPL_H_
8 #include "ash/ash_export.h"
9 #include "ash/public/cpp/shutdown_controller.h"
10 #include "base/observer_list.h"
14 enum class ShutdownReason;
16 // Handles actual device shutdown by making requests to powerd over D-Bus.
17 // Caches the DeviceRebootOnShutdown device policy sent from Chrome.
18 class ASH_EXPORT ShutdownControllerImpl : public ShutdownController {
22 virtual ~Observer() {}
24 // Called when shutdown policy changes.
25 virtual void OnShutdownPolicyChanged(bool reboot_on_shutdown) = 0;
28 ShutdownControllerImpl();
30 ShutdownControllerImpl(const ShutdownControllerImpl&) = delete;
31 ShutdownControllerImpl& operator=(const ShutdownControllerImpl&) = delete;
33 ~ShutdownControllerImpl() override;
35 void AddObserver(Observer* observer);
36 void RemoveObserver(Observer* observer);
38 bool reboot_on_shutdown() const { return reboot_on_shutdown_; }
40 // ShutdownController:
41 void SetRebootOnShutdown(bool reboot_on_shutdown) override;
42 void ShutDownOrReboot(ShutdownReason reason) override;
45 // Cached copy of the DeviceRebootOnShutdown policy from chrome.
46 bool reboot_on_shutdown_ = false;
48 base::ObserverList<Observer>::Unchecked observers_;
53 #endif // ASH_SHUTDOWN_CONTROLLER_IMPL_H_