1 // Copyright (c) 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. 4 5 #ifndef CHROME_BROWSER_CHROMEOS_POWER_SUSPEND_OBSERVER_H_ 6 #define CHROME_BROWSER_CHROMEOS_POWER_SUSPEND_OBSERVER_H_ 7 8 #include "base/basictypes.h" 9 #include "base/callback.h" 10 #include "base/compiler_specific.h" 11 #include "chromeos/dbus/power_manager_client.h" 12 #include "chromeos/dbus/session_manager_client.h" 13 14 namespace chromeos { 15 16 // A class to observe suspend events. 17 class SuspendObserver : public PowerManagerClient::Observer, 18 public SessionManagerClient::Observer { 19 public: 20 // This class registers/unregisters itself as an observer in ctor/dtor. 21 SuspendObserver(); 22 virtual ~SuspendObserver(); 23 24 // PowerManagerClient::Observer override. 25 virtual void SuspendImminent() OVERRIDE; 26 27 // SessionManagerClient::Observer overrides. 28 virtual void ScreenIsLocked() OVERRIDE; 29 virtual void ScreenIsUnlocked() OVERRIDE; 30 31 private: 32 PowerManagerClient* power_client_; // not owned 33 SessionManagerClient* session_client_; // not owned 34 35 // Is the screen currently locked? 36 bool screen_locked_; 37 38 // If set, called when the lock screen has been shown to confirm that the 39 // system is ready to be suspended. 40 base::Closure screen_lock_callback_; 41 42 DISALLOW_COPY_AND_ASSIGN(SuspendObserver); 43 }; 44 45 } // namespace chromeos 46 47 #endif // CHROME_BROWSER_CHROMEOS_POWER_SUSPEND_OBSERVER_H_ 48