OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/common/shelf/shelf_locking_manager.h" | 5 #include "ash/common/shelf/shelf_locking_manager.h" |
6 | 6 |
7 #include "ash/common/session/session_state_delegate.h" | 7 #include "ash/common/session/session_controller.h" |
8 #include "ash/common/shelf/wm_shelf.h" | 8 #include "ash/common/shelf/wm_shelf.h" |
9 #include "ash/common/wm_shell.h" | 9 #include "ash/common/wm_shell.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
11 | 11 |
12 namespace ash { | 12 namespace ash { |
13 | 13 |
14 ShelfLockingManager::ShelfLockingManager(WmShelf* shelf) : shelf_(shelf) { | 14 ShelfLockingManager::ShelfLockingManager(WmShelf* shelf) |
| 15 : shelf_(shelf), stored_alignment_(shelf->GetAlignment()) { |
| 16 DCHECK(shelf_); |
15 WmShell::Get()->AddLockStateObserver(this); | 17 WmShell::Get()->AddLockStateObserver(this); |
16 SessionStateDelegate* delegate = WmShell::Get()->GetSessionStateDelegate(); | 18 SessionController* controller = WmShell::Get()->session_controller(); |
17 session_locked_ = | 19 session_locked_ = |
18 delegate->GetSessionState() != session_manager::SessionState::ACTIVE; | 20 controller->GetSessionState() != session_manager::SessionState::ACTIVE; |
19 screen_locked_ = delegate->IsScreenLocked(); | 21 screen_locked_ = controller->IsScreenLocked(); |
20 delegate->AddSessionStateObserver(this); | 22 controller->AddSessionStateObserver(this); |
21 Shell::GetInstance()->AddShellObserver(this); | 23 Shell::GetInstance()->AddShellObserver(this); |
22 } | 24 } |
23 | 25 |
24 ShelfLockingManager::~ShelfLockingManager() { | 26 ShelfLockingManager::~ShelfLockingManager() { |
25 WmShell::Get()->RemoveLockStateObserver(this); | 27 WmShell::Get()->RemoveLockStateObserver(this); |
26 WmShell::Get()->GetSessionStateDelegate()->RemoveSessionStateObserver(this); | 28 WmShell::Get()->session_controller()->RemoveSessionStateObserver(this); |
27 Shell::GetInstance()->RemoveShellObserver(this); | 29 Shell::GetInstance()->RemoveShellObserver(this); |
28 } | 30 } |
29 | 31 |
30 void ShelfLockingManager::OnLockStateChanged(bool locked) { | 32 void ShelfLockingManager::OnLockStateChanged(bool locked) { |
31 screen_locked_ = locked; | 33 screen_locked_ = locked; |
32 UpdateLockedState(); | 34 UpdateLockedState(); |
33 } | 35 } |
34 | 36 |
35 void ShelfLockingManager::SessionStateChanged( | 37 void ShelfLockingManager::SessionStateChanged( |
36 session_manager::SessionState state) { | 38 session_manager::SessionState state) { |
(...skipping 11 matching lines...) Expand all Loading... |
48 const ShelfAlignment alignment = shelf_->GetAlignment(); | 50 const ShelfAlignment alignment = shelf_->GetAlignment(); |
49 if (is_locked() && alignment != SHELF_ALIGNMENT_BOTTOM_LOCKED) { | 51 if (is_locked() && alignment != SHELF_ALIGNMENT_BOTTOM_LOCKED) { |
50 stored_alignment_ = alignment; | 52 stored_alignment_ = alignment; |
51 shelf_->SetAlignment(SHELF_ALIGNMENT_BOTTOM_LOCKED); | 53 shelf_->SetAlignment(SHELF_ALIGNMENT_BOTTOM_LOCKED); |
52 } else if (!is_locked() && alignment == SHELF_ALIGNMENT_BOTTOM_LOCKED) { | 54 } else if (!is_locked() && alignment == SHELF_ALIGNMENT_BOTTOM_LOCKED) { |
53 shelf_->SetAlignment(stored_alignment_); | 55 shelf_->SetAlignment(stored_alignment_); |
54 } | 56 } |
55 } | 57 } |
56 | 58 |
57 } // namespace ash | 59 } // namespace ash |
OLD | NEW |