Chromium Code Reviews| 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 | 7 |
| 8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
| 9 #include "ash/shell_observer.h" | 9 #include "ash/shell_observer.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 // Exposed here for TestApi::ContainerGroupIsAnimated(). | 46 // Exposed here for TestApi::ContainerGroupIsAnimated(). |
| 47 enum AnimationType { | 47 enum AnimationType { |
| 48 ANIMATION_SLOW_CLOSE = 0, | 48 ANIMATION_SLOW_CLOSE = 0, |
| 49 ANIMATION_UNDO_SLOW_CLOSE, | 49 ANIMATION_UNDO_SLOW_CLOSE, |
| 50 ANIMATION_FAST_CLOSE, | 50 ANIMATION_FAST_CLOSE, |
| 51 ANIMATION_FADE_IN, | 51 ANIMATION_FADE_IN, |
| 52 ANIMATION_HIDE, | 52 ANIMATION_HIDE, |
| 53 ANIMATION_RESTORE, | 53 ANIMATION_RESTORE, |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 // Groups of containers that can be animated. | 56 // Specific containers or group of containers that can be animated. |
|
Daniel Erat
2012/09/04 16:40:18
nit: s/group/groups/
Nikita (slow)
2012/09/04 17:36:42
Done.
| |
| 57 // Exposed here for TestApi::ContainerGroupIsAnimated(). | 57 // Exposed here for TestApi::ContainerGroupIsAnimated(). |
| 58 enum ContainerGroup { | 58 enum ContainerGroup { |
| 59 ALL_CONTAINERS = 0, | 59 DESKTOP_WALLPAPER = 1 << 0, |
|
Daniel Erat
2012/09/04 16:40:18
use consistent terminology: you're using "backgrou
Nikita (slow)
2012/09/04 17:36:42
Done.
| |
| 60 SCREEN_LOCKER_CONTAINERS, | 60 |
| 61 SCREEN_LOCKER_AND_RELATED_CONTAINERS, | 61 // All user session related containers including system background but |
| 62 ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, | 62 // not including desktop background (wallpaper). |
| 63 NON_LOCK_SCREEN_CONTAINERS = 1 << 1, | |
| 64 | |
| 65 // Desktop wallpaper is moved to this layer when screen is locked. | |
|
Daniel Erat
2012/09/04 16:40:18
asked over IM, but perhaps you're not there: i did
Nikita (slow)
2012/09/04 17:36:42
http://codereview.chromium.org/10810039/
Discussed
| |
| 66 // This layer is excluded from lock animation so that wallpaper stays as is, | |
| 67 // user session windows are hidden and lock UI is shown on top of it. | |
| 68 // This layer is included in shutdown animation. | |
| 69 LOCK_SCREEN_WALLPAPER = 1 << 2, | |
|
Daniel Erat
2012/09/04 16:40:18
same background vs. wallpaper issue here
Nikita (slow)
2012/09/04 17:36:42
Done.
| |
| 70 | |
| 71 // Lock screen and lock screen modal containers. | |
| 72 LOCK_SCREEN_CONTAINERS = 1 << 3, | |
| 73 | |
| 74 // Multiple system layers belong here like status, menu, tooltip | |
| 75 // and overlay layers. | |
| 76 LOCK_SCREEN_RELATED_CONTAINERS = 1 << 4, | |
| 63 }; | 77 }; |
| 64 | 78 |
| 65 // Helper class used by tests to access internal state. | 79 // Helper class used by tests to access internal state. |
| 66 class ASH_EXPORT TestApi { | 80 class ASH_EXPORT TestApi { |
| 67 public: | 81 public: |
| 68 explicit TestApi(PowerButtonController* controller) | 82 explicit TestApi(PowerButtonController* controller) |
| 69 : controller_(controller) {} | 83 : controller_(controller) {} |
| 70 | 84 |
| 71 bool lock_timer_is_running() const { | 85 bool lock_timer_is_running() const { |
| 72 return controller_->lock_timer_.IsRunning(); | 86 return controller_->lock_timer_.IsRunning(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 } | 119 } |
| 106 void trigger_real_shutdown_timeout() { | 120 void trigger_real_shutdown_timeout() { |
| 107 controller_->OnRealShutdownTimeout(); | 121 controller_->OnRealShutdownTimeout(); |
| 108 controller_->real_shutdown_timer_.Stop(); | 122 controller_->real_shutdown_timer_.Stop(); |
| 109 } | 123 } |
| 110 void trigger_hide_background_layer_timeout() { | 124 void trigger_hide_background_layer_timeout() { |
| 111 controller_->HideBackgroundLayer(); | 125 controller_->HideBackgroundLayer(); |
| 112 controller_->hide_background_layer_timer_.Stop(); | 126 controller_->hide_background_layer_timer_.Stop(); |
| 113 } | 127 } |
| 114 | 128 |
| 115 // Returns true if the given set of containers was last animated with | 129 // Returns true if containers of a given |container_mask| |
| 116 // |type| (probably; the analysis is fairly ad-hoc). | 130 // was last animated with |type| (probably; the analysis is fairly ad-hoc). |
|
Daniel Erat
2012/09/04 16:40:18
nit: s/was/were/
Nikita (slow)
2012/09/04 17:36:42
Done.
| |
| 117 bool ContainerGroupIsAnimated(ContainerGroup group, | 131 // |container_mask| is a bitfield of a ContainerGroup. |
|
Daniel Erat
2012/09/04 16:40:18
nit: s/a ContainerGroup/ContainerGroups/
Nikita (slow)
2012/09/04 17:36:42
As discussed renamed to Container
| |
| 118 AnimationType type) const; | 132 bool ContainerGroupIsAnimated(int container_mask, AnimationType type) const; |
|
Daniel Erat
2012/09/04 16:40:18
nit: s/ContainerGroupIs/ContainerGroupsAre/
Nikita (slow)
2012/09/04 17:36:42
Done.
| |
| 119 | 133 |
| 120 // Returns true if |background_layer_| is non-NULL and visible. | 134 // Returns true if |background_layer_| is non-NULL and visible. |
| 121 bool BackgroundLayerIsVisible() const; | 135 bool BackgroundLayerIsVisible() const; |
| 122 | 136 |
| 123 // Returns |background_layer_|'s bounds, or an empty rect if the layer is | 137 // Returns |background_layer_|'s bounds, or an empty rect if the layer is |
| 124 // NULL. | 138 // NULL. |
| 125 gfx::Rect GetBackgroundLayerBounds() const; | 139 gfx::Rect GetBackgroundLayerBounds() const; |
| 126 | 140 |
| 127 private: | 141 private: |
| 128 PowerButtonController* controller_; // not owned | 142 PowerButtonController* controller_; // not owned |
| 129 | 143 |
| 130 DISALLOW_COPY_AND_ASSIGN(TestApi); | 144 DISALLOW_COPY_AND_ASSIGN(TestApi); |
| 131 }; | 145 }; |
| 132 | 146 |
| 147 // Helper method that returns bitfield mask of all containers. | |
|
Daniel Erat
2012/09/04 16:40:18
nit: s/returns/returns a/
Nikita (slow)
2012/09/04 17:36:42
Done.
| |
| 148 static int GetAllContainersMask(); | |
| 149 | |
| 150 // Helper method that returns bitfield mask of all lock screen containers. | |
|
Daniel Erat
2012/09/04 16:40:18
nit: s/returns/returns a/
the comment here makes
Nikita (slow)
2012/09/04 17:36:42
Done.
| |
| 151 static int GetAllScreenLockContainersMask(); | |
|
Daniel Erat
2012/09/04 16:40:18
nit: s/ScreenLock/LockScreen/, so this is consiste
Nikita (slow)
2012/09/04 17:36:42
Done.
| |
| 152 | |
| 133 PowerButtonController(); | 153 PowerButtonController(); |
| 134 virtual ~PowerButtonController(); | 154 virtual ~PowerButtonController(); |
| 135 | 155 |
| 136 void set_delegate(PowerButtonControllerDelegate* delegate) { | 156 void set_delegate(PowerButtonControllerDelegate* delegate) { |
| 137 delegate_.reset(delegate); | 157 delegate_.reset(delegate); |
| 138 } | 158 } |
| 139 | 159 |
| 140 void set_has_legacy_power_button_for_test(bool legacy) { | 160 void set_has_legacy_power_button_for_test(bool legacy) { |
| 141 has_legacy_power_button_ = legacy; | 161 has_legacy_power_button_ = legacy; |
| 142 } | 162 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 // Are the power or lock buttons currently held? | 226 // Are the power or lock buttons currently held? |
| 207 bool power_button_down_; | 227 bool power_button_down_; |
| 208 bool lock_button_down_; | 228 bool lock_button_down_; |
| 209 | 229 |
| 210 // Is the screen currently turned off? | 230 // Is the screen currently turned off? |
| 211 bool screen_is_off_; | 231 bool screen_is_off_; |
| 212 | 232 |
| 213 // Are we in the process of shutting the machine down? | 233 // Are we in the process of shutting the machine down? |
| 214 bool shutting_down_; | 234 bool shutting_down_; |
| 215 | 235 |
| 216 // Should we start |shutdown_timer_| when we receive notification that the | |
| 217 // screen has been locked? | |
| 218 bool should_start_shutdown_timer_after_lock_; | |
|
Daniel Erat
2012/09/04 16:40:18
thanks for deleting this
| |
| 219 | |
| 220 // Was a command-line switch set telling us that we're running on hardware | 236 // Was a command-line switch set telling us that we're running on hardware |
| 221 // that misreports power button releases? | 237 // that misreports power button releases? |
| 222 bool has_legacy_power_button_; | 238 bool has_legacy_power_button_; |
| 223 | 239 |
| 224 // Layer that's stacked under all of the root window's children to provide a | 240 // Layer that's stacked under all of the root window's children to provide a |
| 225 // black background when we're scaling all of the other windows down. | 241 // black background when we're scaling all of the other windows down. |
| 226 // TODO(derat): Remove this in favor of having the compositor only clear the | 242 // TODO(derat): Remove this in favor of having the compositor only clear the |
| 227 // viewport when there are regions not covered by a layer: | 243 // viewport when there are regions not covered by a layer: |
| 228 // http://crbug.com/113445 | 244 // http://crbug.com/113445 |
| 229 scoped_ptr<ui::Layer> background_layer_; | 245 scoped_ptr<ui::Layer> background_layer_; |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 255 // |background_layer_|, as the desktop background is now covering the whole | 271 // |background_layer_|, as the desktop background is now covering the whole |
| 256 // screen. | 272 // screen. |
| 257 base::OneShotTimer<PowerButtonController> hide_background_layer_timer_; | 273 base::OneShotTimer<PowerButtonController> hide_background_layer_timer_; |
| 258 | 274 |
| 259 DISALLOW_COPY_AND_ASSIGN(PowerButtonController); | 275 DISALLOW_COPY_AND_ASSIGN(PowerButtonController); |
| 260 }; | 276 }; |
| 261 | 277 |
| 262 } // namespace ash | 278 } // namespace ash |
| 263 | 279 |
| 264 #endif // ASH_WM_POWER_BUTTON_CONTROLLER_H_ | 280 #endif // ASH_WM_POWER_BUTTON_CONTROLLER_H_ |
| OLD | NEW |