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

Side by Side Diff: ash/common/shelf/shelf_locking_manager.cc

Issue 2416253004: ash: Use session_manager::SessionState (Closed)
Patch Set: fix compile Created 4 years, 2 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 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_state_delegate.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 10
11 namespace ash { 11 namespace ash {
12 12
13 ShelfLockingManager::ShelfLockingManager(WmShelf* shelf) : shelf_(shelf) { 13 ShelfLockingManager::ShelfLockingManager(WmShelf* shelf) : shelf_(shelf) {
14 WmShell::Get()->AddLockStateObserver(this); 14 WmShell::Get()->AddLockStateObserver(this);
15 SessionStateDelegate* delegate = WmShell::Get()->GetSessionStateDelegate(); 15 SessionStateDelegate* delegate = WmShell::Get()->GetSessionStateDelegate();
16 session_locked_ = 16 session_locked_ = delegate->GetSessionState() != SessionState::ACTIVE;
17 delegate->GetSessionState() != SessionStateDelegate::SESSION_STATE_ACTIVE;
18 screen_locked_ = delegate->IsScreenLocked(); 17 screen_locked_ = delegate->IsScreenLocked();
19 delegate->AddSessionStateObserver(this); 18 delegate->AddSessionStateObserver(this);
20 WmShell::Get()->AddShellObserver(this); 19 WmShell::Get()->AddShellObserver(this);
21 } 20 }
22 21
23 ShelfLockingManager::~ShelfLockingManager() { 22 ShelfLockingManager::~ShelfLockingManager() {
24 WmShell::Get()->RemoveLockStateObserver(this); 23 WmShell::Get()->RemoveLockStateObserver(this);
25 WmShell::Get()->GetSessionStateDelegate()->RemoveSessionStateObserver(this); 24 WmShell::Get()->GetSessionStateDelegate()->RemoveSessionStateObserver(this);
26 WmShell::Get()->RemoveShellObserver(this); 25 WmShell::Get()->RemoveShellObserver(this);
27 } 26 }
28 27
29 void ShelfLockingManager::OnLockStateChanged(bool locked) { 28 void ShelfLockingManager::OnLockStateChanged(bool locked) {
30 screen_locked_ = locked; 29 screen_locked_ = locked;
31 UpdateLockedState(); 30 UpdateLockedState();
32 } 31 }
33 32
34 void ShelfLockingManager::SessionStateChanged( 33 void ShelfLockingManager::SessionStateChanged(SessionState state) {
35 SessionStateDelegate::SessionState state) { 34 session_locked_ = state != SessionState::ACTIVE;
36 session_locked_ = state != SessionStateDelegate::SESSION_STATE_ACTIVE;
37 UpdateLockedState(); 35 UpdateLockedState();
38 } 36 }
39 37
40 void ShelfLockingManager::OnLockStateEvent(EventType event) { 38 void ShelfLockingManager::OnLockStateEvent(EventType event) {
41 // Lock when the animation starts, ignoring pre-lock. There's no unlock event. 39 // Lock when the animation starts, ignoring pre-lock. There's no unlock event.
42 screen_locked_ |= event == EVENT_LOCK_ANIMATION_STARTED; 40 screen_locked_ |= event == EVENT_LOCK_ANIMATION_STARTED;
43 UpdateLockedState(); 41 UpdateLockedState();
44 } 42 }
45 43
46 void ShelfLockingManager::UpdateLockedState() { 44 void ShelfLockingManager::UpdateLockedState() {
47 const ShelfAlignment alignment = shelf_->GetAlignment(); 45 const ShelfAlignment alignment = shelf_->GetAlignment();
48 if (is_locked() && alignment != SHELF_ALIGNMENT_BOTTOM_LOCKED) { 46 if (is_locked() && alignment != SHELF_ALIGNMENT_BOTTOM_LOCKED) {
49 stored_alignment_ = alignment; 47 stored_alignment_ = alignment;
50 shelf_->SetAlignment(SHELF_ALIGNMENT_BOTTOM_LOCKED); 48 shelf_->SetAlignment(SHELF_ALIGNMENT_BOTTOM_LOCKED);
51 } else if (!is_locked() && alignment == SHELF_ALIGNMENT_BOTTOM_LOCKED) { 49 } else if (!is_locked() && alignment == SHELF_ALIGNMENT_BOTTOM_LOCKED) {
52 shelf_->SetAlignment(stored_alignment_); 50 shelf_->SetAlignment(stored_alignment_);
53 } 51 }
54 } 52 }
55 53
56 } // namespace ash 54 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698