Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: athena/input/power_button_controller.h

Issue 654343002: Intorduce PowerButtonObserver API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: speculative fix Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « athena/input/input_manager_unittest.cc ('k') | athena/input/power_button_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: athena/input/power_button_controller.h
diff --git a/athena/input/power_button_controller.h b/athena/input/power_button_controller.h
new file mode 100644
index 0000000000000000000000000000000000000000..7550fc43689ff327043fca38b380d0509e777600
--- /dev/null
+++ b/athena/input/power_button_controller.h
@@ -0,0 +1,56 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ATHENA_INPUT_POWER_BUTTON_CONTROLLER_H_
+#define ATHENA_INPUT_POWER_BUTTON_CONTROLLER_H_
+
+#include "athena/input/public/accelerator_manager.h"
+#include "athena/input/public/input_manager.h"
+#include "base/observer_list.h"
+#include "base/timer/timer.h"
+#include "chromeos/dbus/power_manager_client.h"
+
+namespace athena {
+
+class PowerButtonController : public chromeos::PowerManagerClient::Observer,
+ public AcceleratorHandler {
+ public:
+ PowerButtonController();
+ virtual ~PowerButtonController();
+
+ void AddPowerButtonObserver(PowerButtonObserver* observer);
+ void RemovePowerButtonObserver(PowerButtonObserver* observer);
+
+ void InstallAccelerators();
+
+ // A timer callabck to notify the long press event.
+ int SetPowerButtonTimeoutMsForTest(int timeout);
+
+ private:
+ // chromeos::PowerManagerClient::Observer:
+ virtual void BrightnessChanged(int level, bool user_initiated) override;
+ virtual void PowerButtonEventReceived(
+ bool down,
+ const base::TimeTicks& timestamp) override;
+
+ // AcceleratorHandler:
+ virtual bool IsCommandEnabled(int command_id) const override;
+ virtual bool OnAcceleratorFired(int command_id,
+ const ui::Accelerator& accelerator) override;
+
+ void NotifyLongPress();
+
+ int power_button_timeout_ms_;
+ ObserverList<PowerButtonObserver> observers_;
+ // The last time at which the screen brightness was 0%.
+ base::TimeTicks zero_brightness_end_time_;
+ bool brightness_is_zero_;
+ base::OneShotTimer<PowerButtonController> timer_;
+
+ DISALLOW_COPY_AND_ASSIGN(PowerButtonController);
+};
+
+} // namespace athena
+
+#endif // ATHENA_INPUT_POWER_BUTTON_CONTROLLER_H_
« no previous file with comments | « athena/input/input_manager_unittest.cc ('k') | athena/input/power_button_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698