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 #include "ash/shelf/shelf_layout_manager.h" | 5 #include "ash/shelf/shelf_layout_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <cstring> | 9 #include <cstring> |
10 #include <string> | 10 #include <string> |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
239 (state_.visibility_state == SHELF_VISIBLE || | 239 (state_.visibility_state == SHELF_VISIBLE || |
240 (state_.visibility_state == SHELF_AUTO_HIDE && | 240 (state_.visibility_state == SHELF_AUTO_HIDE && |
241 state_.auto_hide_state == SHELF_AUTO_HIDE_SHOWN)); | 241 state_.auto_hide_state == SHELF_AUTO_HIDE_SHOWN)); |
242 } | 242 } |
243 | 243 |
244 bool ShelfLayoutManager::SetAlignment(ShelfAlignment alignment) { | 244 bool ShelfLayoutManager::SetAlignment(ShelfAlignment alignment) { |
245 if (alignment_ == alignment) | 245 if (alignment_ == alignment) |
246 return false; | 246 return false; |
247 | 247 |
248 alignment_ = alignment; | 248 alignment_ = alignment; |
249 if (Shell::GetInstance()->session_state_delegate()->IsUserSessionBlocked() || | 249 // The shelf will itself move to the bottom while locked or obscured by user |
250 state_.is_adding_user_screen) { | 250 // login. If a request is sent to move while being obscured, we postpone the |
251 // The shelf will itself move to the bottom while locked. If a request is | 251 // move until the user session is resumed. |
252 // sent to move while being locked, we postpone the move until the lock | 252 if (IsAlignmentLocked()) |
253 // screen goes away. | |
254 return false; | 253 return false; |
255 } | |
256 | 254 |
257 // This should not be called during the lock screen transitions. | 255 // This should not be called during the lock screen transitions. |
258 shelf_->SetAlignment(alignment); | 256 shelf_->SetAlignment(alignment); |
259 LayoutShelf(); | 257 LayoutShelf(); |
260 return true; | 258 return true; |
261 } | 259 } |
262 | 260 |
263 ShelfAlignment ShelfLayoutManager::GetAlignment() const { | 261 ShelfAlignment ShelfLayoutManager::GetAlignment() const { |
264 // When the screen is locked or a user gets added, the shelf is forced into | 262 // When the screen is locked or a user gets added, the shelf is forced into |
265 // bottom alignment. Note: We cannot use state_.is_screen_locked here since | 263 // bottom alignment. |
266 // that flag gets set later than the SessionStateDelegate reports a locked | 264 if (IsAlignmentLocked()) |
267 // screen which leads in | |
268 if (Shell::GetInstance()->session_state_delegate()->IsUserSessionBlocked() || | |
269 state_.is_adding_user_screen) | |
270 return SHELF_ALIGNMENT_BOTTOM; | 265 return SHELF_ALIGNMENT_BOTTOM; |
271 return alignment_; | 266 return alignment_; |
272 } | 267 } |
273 | 268 |
274 gfx::Rect ShelfLayoutManager::GetIdealBounds() { | 269 gfx::Rect ShelfLayoutManager::GetIdealBounds() { |
275 gfx::Rect bounds( | 270 gfx::Rect bounds( |
276 ScreenUtil::GetDisplayBoundsInParent(shelf_->GetNativeView())); | 271 ScreenUtil::GetDisplayBoundsInParent(shelf_->GetNativeView())); |
277 int width = 0, height = 0; | 272 int width = 0, height = 0; |
278 GetShelfSize(&width, &height); | 273 GetShelfSize(&width, &height); |
279 return SelectValueForShelfAlignment( | 274 return SelectValueForShelfAlignment( |
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1152 UpdateShelfVisibilityAfterLoginUIChange(); | 1147 UpdateShelfVisibilityAfterLoginUIChange(); |
1153 return; | 1148 return; |
1154 } | 1149 } |
1155 TargetBounds target_bounds; | 1150 TargetBounds target_bounds; |
1156 CalculateTargetBounds(state_, &target_bounds); | 1151 CalculateTargetBounds(state_, &target_bounds); |
1157 UpdateBoundsAndOpacity(target_bounds, true, NULL); | 1152 UpdateBoundsAndOpacity(target_bounds, true, NULL); |
1158 UpdateVisibilityState(); | 1153 UpdateVisibilityState(); |
1159 } | 1154 } |
1160 | 1155 |
1161 void ShelfLayoutManager::UpdateShelfVisibilityAfterLoginUIChange() { | 1156 void ShelfLayoutManager::UpdateShelfVisibilityAfterLoginUIChange() { |
1162 shelf_->SetAlignment(state_.is_adding_user_screen || state_.is_screen_locked ? | 1157 shelf_->SetAlignment(GetAlignment()); |
1163 SHELF_ALIGNMENT_BOTTOM : alignment_); | |
1164 UpdateVisibilityState(); | 1158 UpdateVisibilityState(); |
1165 LayoutShelf(); | 1159 LayoutShelf(); |
1166 } | 1160 } |
1167 | 1161 |
1162 bool ShelfLayoutManager::IsAlignmentLocked() const { | |
1163 SessionStateDelegate* session_state_delegate = | |
James Cook
2015/02/17 20:03:36
nit: move this lower down, closer to where it is u
| |
1164 Shell::GetInstance()->session_state_delegate(); | |
1165 if (state_.is_screen_locked) | |
1166 return true; | |
1167 // The session state becomes active at the start of transitioning to a user | |
1168 // session, however the session is considered blocked until the full UI is | |
1169 // ready. Exit early to allow for proper layout. | |
1170 if (session_state_delegate->GetSessionState() == | |
1171 SessionStateDelegate::SESSION_STATE_ACTIVE) { | |
1172 return false; | |
1173 } | |
1174 if (session_state_delegate->IsUserSessionBlocked() || | |
1175 state_.is_adding_user_screen) { | |
1176 return true; | |
1177 } | |
1178 return false; | |
1179 } | |
1180 | |
1168 } // namespace ash | 1181 } // namespace ash |
OLD | NEW |