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

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

Issue 2739763003: Moves maintaining ShellObservers back to Shell (Closed)
Patch Set: Created 3 years, 9 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/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/shell_delegate.h"
10 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" 10 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } 75 }
76 76
77 TabletPowerButtonController::TabletPowerButtonController( 77 TabletPowerButtonController::TabletPowerButtonController(
78 LockStateController* controller) 78 LockStateController* controller)
79 : tick_clock_(new base::DefaultTickClock()), 79 : tick_clock_(new base::DefaultTickClock()),
80 force_off_on_button_up_(true), 80 force_off_on_button_up_(true),
81 controller_(controller), 81 controller_(controller),
82 weak_ptr_factory_(this) { 82 weak_ptr_factory_(this) {
83 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver( 83 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(
84 this); 84 this);
85 WmShell::Get()->AddShellObserver(this); 85 Shell::GetInstance()->AddShellObserver(this);
86 // TODO(mash): Provide a way for this class to observe stylus events: 86 // TODO(mash): Provide a way for this class to observe stylus events:
87 // http://crbug.com/682460 87 // http://crbug.com/682460
88 if (ui::InputDeviceManager::HasInstance()) 88 if (ui::InputDeviceManager::HasInstance())
89 ui::InputDeviceManager::GetInstance()->AddObserver(this); 89 ui::InputDeviceManager::GetInstance()->AddObserver(this);
90 Shell::GetInstance()->PrependPreTargetHandler(this); 90 Shell::GetInstance()->PrependPreTargetHandler(this);
91 91
92 GetInitialBacklightsForcedOff(); 92 GetInitialBacklightsForcedOff();
93 } 93 }
94 94
95 TabletPowerButtonController::~TabletPowerButtonController() { 95 TabletPowerButtonController::~TabletPowerButtonController() {
96 Shell::GetInstance()->RemovePreTargetHandler(this); 96 Shell::GetInstance()->RemovePreTargetHandler(this);
97 if (ui::InputDeviceManager::HasInstance()) 97 if (ui::InputDeviceManager::HasInstance())
98 ui::InputDeviceManager::GetInstance()->RemoveObserver(this); 98 ui::InputDeviceManager::GetInstance()->RemoveObserver(this);
99 WmShell::Get()->RemoveShellObserver(this); 99 Shell::GetInstance()->RemoveShellObserver(this);
100 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver( 100 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(
101 this); 101 this);
102 } 102 }
103 103
104 bool TabletPowerButtonController::ShouldHandlePowerButtonEvents() const { 104 bool TabletPowerButtonController::ShouldHandlePowerButtonEvents() const {
105 return IsTabletModeSupported(); 105 return IsTabletModeSupported();
106 } 106 }
107 107
108 void TabletPowerButtonController::OnPowerButtonEvent( 108 void TabletPowerButtonController::OnPowerButtonEvent(
109 bool down, 109 bool down,
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 WmShell::Get()->GetSessionStateDelegate(); 256 WmShell::Get()->GetSessionStateDelegate();
257 if (session_state_delegate->ShouldLockScreenAutomatically() && 257 if (session_state_delegate->ShouldLockScreenAutomatically() &&
258 session_state_delegate->CanLockScreen() && 258 session_state_delegate->CanLockScreen() &&
259 !session_state_delegate->IsUserSessionBlocked() && 259 !session_state_delegate->IsUserSessionBlocked() &&
260 !controller_->LockRequested()) { 260 !controller_->LockRequested()) {
261 session_state_delegate->LockScreen(); 261 session_state_delegate->LockScreen();
262 } 262 }
263 } 263 }
264 264
265 } // namespace ash 265 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698