Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "chrome/browser/chromeos/power/brightness_observer.h" | 5 #include "chrome/browser/chromeos/power/brightness_observer.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/wm/power_button_controller.h" | |
| 9 #include "chrome/browser/chromeos/login/user_manager.h" | 8 #include "chrome/browser/chromeos/login/user_manager.h" |
| 10 #include "chrome/browser/extensions/api/system_private/system_private_api.h" | |
| 11 #include "chrome/browser/lifetime/application_lifetime.h" | 9 #include "chrome/browser/lifetime/application_lifetime.h" |
| 12 #include "chromeos/dbus/dbus_thread_manager.h" | 10 #include "chromeos/dbus/dbus_thread_manager.h" |
| 13 | 11 |
| 14 namespace chromeos { | 12 namespace chromeos { |
| 15 | 13 |
| 16 BrightnessObserver::BrightnessObserver() { | 14 BrightnessObserver::BrightnessObserver() { |
| 17 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); | 15 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); |
| 18 } | 16 } |
| 19 | 17 |
| 20 BrightnessObserver::~BrightnessObserver() { | 18 BrightnessObserver::~BrightnessObserver() { |
| 21 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); | 19 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); |
| 22 } | 20 } |
| 23 | 21 |
| 24 void BrightnessObserver::BrightnessChanged(int level, bool user_initiated) { | 22 void BrightnessObserver::BrightnessChanged(int level, bool user_initiated) { |
| 25 extensions::DispatchBrightnessChangedEvent(level, user_initiated); | |
| 26 ash::Shell::GetInstance()->power_button_controller()-> | |
| 27 OnScreenBrightnessChanged(static_cast<double>(level)); | |
| 28 | |
| 29 // When the user is idle, the power manager dims the screen, turns off the | 23 // When the user is idle, the power manager dims the screen, turns off the |
| 30 // screen and eventually locks the screen (if screen lock on idle and suspend | 24 // screen and eventually locks the screen (if screen lock on idle and suspend |
| 31 // is enabled). For Public Accounts, the session should be terminated instead | 25 // is enabled). For Public Accounts, the session should be terminated instead |
| 32 // as soon as the screen turns off. | 26 // as soon as the screen turns off. |
| 33 // This implementation will be superseded after a revamp of the power manager | 27 // This implementation will be superseded after a revamp of the power manager |
| 34 // is complete, see crbug.com/161267. | 28 // is complete, see crbug.com/161267. |
| 35 if (UserManager::Get()->IsLoggedInAsPublicAccount() && | 29 if (UserManager::Get()->IsLoggedInAsPublicAccount() && |
| 36 !level && !user_initiated) { | 30 !level && !user_initiated) { |
| 37 chrome::AttemptUserExit(); | 31 chrome::AttemptUserExit(); |
|
stevenjb
2013/10/09 18:52:28
If we do need this, it seems like we should put th
Daniel Erat
2013/10/09 19:25:30
I dunno... I'm still pretty hopeful that this can
stevenjb
2013/10/09 20:15:36
1. OK, fair, this is fine here then if we can't re
Daniel Erat
2013/10/09 20:36:39
(Discussed in person: I'm going to clean this up i
| |
| 38 } | 32 } |
| 39 } | 33 } |
| 40 | 34 |
| 41 } // namespace chromeos | 35 } // namespace chromeos |
| OLD | NEW |