power_button_observer.h revision 5821806d5e7f356e8fa4b058a389a808ea183019
1// Copyright (c) 2012 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_POWER_BUTTON_OBSERVER_H_
6#define CHROME_BROWSER_CHROMEOS_POWER_POWER_BUTTON_OBSERVER_H_
7
8#include "base/basictypes.h"
9#include "base/compiler_specific.h"
10#include "chromeos/dbus/power_manager_client.h"
11#include "chromeos/dbus/session_manager_client.h"
12#include "content/public/browser/notification_observer.h"
13#include "content/public/browser/notification_registrar.h"
14
15namespace chromeos {
16
17// Listens for power button, login, and screen lock events and passes them to
18// the Aura shell's PowerButtonController class.
19class PowerButtonObserver : public content::NotificationObserver,
20                            public PowerManagerClient::Observer,
21                            public SessionManagerClient::Observer {
22 public:
23  // This class registers/unregisters itself as an observer in ctor/dtor.
24  PowerButtonObserver();
25  virtual ~PowerButtonObserver();
26
27 private:
28  // content::NotificationObserver implementation:
29  virtual void Observe(int type,
30                       const content::NotificationSource& source,
31                       const content::NotificationDetails& details) OVERRIDE;
32
33  // PowerManagerClient::Observer implementation.
34  virtual void PowerButtonStateChanged(
35      bool down, const base::TimeTicks& timestamp) OVERRIDE;
36  virtual void LockButtonStateChanged(
37      bool down, const base::TimeTicks& timestamp) OVERRIDE;
38
39  // SessionManagerClient::Observer implementation.
40  virtual void LockScreen() OVERRIDE;
41
42  content::NotificationRegistrar registrar_;
43
44  DISALLOW_COPY_AND_ASSIGN(PowerButtonObserver);
45};
46
47}  // namespace chromeos
48
49#endif  // CHROME_BROWSER_CHROMEOS_POWER_POWER_BUTTON_OBSERVER_H_
50