| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_CHROMEOS_CROS_SCREEN_LOCK_LIBRARY_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_SCREEN_LOCK_LIBRARY_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_CROS_SCREEN_LOCK_LIBRARY_H_ | 6 #define CHROME_BROWSER_CHROMEOS_CROS_SCREEN_LOCK_LIBRARY_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
| 10 #include "cros/chromeos_screen_lock.h" | 10 #include "cros/chromeos_screen_lock.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 virtual void RemoveObserver(Observer* observer) = 0; | 28 virtual void RemoveObserver(Observer* observer) = 0; |
| 29 | 29 |
| 30 // Notifies PowerManager that screen lock has been completed. | 30 // Notifies PowerManager that screen lock has been completed. |
| 31 virtual void NotifyScreenLockCompleted() = 0; | 31 virtual void NotifyScreenLockCompleted() = 0; |
| 32 // Notifies PowerManager that a user requested to lock the screen. | 32 // Notifies PowerManager that a user requested to lock the screen. |
| 33 virtual void NotifyScreenLockRequested() = 0; | 33 virtual void NotifyScreenLockRequested() = 0; |
| 34 // Notifies PowerManager that a user unlocked the screen. | 34 // Notifies PowerManager that a user unlocked the screen. |
| 35 virtual void NotifyScreenUnlockRequested() = 0; | 35 virtual void NotifyScreenUnlockRequested() = 0; |
| 36 // Notifies PowerManager that screen is unlocked. | 36 // Notifies PowerManager that screen is unlocked. |
| 37 virtual void NotifyScreenUnlockCompleted() = 0; | 37 virtual void NotifyScreenUnlockCompleted() = 0; |
| 38 }; | |
| 39 | 38 |
| 40 // This class handles the interaction with the ChromeOS screen lock APIs. | 39 // Get library implementation. |
| 41 class ScreenLockLibraryImpl : public ScreenLockLibrary { | 40 static ScreenLockLibrary* GetImpl(bool stub); |
| 42 public: | |
| 43 ScreenLockLibraryImpl(); | |
| 44 virtual ~ScreenLockLibraryImpl(); | |
| 45 | |
| 46 // ScreenLockLibrary implementations: | |
| 47 virtual void AddObserver(Observer* observer); | |
| 48 virtual void RemoveObserver(Observer* observer); | |
| 49 virtual void NotifyScreenLockRequested(); | |
| 50 virtual void NotifyScreenLockCompleted(); | |
| 51 virtual void NotifyScreenUnlockRequested(); | |
| 52 virtual void NotifyScreenUnlockCompleted(); | |
| 53 | |
| 54 private: | |
| 55 // This method is called when PowerManager requests to lock the screen. | |
| 56 // This method is called on a background thread. | |
| 57 static void ScreenLockedHandler(void* object, ScreenLockEvent event); | |
| 58 | |
| 59 // This methods starts the monitoring of screen lock request. | |
| 60 void Init(); | |
| 61 | |
| 62 // Called by the handler to notify the screen lock request from | |
| 63 // SessionManager. | |
| 64 void LockScreen(); | |
| 65 | |
| 66 // Called by the handler to notify the screen unlock request from | |
| 67 // SessionManager. | |
| 68 void UnlockScreen(); | |
| 69 | |
| 70 // Called by the handler to notify the screen unlock request has been | |
| 71 // failed. | |
| 72 void UnlockScreenFailed(); | |
| 73 | |
| 74 ObserverList<Observer> observers_; | |
| 75 | |
| 76 // A reference to the screen lock api | |
| 77 chromeos::ScreenLockConnection screen_lock_connection_; | |
| 78 | |
| 79 DISALLOW_COPY_AND_ASSIGN(ScreenLockLibraryImpl); | |
| 80 }; | 41 }; |
| 81 | 42 |
| 82 } // namespace chromeos | 43 } // namespace chromeos |
| 83 | 44 |
| 84 #endif // CHROME_BROWSER_CHROMEOS_CROS_SCREEN_LOCK_LIBRARY_H_ | 45 #endif // CHROME_BROWSER_CHROMEOS_CROS_SCREEN_LOCK_LIBRARY_H_ |
| OLD | NEW |