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

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

Issue 2506493002: Add a switch for tablet power button behavior (Closed)
Patch Set: based on comments Created 4 years, 1 month 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/accelerators/accelerator_controller.h" 7 #include "ash/common/accelerators/accelerator_controller.h"
8 #include "ash/common/ash_switches.h" 8 #include "ash/common/ash_switches.h"
9 #include "ash/common/session/session_state_delegate.h" 9 #include "ash/common/session/session_state_delegate.h"
10 #include "ash/common/system/tray/system_tray.h" 10 #include "ash/common/system/tray/system_tray.h"
(...skipping 26 matching lines...) Expand all
37 #endif 37 #endif
38 brightness_is_zero_(false), 38 brightness_is_zero_(false),
39 internal_display_off_and_external_display_on_(false), 39 internal_display_off_and_external_display_on_(false),
40 has_legacy_power_button_( 40 has_legacy_power_button_(
41 base::CommandLine::ForCurrentProcess()->HasSwitch( 41 base::CommandLine::ForCurrentProcess()->HasSwitch(
42 switches::kAuraLegacyPowerButton)), 42 switches::kAuraLegacyPowerButton)),
43 lock_state_controller_(controller) { 43 lock_state_controller_(controller) {
44 #if defined(OS_CHROMEOS) 44 #if defined(OS_CHROMEOS)
45 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver( 45 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(
46 this); 46 this);
47 tablet_controller_.reset( 47 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
48 new TabletPowerButtonController(lock_state_controller_)); 48 switches::kAshEnableTabletPowerButton)) {
49 tablet_controller_.reset(
50 new TabletPowerButtonController(lock_state_controller_));
51 }
49 Shell::GetInstance()->display_configurator()->AddObserver(this); 52 Shell::GetInstance()->display_configurator()->AddObserver(this);
50 #endif 53 #endif
51 Shell::GetInstance()->PrependPreTargetHandler(this); 54 Shell::GetInstance()->PrependPreTargetHandler(this);
52 } 55 }
53 56
54 PowerButtonController::~PowerButtonController() { 57 PowerButtonController::~PowerButtonController() {
55 Shell::GetInstance()->RemovePreTargetHandler(this); 58 Shell::GetInstance()->RemovePreTargetHandler(this);
56 #if defined(OS_CHROMEOS) 59 #if defined(OS_CHROMEOS)
57 Shell::GetInstance()->display_configurator()->RemoveObserver(this); 60 Shell::GetInstance()->display_configurator()->RemoveObserver(this);
58 tablet_controller_.reset(); 61 tablet_controller_.reset();
(...skipping 14 matching lines...) Expand all
73 if (lock_state_controller_->ShutdownRequested()) 76 if (lock_state_controller_->ShutdownRequested())
74 return; 77 return;
75 78
76 #if defined(OS_CHROMEOS) 79 #if defined(OS_CHROMEOS)
77 bool should_take_screenshot = down && volume_down_pressed_ && 80 bool should_take_screenshot = down && volume_down_pressed_ &&
78 WmShell::Get() 81 WmShell::Get()
79 ->maximize_mode_controller() 82 ->maximize_mode_controller()
80 ->IsMaximizeModeWindowManagerEnabled(); 83 ->IsMaximizeModeWindowManagerEnabled();
81 84
82 if (!has_legacy_power_button_ && !should_take_screenshot && 85 if (!has_legacy_power_button_ && !should_take_screenshot &&
86 tablet_controller_ &&
83 tablet_controller_->ShouldHandlePowerButtonEvents()) { 87 tablet_controller_->ShouldHandlePowerButtonEvents()) {
84 tablet_controller_->OnPowerButtonEvent(down, timestamp); 88 tablet_controller_->OnPowerButtonEvent(down, timestamp);
85 return; 89 return;
86 } 90 }
87 #endif 91 #endif
88 92
89 // Avoid starting the lock/shutdown sequence if the power button is pressed 93 // Avoid starting the lock/shutdown sequence if the power button is pressed
90 // while the screen is off (http://crbug.com/128451), unless an external 94 // while the screen is off (http://crbug.com/128451), unless an external
91 // display is still on (http://crosbug.com/p/24912). 95 // display is still on (http://crosbug.com/p/24912).
92 if (brightness_is_zero_ && !internal_display_off_and_external_display_on_) 96 if (brightness_is_zero_ && !internal_display_off_and_external_display_on_)
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 } 208 }
205 209
206 void PowerButtonController::PowerButtonEventReceived( 210 void PowerButtonController::PowerButtonEventReceived(
207 bool down, 211 bool down,
208 const base::TimeTicks& timestamp) { 212 const base::TimeTicks& timestamp) {
209 OnPowerButtonEvent(down, timestamp); 213 OnPowerButtonEvent(down, timestamp);
210 } 214 }
211 #endif // defined(OS_CHROMEOS) 215 #endif // defined(OS_CHROMEOS)
212 216
213 } // namespace ash 217 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698