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

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

Issue 2166043003: mash: Migrate ShelfLockingManager to ash/common. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move ShelfLockingManager test access to Shelf. Created 4 years, 5 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/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/wm_shell.h" 9 #include "ash/common/wm_shell.h"
9 #include "ash/shelf/shelf.h"
10 #include "ash/shell.h"
11 #include "ash/wm/lock_state_controller.h"
12 10
13 namespace ash { 11 namespace ash {
14 12
15 ShelfLockingManager::ShelfLockingManager(Shelf* shelf) : shelf_(shelf) { 13 ShelfLockingManager::ShelfLockingManager(WmShelf* shelf) : shelf_(shelf) {
16 Shell* shell = Shell::GetInstance(); 14 WmShell::Get()->AddLockStateObserver(this);
17 shell->lock_state_controller()->AddObserver(this);
18 SessionStateDelegate* delegate = WmShell::Get()->GetSessionStateDelegate(); 15 SessionStateDelegate* delegate = WmShell::Get()->GetSessionStateDelegate();
19 session_locked_ = 16 session_locked_ =
20 delegate->GetSessionState() != SessionStateDelegate::SESSION_STATE_ACTIVE; 17 delegate->GetSessionState() != SessionStateDelegate::SESSION_STATE_ACTIVE;
21 screen_locked_ = delegate->IsScreenLocked(); 18 screen_locked_ = delegate->IsScreenLocked();
22 delegate->AddSessionStateObserver(this); 19 delegate->AddSessionStateObserver(this);
23 WmShell::Get()->AddShellObserver(this); 20 WmShell::Get()->AddShellObserver(this);
24 } 21 }
25 22
26 ShelfLockingManager::~ShelfLockingManager() { 23 ShelfLockingManager::~ShelfLockingManager() {
27 Shell::GetInstance()->lock_state_controller()->RemoveObserver(this); 24 WmShell::Get()->RemoveLockStateObserver(this);
28 WmShell::Get()->GetSessionStateDelegate()->RemoveSessionStateObserver(this); 25 WmShell::Get()->GetSessionStateDelegate()->RemoveSessionStateObserver(this);
29 WmShell::Get()->RemoveShellObserver(this); 26 WmShell::Get()->RemoveShellObserver(this);
30 } 27 }
31 28
32 void ShelfLockingManager::OnLockStateChanged(bool locked) { 29 void ShelfLockingManager::OnLockStateChanged(bool locked) {
33 screen_locked_ = locked; 30 screen_locked_ = locked;
34 UpdateLockedState(); 31 UpdateLockedState();
35 } 32 }
36 33
37 void ShelfLockingManager::SessionStateChanged( 34 void ShelfLockingManager::SessionStateChanged(
38 SessionStateDelegate::SessionState state) { 35 SessionStateDelegate::SessionState state) {
39 session_locked_ = state != SessionStateDelegate::SESSION_STATE_ACTIVE; 36 session_locked_ = state != SessionStateDelegate::SESSION_STATE_ACTIVE;
40 UpdateLockedState(); 37 UpdateLockedState();
41 } 38 }
42 39
43 void ShelfLockingManager::OnLockStateEvent(EventType event) { 40 void ShelfLockingManager::OnLockStateEvent(EventType event) {
44 // Lock when the animation starts, ignoring pre-lock. There's no unlock event. 41 // Lock when the animation starts, ignoring pre-lock. There's no unlock event.
45 screen_locked_ |= event == EVENT_LOCK_ANIMATION_STARTED; 42 screen_locked_ |= event == EVENT_LOCK_ANIMATION_STARTED;
46 UpdateLockedState(); 43 UpdateLockedState();
47 } 44 }
48 45
49 void ShelfLockingManager::UpdateLockedState() { 46 void ShelfLockingManager::UpdateLockedState() {
50 const ShelfAlignment alignment = shelf_->alignment(); 47 const ShelfAlignment alignment = shelf_->GetAlignment();
51 if (is_locked() && alignment != SHELF_ALIGNMENT_BOTTOM_LOCKED) { 48 if (is_locked() && alignment != SHELF_ALIGNMENT_BOTTOM_LOCKED) {
52 stored_alignment_ = alignment; 49 stored_alignment_ = alignment;
53 shelf_->SetAlignment(SHELF_ALIGNMENT_BOTTOM_LOCKED); 50 shelf_->SetAlignment(SHELF_ALIGNMENT_BOTTOM_LOCKED);
54 } else if (!is_locked() && alignment == SHELF_ALIGNMENT_BOTTOM_LOCKED) { 51 } else if (!is_locked() && alignment == SHELF_ALIGNMENT_BOTTOM_LOCKED) {
55 shelf_->SetAlignment(stored_alignment_); 52 shelf_->SetAlignment(stored_alignment_);
56 } 53 }
57 } 54 }
58 55
59 } // namespace ash 56 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698