| 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/shelf/shelf_locking_manager.h" | 5 #include "ash/shelf/shelf_locking_manager.h" |
| 6 | 6 |
| 7 #include "ash/common/session/session_state_delegate.h" | 7 #include "ash/common/session/session_state_delegate.h" |
| 8 #include "ash/common/wm_shell.h" | 8 #include "ash/common/wm_shell.h" |
| 9 #include "ash/shelf/shelf.h" | 9 #include "ash/shelf/shelf.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "ash/wm/lock_state_controller.h" | 11 #include "ash/wm/lock_state_controller.h" |
| 12 | 12 |
| 13 namespace ash { | 13 namespace ash { |
| 14 | 14 |
| 15 ShelfLockingManager::ShelfLockingManager(Shelf* shelf) : shelf_(shelf) { | 15 ShelfLockingManager::ShelfLockingManager(Shelf* shelf) : shelf_(shelf) { |
| 16 Shell* shell = Shell::GetInstance(); | 16 Shell* shell = Shell::GetInstance(); |
| 17 shell->lock_state_controller()->AddObserver(this); | 17 shell->lock_state_controller()->AddObserver(this); |
| 18 SessionStateDelegate* delegate = shell->session_state_delegate(); | 18 SessionStateDelegate* delegate = WmShell::Get()->GetSessionStateDelegate(); |
| 19 session_locked_ = | 19 session_locked_ = |
| 20 delegate->GetSessionState() != SessionStateDelegate::SESSION_STATE_ACTIVE; | 20 delegate->GetSessionState() != SessionStateDelegate::SESSION_STATE_ACTIVE; |
| 21 screen_locked_ = delegate->IsScreenLocked(); | 21 screen_locked_ = delegate->IsScreenLocked(); |
| 22 delegate->AddSessionStateObserver(this); | 22 delegate->AddSessionStateObserver(this); |
| 23 WmShell::Get()->AddShellObserver(this); | 23 WmShell::Get()->AddShellObserver(this); |
| 24 } | 24 } |
| 25 | 25 |
| 26 ShelfLockingManager::~ShelfLockingManager() { | 26 ShelfLockingManager::~ShelfLockingManager() { |
| 27 Shell* shell = Shell::GetInstance(); | 27 Shell::GetInstance()->lock_state_controller()->RemoveObserver(this); |
| 28 shell->lock_state_controller()->RemoveObserver(this); | 28 WmShell::Get()->GetSessionStateDelegate()->RemoveSessionStateObserver(this); |
| 29 shell->session_state_delegate()->RemoveSessionStateObserver(this); | |
| 30 WmShell::Get()->RemoveShellObserver(this); | 29 WmShell::Get()->RemoveShellObserver(this); |
| 31 } | 30 } |
| 32 | 31 |
| 33 void ShelfLockingManager::OnLockStateChanged(bool locked) { | 32 void ShelfLockingManager::OnLockStateChanged(bool locked) { |
| 34 screen_locked_ = locked; | 33 screen_locked_ = locked; |
| 35 UpdateLockedState(); | 34 UpdateLockedState(); |
| 36 } | 35 } |
| 37 | 36 |
| 38 void ShelfLockingManager::SessionStateChanged( | 37 void ShelfLockingManager::SessionStateChanged( |
| 39 SessionStateDelegate::SessionState state) { | 38 SessionStateDelegate::SessionState state) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 51 const ShelfAlignment alignment = shelf_->alignment(); | 50 const ShelfAlignment alignment = shelf_->alignment(); |
| 52 if (is_locked() && alignment != SHELF_ALIGNMENT_BOTTOM_LOCKED) { | 51 if (is_locked() && alignment != SHELF_ALIGNMENT_BOTTOM_LOCKED) { |
| 53 stored_alignment_ = alignment; | 52 stored_alignment_ = alignment; |
| 54 shelf_->SetAlignment(SHELF_ALIGNMENT_BOTTOM_LOCKED); | 53 shelf_->SetAlignment(SHELF_ALIGNMENT_BOTTOM_LOCKED); |
| 55 } else if (!is_locked() && alignment == SHELF_ALIGNMENT_BOTTOM_LOCKED) { | 54 } else if (!is_locked() && alignment == SHELF_ALIGNMENT_BOTTOM_LOCKED) { |
| 56 shelf_->SetAlignment(stored_alignment_); | 55 shelf_->SetAlignment(stored_alignment_); |
| 57 } | 56 } |
| 58 } | 57 } |
| 59 | 58 |
| 60 } // namespace ash | 59 } // namespace ash |
| OLD | NEW |