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

Side by Side Diff: ash/system/chromeos/power/tablet_power_button_controller.cc

Issue 2533373002: Enabled/disable touch screen in TabletPowerButtonController (Closed)
Patch Set: touch_screen_status Created 4 years 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/system/chromeos/power/tablet_power_button_controller.h" 5 #include "ash/system/chromeos/power/tablet_power_button_controller.h"
6 6
7 #include "ash/common/accessibility_delegate.h" 7 #include "ash/common/accessibility_delegate.h"
8 #include "ash/common/session/session_state_delegate.h" 8 #include "ash/common/session/session_state_delegate.h"
9 #include "ash/common/shell_delegate.h"
9 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" 10 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
10 #include "ash/common/wm_shell.h" 11 #include "ash/common/wm_shell.h"
11 #include "ash/shell.h" 12 #include "ash/shell.h"
12 #include "ash/wm/lock_state_controller.h" 13 #include "ash/wm/lock_state_controller.h"
13 #include "base/time/default_tick_clock.h" 14 #include "base/time/default_tick_clock.h"
14 #include "chromeos/dbus/dbus_thread_manager.h" 15 #include "chromeos/dbus/dbus_thread_manager.h"
15 #include "ui/events/devices/input_device_manager.h" 16 #include "ui/events/devices/input_device_manager.h"
16 #include "ui/events/devices/stylus_state.h" 17 #include "ui/events/devices/stylus_state.h"
17 #include "ui/events/event.h" 18 #include "ui/events/event.h"
18 19
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 SetBacklightsForcedOff(false); 167 SetBacklightsForcedOff(false);
167 } 168 }
168 } 169 }
169 170
170 void TabletPowerButtonController::SetTickClockForTesting( 171 void TabletPowerButtonController::SetTickClockForTesting(
171 std::unique_ptr<base::TickClock> tick_clock) { 172 std::unique_ptr<base::TickClock> tick_clock) {
172 DCHECK(tick_clock); 173 DCHECK(tick_clock);
173 tick_clock_ = std::move(tick_clock); 174 tick_clock_ = std::move(tick_clock);
174 } 175 }
175 176
176 void TabletPowerButtonController::SetBacklightsForcedOff(bool forced_off) { 177 void TabletPowerButtonController::SetBacklightsForcedOff(bool forced_off) {
Daniel Erat 2016/11/29 21:03:36 this should probably be renamed now, as it does mo
Qiang(Joe) Xu 2016/11/30 22:09:11 Done.
177 if (backlights_forced_off_ == forced_off) 178 if (backlights_forced_off_ == forced_off)
178 return; 179 return;
179 180
180 chromeos::DBusThreadManager::Get() 181 chromeos::DBusThreadManager::Get()
181 ->GetPowerManagerClient() 182 ->GetPowerManagerClient()
182 ->SetBacklightsForcedOff(forced_off); 183 ->SetBacklightsForcedOff(forced_off);
183 backlights_forced_off_ = forced_off; 184 backlights_forced_off_ = forced_off;
184 185
186 // ToggleTouchscreen when there is a request/stop backlights forced off call
187 // and touch screen should be toggled.
188 WmShell* wm_shell = WmShell::Get();
189 const bool touch_screen_disabled =
190 !wm_shell->delegate()->IsTouchscreenEnabled();
191 if (touch_screen_disabled ^ forced_off)
192 wm_shell->delegate()->ToggleTouchscreen();
193
185 // Send an a11y alert. 194 // Send an a11y alert.
186 WmShell::Get()->accessibility_delegate()->TriggerAccessibilityAlert( 195 wm_shell->accessibility_delegate()->TriggerAccessibilityAlert(
187 forced_off ? A11Y_ALERT_SCREEN_OFF : A11Y_ALERT_SCREEN_ON); 196 forced_off ? A11Y_ALERT_SCREEN_OFF : A11Y_ALERT_SCREEN_ON);
188 } 197 }
189 198
190 void TabletPowerButtonController::GetInitialBacklightsForcedOff() { 199 void TabletPowerButtonController::GetInitialBacklightsForcedOff() {
191 chromeos::DBusThreadManager::Get() 200 chromeos::DBusThreadManager::Get()
192 ->GetPowerManagerClient() 201 ->GetPowerManagerClient()
193 ->GetBacklightsForcedOff(base::Bind( 202 ->GetBacklightsForcedOff(base::Bind(
194 &TabletPowerButtonController::OnGotInitialBacklightsForcedOff, 203 &TabletPowerButtonController::OnGotInitialBacklightsForcedOff,
195 weak_ptr_factory_.GetWeakPtr())); 204 weak_ptr_factory_.GetWeakPtr()));
196 } 205 }
(...skipping 18 matching lines...) Expand all
215 WmShell::Get()->GetSessionStateDelegate(); 224 WmShell::Get()->GetSessionStateDelegate();
216 if (session_state_delegate->ShouldLockScreenAutomatically() && 225 if (session_state_delegate->ShouldLockScreenAutomatically() &&
217 session_state_delegate->CanLockScreen() && 226 session_state_delegate->CanLockScreen() &&
218 !session_state_delegate->IsUserSessionBlocked() && 227 !session_state_delegate->IsUserSessionBlocked() &&
219 !controller_->LockRequested()) { 228 !controller_->LockRequested()) {
220 session_state_delegate->LockScreen(); 229 session_state_delegate->LockScreen();
221 } 230 }
222 } 231 }
223 232
224 } // namespace ash 233 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698