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

Side by Side Diff: athena/system/power_button_controller.h

Issue 585623003: [Athena] Make a quick power button tap suspend the device (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 unified diff | Download patch
« no previous file with comments | « athena/screen/screen_manager_impl.cc ('k') | athena/system/power_button_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef ATHENA_SYSTEM_POWER_BUTTON_CONTROLLER_H_ 5 #ifndef ATHENA_SYSTEM_POWER_BUTTON_CONTROLLER_H_
6 #define ATHENA_SYSTEM_POWER_BUTTON_CONTROLLER_H_ 6 #define ATHENA_SYSTEM_POWER_BUTTON_CONTROLLER_H_
7 7
8 #include "base/memory/scoped_ptr.h"
8 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "base/timer/timer.h"
9 #include "chromeos/dbus/power_manager_client.h" 11 #include "chromeos/dbus/power_manager_client.h"
10 #include "ui/compositor/layer_animation_observer.h" 12
11 #include "ui/gfx/animation/tween.h" 13 namespace aura {
14 class Window;
15 }
16
17 namespace views {
18 class Widget;
19 }
12 20
13 namespace athena { 21 namespace athena {
14 22
15 // Shuts down in response to the power button being pressed. 23 // Shuts down in response to the power button being pressed.
16 class PowerButtonController : public chromeos::PowerManagerClient::Observer, 24 class PowerButtonController : public chromeos::PowerManagerClient::Observer {
17 public ui::ImplicitAnimationObserver {
18 public: 25 public:
19 PowerButtonController(); 26 explicit PowerButtonController(aura::Window* dialog_container);
20 virtual ~PowerButtonController(); 27 virtual ~PowerButtonController();
21 28
22 private: 29 private:
23 enum State { 30 enum State {
24 // The screen is animating prior to shutdown. Shutdown can be canceled. 31 // Releasing the power button sends a suspend request.
25 STATE_PRE_SHUTDOWN_ANIMATION, 32 STATE_SUSPEND_ON_RELEASE,
33
34 // A warning that the device is about to be shutdown is visible. Releasing
35 // the power button does not send a suspend or a shutdown request.
36 STATE_SHUTDOWN_WARNING_VISIBLE,
26 37
27 // A D-Bus shutdown request has been sent. Shutdown cannot be canceled. 38 // A D-Bus shutdown request has been sent. Shutdown cannot be canceled.
28 STATE_SHUTDOWN_REQUESTED, 39 STATE_SHUTDOWN_REQUESTED,
29 40
30 STATE_OTHER 41 STATE_OTHER
31 }; 42 };
32 43
33 // Animates the screen's grayscale and brightness to |target|. 44 // Shows the shutdown warning dialog.
34 void StartGrayscaleAndBrightnessAnimation(float target, 45 void ShowShutdownWarningDialog();
35 int duration_ms, 46
36 gfx::Tween::Type tween_type); 47 // Requests shutdown.
48 void Shutdown();
37 49
38 // chromeos::PowerManagerClient::Observer: 50 // chromeos::PowerManagerClient::Observer:
39 virtual void BrightnessChanged(int level, bool user_initiated) OVERRIDE; 51 virtual void BrightnessChanged(int level, bool user_initiated) OVERRIDE;
40 virtual void PowerButtonEventReceived( 52 virtual void PowerButtonEventReceived(
41 bool down, 53 bool down,
42 const base::TimeTicks& timestamp) OVERRIDE; 54 const base::TimeTicks& timestamp) OVERRIDE;
43 55
44 // ui::ImplicitAnimationObserver: 56 // |shutdown_warning_message_|'s parent container.
45 virtual void OnImplicitAnimationsCompleted() OVERRIDE; 57 aura::Window* warning_message_container_;
58
59 // Shows a warning that the device is about to be shutdown.
60 scoped_ptr<views::Widget> shutdown_warning_message_;
46 61
47 // Whether the screen brightness was reduced to 0%. 62 // Whether the screen brightness was reduced to 0%.
48 bool brightness_is_zero_; 63 bool brightness_is_zero_;
49 64
50 // The last time at which the screen brightness was 0%. 65 // The last time at which the screen brightness was 0%.
51 base::TimeTicks zero_brightness_end_time_; 66 base::TimeTicks zero_brightness_end_time_;
52 67
53 State state_; 68 State state_;
54 69
70 base::OneShotTimer<PowerButtonController> timer_;
71
55 DISALLOW_COPY_AND_ASSIGN(PowerButtonController); 72 DISALLOW_COPY_AND_ASSIGN(PowerButtonController);
56 }; 73 };
57 74
58 } // namespace athena 75 } // namespace athena
59 76
60 #endif // ATHENA_SYSTEM_POWER_BUTTON_CONTROLLER_H_ 77 #endif // ATHENA_SYSTEM_POWER_BUTTON_CONTROLLER_H_
OLDNEW
« no previous file with comments | « athena/screen/screen_manager_impl.cc ('k') | athena/system/power_button_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698