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