| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 ASH_WM_POWER_BUTTON_CONTROLLER_H_ | 5 #ifndef ASH_WM_POWER_BUTTON_CONTROLLER_H_ |
| 6 #define ASH_WM_POWER_BUTTON_CONTROLLER_H_ | 6 #define ASH_WM_POWER_BUTTON_CONTROLLER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "ash/ash_export.h" | 9 #include "ash/ash_export.h" |
| 10 #include "ash/shell_observer.h" |
| 10 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/time.h" | 13 #include "base/time.h" |
| 13 #include "base/timer.h" | 14 #include "base/timer.h" |
| 14 #include "ui/aura/root_window_observer.h" | 15 #include "ui/aura/root_window_observer.h" |
| 15 | 16 |
| 16 namespace gfx { | 17 namespace gfx { |
| 17 class Size; | 18 class Size; |
| 18 } | 19 } |
| 19 | 20 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 31 | 32 |
| 32 virtual void RequestLockScreen() = 0; | 33 virtual void RequestLockScreen() = 0; |
| 33 virtual void RequestShutdown() = 0; | 34 virtual void RequestShutdown() = 0; |
| 34 | 35 |
| 35 private: | 36 private: |
| 36 DISALLOW_COPY_AND_ASSIGN(PowerButtonControllerDelegate); | 37 DISALLOW_COPY_AND_ASSIGN(PowerButtonControllerDelegate); |
| 37 }; | 38 }; |
| 38 | 39 |
| 39 // Displays onscreen animations and locks or suspends the system in response to | 40 // Displays onscreen animations and locks or suspends the system in response to |
| 40 // the power button being pressed or released. | 41 // the power button being pressed or released. |
| 41 class ASH_EXPORT PowerButtonController : public aura::RootWindowObserver { | 42 class ASH_EXPORT PowerButtonController : public aura::RootWindowObserver, |
| 43 public ShellObserver { |
| 42 public: | 44 public: |
| 43 // Animations that can be applied to groups of containers. | 45 // Animations that can be applied to groups of containers. |
| 44 // Exposed here for TestApi::ContainerGroupIsAnimated(). | 46 // Exposed here for TestApi::ContainerGroupIsAnimated(). |
| 45 enum AnimationType { | 47 enum AnimationType { |
| 46 ANIMATION_SLOW_CLOSE = 0, | 48 ANIMATION_SLOW_CLOSE = 0, |
| 47 ANIMATION_UNDO_SLOW_CLOSE, | 49 ANIMATION_UNDO_SLOW_CLOSE, |
| 48 ANIMATION_FAST_CLOSE, | 50 ANIMATION_FAST_CLOSE, |
| 49 ANIMATION_FADE_IN, | 51 ANIMATION_FADE_IN, |
| 50 ANIMATION_HIDE, | 52 ANIMATION_HIDE, |
| 51 ANIMATION_RESTORE, | 53 ANIMATION_RESTORE, |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 virtual ~PowerButtonController(); | 130 virtual ~PowerButtonController(); |
| 129 | 131 |
| 130 void set_delegate(PowerButtonControllerDelegate* delegate) { | 132 void set_delegate(PowerButtonControllerDelegate* delegate) { |
| 131 delegate_.reset(delegate); | 133 delegate_.reset(delegate); |
| 132 } | 134 } |
| 133 | 135 |
| 134 void set_has_legacy_power_button_for_test(bool legacy) { | 136 void set_has_legacy_power_button_for_test(bool legacy) { |
| 135 has_legacy_power_button_ = legacy; | 137 has_legacy_power_button_ = legacy; |
| 136 } | 138 } |
| 137 | 139 |
| 138 // Called when the user logs in. | |
| 139 void OnLoginStateChange(bool logged_in, bool is_guest); | |
| 140 | |
| 141 // Called when the application is exiting. | |
| 142 void OnExit(); | |
| 143 | |
| 144 // Called when the screen is locked (after the lock window is visible) or | |
| 145 // unlocked. | |
| 146 void OnLockStateChange(bool locked); | |
| 147 | |
| 148 // Called when Chrome gets a request to display the lock screen. | 140 // Called when Chrome gets a request to display the lock screen. |
| 149 void OnStartingLock(); | 141 void OnStartingLock(); |
| 150 | 142 |
| 151 // Called when the power or lock buttons are pressed or released. | 143 // Called when the power or lock buttons are pressed or released. |
| 152 void OnPowerButtonEvent(bool down, const base::TimeTicks& timestamp); | 144 void OnPowerButtonEvent(bool down, const base::TimeTicks& timestamp); |
| 153 void OnLockButtonEvent(bool down, const base::TimeTicks& timestamp); | 145 void OnLockButtonEvent(bool down, const base::TimeTicks& timestamp); |
| 154 | 146 |
| 155 // Displays the shutdown animation and requests shutdown when it's done. | 147 // Displays the shutdown animation and requests shutdown when it's done. |
| 156 void RequestShutdown(); | 148 void RequestShutdown(); |
| 157 | 149 |
| 158 // aura::RootWindowObserver overrides: | 150 // aura::RootWindowObserver overrides: |
| 159 virtual void OnRootWindowResized(const aura::RootWindow* root, | 151 virtual void OnRootWindowResized(const aura::RootWindow* root, |
| 160 const gfx::Size& old_size) OVERRIDE; | 152 const gfx::Size& old_size) OVERRIDE; |
| 161 | 153 |
| 154 // ShellObserver overrides: |
| 155 virtual void OnLoginStateChanged(bool logged_in, bool is_guest) OVERRIDE; |
| 156 virtual void OnAppTerminating() OVERRIDE; |
| 157 virtual void OnLockStateChanged(bool locked) OVERRIDE; |
| 158 |
| 162 private: | 159 private: |
| 163 bool logged_in_as_non_guest() const { return logged_in_ && !is_guest_; } | 160 bool logged_in_as_non_guest() const { return logged_in_ && !is_guest_; } |
| 164 | 161 |
| 165 // Requests that the screen be locked and starts |lock_fail_timer_|. | 162 // Requests that the screen be locked and starts |lock_fail_timer_|. |
| 166 void OnLockTimeout(); | 163 void OnLockTimeout(); |
| 167 | 164 |
| 168 // Aborts the pre-lock animation. | 165 // Aborts the pre-lock animation. |
| 169 void OnLockFailTimeout(); | 166 void OnLockFailTimeout(); |
| 170 | 167 |
| 171 // Displays the pre-shutdown animation and starts |shutdown_timer_|. | 168 // Displays the pre-shutdown animation and starts |shutdown_timer_|. |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 // |background_layer_|, as the desktop background is now covering the whole | 247 // |background_layer_|, as the desktop background is now covering the whole |
| 251 // screen. | 248 // screen. |
| 252 base::OneShotTimer<PowerButtonController> hide_background_layer_timer_; | 249 base::OneShotTimer<PowerButtonController> hide_background_layer_timer_; |
| 253 | 250 |
| 254 DISALLOW_COPY_AND_ASSIGN(PowerButtonController); | 251 DISALLOW_COPY_AND_ASSIGN(PowerButtonController); |
| 255 }; | 252 }; |
| 256 | 253 |
| 257 } // namespace ash | 254 } // namespace ash |
| 258 | 255 |
| 259 #endif // ASH_WM_POWER_BUTTON_CONTROLLER_H_ | 256 #endif // ASH_WM_POWER_BUTTON_CONTROLLER_H_ |
| OLD | NEW |