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

Side by Side Diff: ash/wm/power_button_controller.cc

Issue 2111443002: mash: Migrate SessionStateDelegate access to WmShell. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. 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 (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/wm/power_button_controller.h" 5 #include "ash/wm/power_button_controller.h"
6 6
7 #include "ash/common/ash_switches.h" 7 #include "ash/common/ash_switches.h"
8 #include "ash/common/session/session_state_delegate.h" 8 #include "ash/common/session/session_state_delegate.h"
9 #include "ash/common/shell_window_ids.h" 9 #include "ash/common/shell_window_ids.h"
10 #include "ash/common/wm_shell.h"
10 #include "ash/shell.h" 11 #include "ash/shell.h"
11 #include "ash/wm/lock_state_controller.h" 12 #include "ash/wm/lock_state_controller.h"
12 #include "ash/wm/maximize_mode/maximize_mode_controller.h" 13 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
13 #include "ash/wm/session_state_animator.h" 14 #include "ash/wm/session_state_animator.h"
14 #include "base/command_line.h" 15 #include "base/command_line.h"
15 #include "ui/aura/window_event_dispatcher.h" 16 #include "ui/aura/window_event_dispatcher.h"
16 #include "ui/display/types/display_snapshot.h" 17 #include "ui/display/types/display_snapshot.h"
17 #include "ui/events/event_handler.h" 18 #include "ui/events/event_handler.h"
18 #include "ui/wm/core/compound_event_filter.h" 19 #include "ui/wm/core/compound_event_filter.h"
19 20
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 // while the screen is off (http://crbug.com/128451), unless an external 65 // while the screen is off (http://crbug.com/128451), unless an external
65 // display is still on (http://crosbug.com/p/24912). 66 // display is still on (http://crosbug.com/p/24912).
66 if (brightness_is_zero_ && !internal_display_off_and_external_display_on_) 67 if (brightness_is_zero_ && !internal_display_off_and_external_display_on_)
67 return; 68 return;
68 69
69 if (volume_down_pressed_ && down && 70 if (volume_down_pressed_ && down &&
70 Shell::GetInstance() 71 Shell::GetInstance()
71 ->maximize_mode_controller() 72 ->maximize_mode_controller()
72 ->IsMaximizeModeWindowManagerEnabled()) { 73 ->IsMaximizeModeWindowManagerEnabled()) {
73 Shell::GetInstance()->accelerator_controller()->PerformActionIfEnabled( 74 Shell::GetInstance()->accelerator_controller()->PerformActionIfEnabled(
74 ash::TAKE_SCREENSHOT); 75 TAKE_SCREENSHOT);
75 return; 76 return;
76 } 77 }
77 78
78 const SessionStateDelegate* session_state_delegate = 79 const SessionStateDelegate* session_state_delegate =
79 Shell::GetInstance()->session_state_delegate(); 80 WmShell::Get()->GetSessionStateDelegate();
80 if (has_legacy_power_button_) { 81 if (has_legacy_power_button_) {
81 // If power button releases won't get reported correctly because we're not 82 // If power button releases won't get reported correctly because we're not
82 // running on official hardware, just lock the screen or shut down 83 // running on official hardware, just lock the screen or shut down
83 // immediately. 84 // immediately.
84 if (down) { 85 if (down) {
85 if (session_state_delegate->CanLockScreen() && 86 if (session_state_delegate->CanLockScreen() &&
86 !session_state_delegate->IsUserSessionBlocked() && 87 !session_state_delegate->IsUserSessionBlocked() &&
87 !controller_->LockRequested()) { 88 !controller_->LockRequested()) {
88 controller_->StartLockAnimationAndLockImmediately(false); 89 controller_->StartLockAnimationAndLockImmediately(false);
89 } else { 90 } else {
(...skipping 26 matching lines...) Expand all
116 } 117 }
117 } 118 }
118 } 119 }
119 120
120 void PowerButtonController::OnLockButtonEvent( 121 void PowerButtonController::OnLockButtonEvent(
121 bool down, 122 bool down,
122 const base::TimeTicks& timestamp) { 123 const base::TimeTicks& timestamp) {
123 lock_button_down_ = down; 124 lock_button_down_ = down;
124 125
125 const SessionStateDelegate* session_state_delegate = 126 const SessionStateDelegate* session_state_delegate =
126 Shell::GetInstance()->session_state_delegate(); 127 WmShell::Get()->GetSessionStateDelegate();
127 if (!session_state_delegate->CanLockScreen() || 128 if (!session_state_delegate->CanLockScreen() ||
128 session_state_delegate->IsScreenLocked() || 129 session_state_delegate->IsScreenLocked() ||
129 controller_->LockRequested() || controller_->ShutdownRequested()) { 130 controller_->LockRequested() || controller_->ShutdownRequested()) {
130 return; 131 return;
131 } 132 }
132 133
133 // Give the power button precedence over the lock button. 134 // Give the power button precedence over the lock button.
134 if (power_button_down_) 135 if (power_button_down_)
135 return; 136 return;
136 137
(...skipping 20 matching lines...) Expand all
157 } else if (display->current_mode()) { 158 } else if (display->current_mode()) {
158 external_display_on = true; 159 external_display_on = true;
159 } 160 }
160 } 161 }
161 internal_display_off_and_external_display_on_ = 162 internal_display_off_and_external_display_on_ =
162 internal_display_off && external_display_on; 163 internal_display_off && external_display_on;
163 } 164 }
164 #endif 165 #endif
165 166
166 } // namespace ash 167 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698