| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #include "chrome/browser/chromeos/power/output_observer.h" | |
| 6 | |
| 7 #include "ash/shell.h" | |
| 8 #include "ash/wm/user_activity_detector.h" | |
| 9 #include "chromeos/dbus/dbus_thread_manager.h" | |
| 10 #include "chromeos/display/output_configurator.h" | |
| 11 | |
| 12 namespace chromeos { | |
| 13 | |
| 14 OutputObserver::OutputObserver() { | |
| 15 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); | |
| 16 } | |
| 17 | |
| 18 OutputObserver::~OutputObserver() { | |
| 19 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); | |
| 20 } | |
| 21 | |
| 22 void OutputObserver::ScreenPowerSet(bool power_on, bool all_displays) { | |
| 23 // Turning displays off when the device becomes idle or on just before we | |
| 24 // suspend may trigger a mouse move, which would then be incorrectly | |
| 25 // reported as user activity. Let the UserActivityDetector know so that | |
| 26 // it can ignore such events. | |
| 27 ash::Shell::GetInstance()->user_activity_detector()->OnDisplayPowerChanging(); | |
| 28 | |
| 29 DisplayPowerState state = DISPLAY_POWER_ALL_ON; | |
| 30 if (power_on && all_displays) | |
| 31 state = DISPLAY_POWER_ALL_ON; | |
| 32 else if (power_on && !all_displays) | |
| 33 state = DISPLAY_POWER_INTERNAL_ON_EXTERNAL_OFF; | |
| 34 else if (!power_on && all_displays) | |
| 35 state = DISPLAY_POWER_ALL_OFF; | |
| 36 else if (!power_on && !all_displays) | |
| 37 state = DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON; | |
| 38 | |
| 39 ash::Shell::GetInstance()->output_configurator()->SetDisplayPower( | |
| 40 state, false); | |
| 41 } | |
| 42 | |
| 43 } // namespace chromeos | |
| OLD | NEW |