[M108 Migration] Support standard build for armv7hl architecture
[platform/framework/web/chromium-efl.git] / ash / shutdown_controller_impl.h
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.
4
5 #ifndef ASH_SHUTDOWN_CONTROLLER_IMPL_H_
6 #define ASH_SHUTDOWN_CONTROLLER_IMPL_H_
7
8 #include "ash/ash_export.h"
9 #include "ash/public/cpp/shutdown_controller.h"
10 #include "base/observer_list.h"
11
12 namespace ash {
13
14 enum class ShutdownReason;
15
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 {
19  public:
20   class Observer {
21    public:
22     virtual ~Observer() {}
23
24     // Called when shutdown policy changes.
25     virtual void OnShutdownPolicyChanged(bool reboot_on_shutdown) = 0;
26   };
27
28   ShutdownControllerImpl();
29
30   ShutdownControllerImpl(const ShutdownControllerImpl&) = delete;
31   ShutdownControllerImpl& operator=(const ShutdownControllerImpl&) = delete;
32
33   ~ShutdownControllerImpl() override;
34
35   void AddObserver(Observer* observer);
36   void RemoveObserver(Observer* observer);
37
38   bool reboot_on_shutdown() const { return reboot_on_shutdown_; }
39
40   // ShutdownController:
41   void SetRebootOnShutdown(bool reboot_on_shutdown) override;
42   void ShutDownOrReboot(ShutdownReason reason) override;
43
44  private:
45   // Cached copy of the DeviceRebootOnShutdown policy from chrome.
46   bool reboot_on_shutdown_ = false;
47
48   base::ObserverList<Observer>::Unchecked observers_;
49 };
50
51 }  // namespace ash
52
53 #endif  // ASH_SHUTDOWN_CONTROLLER_IMPL_H_