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

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

Issue 14295008: Add ash SessionStateDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ready for review. Created 7 years, 8 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 9
10 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
11 #include "ash/launcher/launcher.h" 11 #include "ash/launcher/launcher.h"
12 #include "ash/launcher/launcher_types.h" 12 #include "ash/launcher/launcher_types.h"
13 #include "ash/root_window_controller.h" 13 #include "ash/root_window_controller.h"
14 #include "ash/screen_ash.h" 14 #include "ash/screen_ash.h"
15 #include "ash/session_state_delegate.h"
15 #include "ash/shelf/shelf_widget.h" 16 #include "ash/shelf/shelf_widget.h"
16 #include "ash/shell.h" 17 #include "ash/shell.h"
17 #include "ash/shell_delegate.h"
18 #include "ash/shell_window_ids.h" 18 #include "ash/shell_window_ids.h"
19 #include "ash/system/status_area_widget.h" 19 #include "ash/system/status_area_widget.h"
20 #include "ash/wm/property_util.h" 20 #include "ash/wm/property_util.h"
21 #include "ash/wm/window_cycle_controller.h" 21 #include "ash/wm/window_cycle_controller.h"
22 #include "ash/wm/window_util.h" 22 #include "ash/wm/window_util.h"
23 #include "ash/wm/workspace_controller.h" 23 #include "ash/wm/workspace_controller.h"
24 #include "ash/wm/workspace/workspace_animations.h" 24 #include "ash/wm/workspace/workspace_animations.h"
25 #include "base/auto_reset.h" 25 #include "base/auto_reset.h"
26 #include "base/command_line.h" 26 #include "base/command_line.h"
27 #include "base/i18n/rtl.h" 27 #include "base/i18n/rtl.h"
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 case SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS: 265 case SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS:
266 case SHELF_AUTO_HIDE_BEHAVIOR_NEVER: 266 case SHELF_AUTO_HIDE_BEHAVIOR_NEVER:
267 return SHELF_AUTO_HIDE; 267 return SHELF_AUTO_HIDE;
268 case SHELF_AUTO_HIDE_ALWAYS_HIDDEN: 268 case SHELF_AUTO_HIDE_ALWAYS_HIDDEN:
269 return SHELF_HIDDEN; 269 return SHELF_HIDDEN;
270 } 270 }
271 return SHELF_VISIBLE; 271 return SHELF_VISIBLE;
272 } 272 }
273 273
274 void ShelfLayoutManager::UpdateVisibilityState() { 274 void ShelfLayoutManager::UpdateVisibilityState() {
275 ShellDelegate* delegate = Shell::GetInstance()->delegate(); 275 if (Shell::GetInstance()->session_state_delegate()->IsScreenLocked()) {
276 if (delegate && delegate->IsScreenLocked()) {
277 SetState(SHELF_VISIBLE); 276 SetState(SHELF_VISIBLE);
278 } else if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS) { 277 } else if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS) {
279 // TODO(zelidrag): Verify shelf drag animation still shows on the device 278 // TODO(zelidrag): Verify shelf drag animation still shows on the device
280 // when we are in SHELF_AUTO_HIDE_ALWAYS_HIDDEN. 279 // when we are in SHELF_AUTO_HIDE_ALWAYS_HIDDEN.
281 SetState(CalculateShelfVisibilityWhileDragging()); 280 SetState(CalculateShelfVisibilityWhileDragging());
282 } else if (GetRootWindowController(root_window_)->IsImmersiveMode()) { 281 } else if (GetRootWindowController(root_window_)->IsImmersiveMode()) {
283 // The user choosing immersive mode indicates he or she wants to maximize 282 // The user choosing immersive mode indicates he or she wants to maximize
284 // screen real-estate for content, so always auto-hide the shelf. 283 // screen real-estate for content, so always auto-hide the shelf.
285 DCHECK_NE(auto_hide_behavior_, SHELF_AUTO_HIDE_ALWAYS_HIDDEN); 284 DCHECK_NE(auto_hide_behavior_, SHELF_AUTO_HIDE_ALWAYS_HIDDEN);
286 SetState(SHELF_AUTO_HIDE); 285 SetState(SHELF_AUTO_HIDE);
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 return shelf ? shelf->shelf_layout_manager() : NULL; 506 return shelf ? shelf->shelf_layout_manager() : NULL;
508 } 507 }
509 508
510 //////////////////////////////////////////////////////////////////////////////// 509 ////////////////////////////////////////////////////////////////////////////////
511 // ShelfLayoutManager, private: 510 // ShelfLayoutManager, private:
512 511
513 ShelfLayoutManager::TargetBounds::TargetBounds() : opacity(0.0f) {} 512 ShelfLayoutManager::TargetBounds::TargetBounds() : opacity(0.0f) {}
514 ShelfLayoutManager::TargetBounds::~TargetBounds() {} 513 ShelfLayoutManager::TargetBounds::~TargetBounds() {}
515 514
516 void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) { 515 void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) {
517 ShellDelegate* delegate = Shell::GetInstance()->delegate();
518 State state; 516 State state;
519 state.visibility_state = visibility_state; 517 state.visibility_state = visibility_state;
520 state.auto_hide_state = CalculateAutoHideState(visibility_state); 518 state.auto_hide_state = CalculateAutoHideState(visibility_state);
521 state.is_screen_locked = delegate && delegate->IsScreenLocked(); 519 state.is_screen_locked =
520 Shell::GetInstance()->session_state_delegate()->IsScreenLocked();
522 521
523 // It's possible for SetState() when a window becomes maximized but the state 522 // It's possible for SetState() when a window becomes maximized but the state
524 // won't have changed value. Do the dimming check before the early exit. 523 // won't have changed value. Do the dimming check before the early exit.
525 if (workspace_controller_) { 524 if (workspace_controller_) {
526 shelf_->SetDimsShelf( 525 shelf_->SetDimsShelf(
527 (state.visibility_state == SHELF_VISIBLE) && 526 (state.visibility_state == SHELF_VISIBLE) &&
528 workspace_controller_->GetWindowState() == 527 workspace_controller_->GetWindowState() ==
529 WORKSPACE_WINDOW_STATE_MAXIMIZED); 528 WORKSPACE_WINDOW_STATE_MAXIMIZED);
530 } 529 }
531 530
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const { 906 int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const {
908 if (state.visibility_state == SHELF_VISIBLE) 907 if (state.visibility_state == SHELF_VISIBLE)
909 return size; 908 return size;
910 if (state.visibility_state == SHELF_AUTO_HIDE) 909 if (state.visibility_state == SHELF_AUTO_HIDE)
911 return kAutoHideSize; 910 return kAutoHideSize;
912 return 0; 911 return 0;
913 } 912 }
914 913
915 } // namespace internal 914 } // namespace internal
916 } // namespace ash 915 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698