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

Side by Side Diff: ash/shelf/shelf_layout_manager.cc

Issue 909293002: Properly set ShelfAlignment during login (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
OLDNEW
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
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
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 =
1164 Shell::GetInstance()->session_state_delegate();
1165 if (state_.is_screen_locked)
1166 return true;
1167 if (session_state_delegate->GetSessionState() ==
1168 SessionStateDelegate::SESSION_STATE_ACTIVE) {
1169 return false;
1170 }
1171 if (session_state_delegate->IsUserSessionBlocked())
1172 return true;
1173 if (state_.is_adding_user_screen)
1174 return true;
tdanderson 2015/02/11 22:59:53 nit: seems reasonable to combine these last two us
jonross 2015/02/12 15:36:58 Done.
1175 return false;
1176 }
1177
1168 } // namespace ash 1178 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698