| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/power_event_observer.h" | 5 #include "ash/system/chromeos/power/power_event_observer.h" |
| 6 | 6 |
| 7 #include "ash/common/session/session_state_delegate.h" | 7 #include "ash/common/session/session_state_delegate.h" |
| 8 #include "ash/common/system/tray/system_tray_notifier.h" | 8 #include "ash/common/system/tray/system_tray_notifier.h" |
| 9 #include "ash/common/wm_shell.h" | 9 #include "ash/common/wm_shell.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 screen_lock_callback_.Reset(); | 70 screen_lock_callback_.Reset(); |
| 71 } | 71 } |
| 72 } | 72 } |
| 73 | 73 |
| 74 void PowerEventObserver::BrightnessChanged(int level, bool user_initiated) { | 74 void PowerEventObserver::BrightnessChanged(int level, bool user_initiated) { |
| 75 Shell::GetInstance()->power_button_controller()->OnScreenBrightnessChanged( | 75 Shell::GetInstance()->power_button_controller()->OnScreenBrightnessChanged( |
| 76 static_cast<double>(level)); | 76 static_cast<double>(level)); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void PowerEventObserver::SuspendImminent() { | 79 void PowerEventObserver::SuspendImminent() { |
| 80 Shell* shell = Shell::GetInstance(); | 80 SessionStateDelegate* delegate = WmShell::Get()->GetSessionStateDelegate(); |
| 81 SessionStateDelegate* delegate = shell->session_state_delegate(); | |
| 82 | 81 |
| 83 // This class is responsible for disabling all rendering requests at suspend | 82 // This class is responsible for disabling all rendering requests at suspend |
| 84 // time and then enabling them at resume time. When the | 83 // time and then enabling them at resume time. When the |
| 85 // lock-before-suspending pref is not set this is easy to do since | 84 // lock-before-suspending pref is not set this is easy to do since |
| 86 // StopRenderingRequests() is just called directly from this function. If the | 85 // StopRenderingRequests() is just called directly from this function. If the |
| 87 // lock-before-suspending pref _is_ set, then the suspend needs to be delayed | 86 // lock-before-suspending pref _is_ set, then the suspend needs to be delayed |
| 88 // until the lock screen is fully visible. While it is sufficient from a | 87 // until the lock screen is fully visible. While it is sufficient from a |
| 89 // security perspective to block only until the lock screen is ready, which | 88 // security perspective to block only until the lock screen is ready, which |
| 90 // guarantees that the contents of the user's screen are no longer visible, | 89 // guarantees that the contents of the user's screen are no longer visible, |
| 91 // this leads to poor UX on the first resume since neither the user pod nor | 90 // this leads to poor UX on the first resume since neither the user pod nor |
| (...skipping 21 matching lines...) Expand all Loading... |
| 113 screen_lock_callback_ = chromeos::DBusThreadManager::Get() | 112 screen_lock_callback_ = chromeos::DBusThreadManager::Get() |
| 114 ->GetPowerManagerClient() | 113 ->GetPowerManagerClient() |
| 115 ->GetSuspendReadinessCallback(); | 114 ->GetSuspendReadinessCallback(); |
| 116 } else { | 115 } else { |
| 117 // The lock-before-suspending pref is not set or the screen has already been | 116 // The lock-before-suspending pref is not set or the screen has already been |
| 118 // locked and the animations have completed. Rendering can be stopped now. | 117 // locked and the animations have completed. Rendering can be stopped now. |
| 119 StopRenderingRequests(); | 118 StopRenderingRequests(); |
| 120 } | 119 } |
| 121 | 120 |
| 122 ui::UserActivityDetector::Get()->OnDisplayPowerChanging(); | 121 ui::UserActivityDetector::Get()->OnDisplayPowerChanging(); |
| 123 shell->display_configurator()->SuspendDisplays(base::Bind( | 122 Shell::GetInstance()->display_configurator()->SuspendDisplays(base::Bind( |
| 124 &OnSuspendDisplaysCompleted, chromeos::DBusThreadManager::Get() | 123 &OnSuspendDisplaysCompleted, chromeos::DBusThreadManager::Get() |
| 125 ->GetPowerManagerClient() | 124 ->GetPowerManagerClient() |
| 126 ->GetSuspendReadinessCallback())); | 125 ->GetSuspendReadinessCallback())); |
| 127 } | 126 } |
| 128 | 127 |
| 129 void PowerEventObserver::SuspendDone(const base::TimeDelta& sleep_duration) { | 128 void PowerEventObserver::SuspendDone(const base::TimeDelta& sleep_duration) { |
| 130 Shell::GetInstance()->display_configurator()->ResumeDisplays(); | 129 Shell::GetInstance()->display_configurator()->ResumeDisplays(); |
| 131 WmShell::Get()->system_tray_notifier()->NotifyRefreshClock(); | 130 WmShell::Get()->system_tray_notifier()->NotifyRefreshClock(); |
| 132 | 131 |
| 133 // If the suspend request was being blocked while waiting for the lock | 132 // If the suspend request was being blocked while waiting for the lock |
| (...skipping 16 matching lines...) Expand all Loading... |
| 150 } else { | 149 } else { |
| 151 VLOG(1) << "Screen locked without suspend"; | 150 VLOG(1) << "Screen locked without suspend"; |
| 152 } | 151 } |
| 153 } | 152 } |
| 154 | 153 |
| 155 void PowerEventObserver::ScreenIsUnlocked() { | 154 void PowerEventObserver::ScreenIsUnlocked() { |
| 156 screen_locked_ = false; | 155 screen_locked_ = false; |
| 157 } | 156 } |
| 158 | 157 |
| 159 } // namespace ash | 158 } // namespace ash |
| OLD | NEW |