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
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/power/brightness_observer.h"
8 #include "ash/wm/power_button_controller.h"
9 #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"
12 #include "chromeos/dbus/dbus_thread_manager.h"
16 BrightnessObserver::BrightnessObserver() {
17 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this);
20 BrightnessObserver::~BrightnessObserver() {
21 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this);
24 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
));
29 // 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
31 // is enabled). For Public Accounts, the session should be terminated instead
32 // as soon as the screen turns off.
33 // This implementation will be superseded after a revamp of the power manager
34 // is complete, see crbug.com/161267.
35 if (UserManager::Get()->IsLoggedInAsPublicAccount() &&
36 !level
&& !user_initiated
) {
37 chrome::AttemptUserExit();
41 } // namespace chromeos