OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/browser/chromeos/power/suspend_observer.h" | 5 #include "chrome/browser/chromeos/power/suspend_observer.h" |
6 | 6 |
| 7 #include "ash/shell.h" |
| 8 #include "ash/wm/user_activity_detector.h" |
7 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
8 #include "chrome/browser/chromeos/login/user_manager.h" | 10 #include "chrome/browser/chromeos/login/user_manager.h" |
9 #include "chrome/browser/extensions/api/system_private/system_private_api.h" | 11 #include "chrome/browser/extensions/api/system_private/system_private_api.h" |
10 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
12 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
13 #include "chromeos/dbus/dbus_thread_manager.h" | 15 #include "chromeos/dbus/dbus_thread_manager.h" |
14 #include "chromeos/display/output_configurator.h" | 16 #include "chromeos/display/output_configurator.h" |
15 | 17 |
16 namespace chromeos { | 18 namespace chromeos { |
(...skipping 18 matching lines...) Expand all Loading... |
35 // suspend and ask the session manager to lock the screen. | 37 // suspend and ask the session manager to lock the screen. |
36 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); | 38 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); |
37 if (profile && profile->GetPrefs()->GetBoolean(prefs::kEnableScreenLock) && | 39 if (profile && profile->GetPrefs()->GetBoolean(prefs::kEnableScreenLock) && |
38 UserManager::Get()->CanCurrentUserLock() && !screen_locked_) { | 40 UserManager::Get()->CanCurrentUserLock() && !screen_locked_) { |
39 screen_lock_callback_ = power_client_->GetSuspendReadinessCallback(); | 41 screen_lock_callback_ = power_client_->GetSuspendReadinessCallback(); |
40 // TODO(antrim) : additional logging for crbug/173178 | 42 // TODO(antrim) : additional logging for crbug/173178 |
41 LOG(WARNING) << "Requesting screen lock from SuspendObserver"; | 43 LOG(WARNING) << "Requesting screen lock from SuspendObserver"; |
42 session_client_->RequestLockScreen(); | 44 session_client_->RequestLockScreen(); |
43 } | 45 } |
44 | 46 |
| 47 ash::Shell::GetInstance()->user_activity_detector()->OnDisplayPowerChanging(); |
45 ash::Shell::GetInstance()->output_configurator()->SuspendDisplays(); | 48 ash::Shell::GetInstance()->output_configurator()->SuspendDisplays(); |
46 } | 49 } |
47 | 50 |
48 void SuspendObserver::ScreenIsLocked() { | 51 void SuspendObserver::ScreenIsLocked() { |
49 screen_locked_ = true; | 52 screen_locked_ = true; |
50 | 53 |
51 // Stop blocking suspend after the screen is locked. | 54 // Stop blocking suspend after the screen is locked. |
52 if (!screen_lock_callback_.is_null()) { | 55 if (!screen_lock_callback_.is_null()) { |
53 // Run the callback asynchronously. ScreenIsLocked() is currently | 56 // Run the callback asynchronously. ScreenIsLocked() is currently |
54 // called asynchronously after RequestLockScreen(), but this guards | 57 // called asynchronously after RequestLockScreen(), but this guards |
55 // against it being made synchronous later. | 58 // against it being made synchronous later. |
56 MessageLoop::current()->PostTask(FROM_HERE, screen_lock_callback_); | 59 MessageLoop::current()->PostTask(FROM_HERE, screen_lock_callback_); |
57 screen_lock_callback_.Reset(); | 60 screen_lock_callback_.Reset(); |
58 } | 61 } |
59 } | 62 } |
60 | 63 |
61 void SuspendObserver::ScreenIsUnlocked() { | 64 void SuspendObserver::ScreenIsUnlocked() { |
62 screen_locked_ = false; | 65 screen_locked_ = false; |
63 } | 66 } |
64 | 67 |
65 } // namespace chromeos | 68 } // namespace chromeos |
OLD | NEW |