1 // Copyright 2013 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.
5 #ifndef ASH_SYSTEM_CHROMEOS_POWER_POWER_EVENT_OBSERVER_H_
6 #define ASH_SYSTEM_CHROMEOS_POWER_POWER_EVENT_OBSERVER_H_
8 #include "ash/ash_export.h"
9 #include "base/basictypes.h"
10 #include "base/callback.h"
11 #include "base/compiler_specific.h"
12 #include "chromeos/dbus/power_manager_client.h"
13 #include "chromeos/dbus/session_manager_client.h"
17 // A class that observes power-management-related events.
18 class ASH_EXPORT PowerEventObserver
19 : public chromeos::PowerManagerClient::Observer
,
20 public chromeos::SessionManagerClient::Observer
{
22 // This class registers/unregisters itself as an observer in ctor/dtor.
24 ~PowerEventObserver() override
;
26 // Called by the WebUIScreenLocker when all the lock screen animations have
27 // completed. This really should be implemented via an observer but since
28 // ash/ isn't allowed to depend on chrome/ we need to have the
29 // WebUIScreenLocker reach into ash::Shell to make this call.
30 void OnLockAnimationsComplete();
32 // chromeos::PowerManagerClient::Observer overrides:
33 void BrightnessChanged(int level
, bool user_initiated
) override
;
34 void SuspendImminent() override
;
35 void SuspendDone(const base::TimeDelta
& sleep_duration
) override
;
37 // chromeos::SessionManagerClient::Observer overrides.
38 void ScreenIsLocked() override
;
39 void ScreenIsUnlocked() override
;
41 // Is the screen currently locked?
44 // Have the lock screen animations completed?
45 bool waiting_for_lock_screen_animations_
;
47 // If set, called when the lock screen animations have completed to confirm
48 // that the system is ready to be suspended.
49 base::Closure screen_lock_callback_
;
52 DISALLOW_COPY_AND_ASSIGN(PowerEventObserver
);
55 } // namespace chromeos
57 #endif // ASH_SYSTEM_CHROMEOS_POWER_POWER_EVENT_OBSERVER_H_