| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_PROXIMITY_AUTH_SCREENLOCK_BRIDGE_H_ | 5 #ifndef COMPONENTS_PROXIMITY_AUTH_SCREENLOCK_BRIDGE_H_ |
| 6 #define COMPONENTS_PROXIMITY_AUTH_SCREENLOCK_BRIDGE_H_ | 6 #define COMPONENTS_PROXIMITY_AUTH_SCREENLOCK_BRIDGE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
| 14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 | 16 |
| 17 #include "components/user_manager/user_id.h" |
| 18 |
| 17 namespace content { | 19 namespace content { |
| 18 class BrowserContext; | 20 class BrowserContext; |
| 19 } // namespace content | 21 } // namespace content |
| 20 | 22 |
| 21 namespace proximity_auth { | 23 namespace proximity_auth { |
| 22 | 24 |
| 23 class ProximityAuthClient; | 25 class ProximityAuthClient; |
| 24 | 26 |
| 25 // ScreenlockBridge brings together the screenLockPrivate API and underlying | 27 // ScreenlockBridge brings together the screenLockPrivate API and underlying |
| 26 // support. On ChromeOS, it delegates calls to the ScreenLocker. On other | 28 // support. On ChromeOS, it delegates calls to the ScreenLocker. On other |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 FORCE_OFFLINE_PASSWORD = 5 | 109 FORCE_OFFLINE_PASSWORD = 5 |
| 108 }; | 110 }; |
| 109 | 111 |
| 110 enum ScreenType { SIGNIN_SCREEN = 0, LOCK_SCREEN = 1, OTHER_SCREEN = 2 }; | 112 enum ScreenType { SIGNIN_SCREEN = 0, LOCK_SCREEN = 1, OTHER_SCREEN = 2 }; |
| 111 | 113 |
| 112 // Displays |message| in a banner on the lock screen. | 114 // Displays |message| in a banner on the lock screen. |
| 113 virtual void ShowBannerMessage(const base::string16& message) = 0; | 115 virtual void ShowBannerMessage(const base::string16& message) = 0; |
| 114 | 116 |
| 115 // Shows a custom icon in the user pod on the lock screen. | 117 // Shows a custom icon in the user pod on the lock screen. |
| 116 virtual void ShowUserPodCustomIcon( | 118 virtual void ShowUserPodCustomIcon( |
| 117 const std::string& user_email, | 119 const user_manager::UserID& user_id, |
| 118 const UserPodCustomIconOptions& icon) = 0; | 120 const UserPodCustomIconOptions& icon) = 0; |
| 119 | 121 |
| 120 // Hides the custom icon in user pod for a user. | 122 // Hides the custom icon in user pod for a user. |
| 121 virtual void HideUserPodCustomIcon(const std::string& user_email) = 0; | 123 virtual void HideUserPodCustomIcon(const user_manager::UserID& user_id) = 0; |
| 122 | 124 |
| 123 // (Re)enable lock screen UI. | 125 // (Re)enable lock screen UI. |
| 124 virtual void EnableInput() = 0; | 126 virtual void EnableInput() = 0; |
| 125 | 127 |
| 126 // Set the authentication type to be used on the lock screen. | 128 // Set the authentication type to be used on the lock screen. |
| 127 virtual void SetAuthType(const std::string& user_email, | 129 virtual void SetAuthType(const user_manager::UserID& user_id, |
| 128 AuthType auth_type, | 130 AuthType auth_type, |
| 129 const base::string16& auth_value) = 0; | 131 const base::string16& auth_value) = 0; |
| 130 | 132 |
| 131 // Returns the authentication type used for a user. | 133 // Returns the authentication type used for a user. |
| 132 virtual AuthType GetAuthType(const std::string& user_email) const = 0; | 134 virtual AuthType GetAuthType(const user_manager::UserID& user_id) const = 0; |
| 133 | 135 |
| 134 // Returns the type of the screen -- a signin or a lock screen. | 136 // Returns the type of the screen -- a signin or a lock screen. |
| 135 virtual ScreenType GetScreenType() const = 0; | 137 virtual ScreenType GetScreenType() const = 0; |
| 136 | 138 |
| 137 // Unlocks from easy unlock app for a user. | 139 // Unlocks from easy unlock app for a user. |
| 138 virtual void Unlock(const std::string& user_email) = 0; | 140 virtual void Unlock(const user_manager::UserID& user_id) = 0; |
| 139 | 141 |
| 140 // Attempts to login the user using an easy unlock key. | 142 // Attempts to login the user using an easy unlock key. |
| 141 virtual void AttemptEasySignin(const std::string& user_email, | 143 virtual void AttemptEasySignin(const user_manager::UserID& user_id, |
| 142 const std::string& secret, | 144 const std::string& secret, |
| 143 const std::string& key_label) = 0; | 145 const std::string& key_label) = 0; |
| 144 | 146 |
| 145 protected: | 147 protected: |
| 146 virtual ~LockHandler() {} | 148 virtual ~LockHandler() {} |
| 147 }; | 149 }; |
| 148 | 150 |
| 149 class Observer { | 151 class Observer { |
| 150 public: | 152 public: |
| 151 // Invoked after the screen is locked. | 153 // Invoked after the screen is locked. |
| 152 virtual void OnScreenDidLock(LockHandler::ScreenType screen_type) = 0; | 154 virtual void OnScreenDidLock(LockHandler::ScreenType screen_type) = 0; |
| 153 | 155 |
| 154 // Invoked after the screen lock is dismissed. | 156 // Invoked after the screen lock is dismissed. |
| 155 virtual void OnScreenDidUnlock(LockHandler::ScreenType screen_type) = 0; | 157 virtual void OnScreenDidUnlock(LockHandler::ScreenType screen_type) = 0; |
| 156 | 158 |
| 157 // Invoked when the user focused on the lock screen changes. | 159 // Invoked when the user focused on the lock screen changes. |
| 158 virtual void OnFocusedUserChanged(const std::string& user_id) = 0; | 160 virtual void OnFocusedUserChanged(const user_manager::UserID& user_id) = 0; |
| 159 | 161 |
| 160 protected: | 162 protected: |
| 161 virtual ~Observer() {} | 163 virtual ~Observer() {} |
| 162 }; | 164 }; |
| 163 | 165 |
| 164 void SetLockHandler(LockHandler* lock_handler); | 166 void SetLockHandler(LockHandler* lock_handler); |
| 165 void SetFocusedUser(const std::string& user_id); | 167 void SetFocusedUser(const user_manager::UserID& user_id); |
| 166 | 168 |
| 167 bool IsLocked() const; | 169 bool IsLocked() const; |
| 168 void Lock(content::BrowserContext* browser_context); | 170 void Lock(content::BrowserContext* browser_context); |
| 169 void Unlock(content::BrowserContext* browser_context); | 171 void Unlock(content::BrowserContext* browser_context); |
| 170 | 172 |
| 171 void AddObserver(Observer* observer); | 173 void AddObserver(Observer* observer); |
| 172 void RemoveObserver(Observer* observer); | 174 void RemoveObserver(Observer* observer); |
| 173 | 175 |
| 174 LockHandler* lock_handler() { return lock_handler_; } | 176 LockHandler* lock_handler() { return lock_handler_; } |
| 175 | 177 |
| 176 std::string focused_user_id() const { return focused_user_id_; } | 178 const user_manager::UserID& focused_user_id() const { return focused_user_id_;
} |
| 177 | 179 |
| 178 private: | 180 private: |
| 179 ProximityAuthClient* client_; // Not owned. Must outlive this object. | 181 ProximityAuthClient* client_; // Not owned. Must outlive this object. |
| 180 LockHandler* lock_handler_; // Not owned | 182 LockHandler* lock_handler_; // Not owned |
| 181 // The last focused user's id. | 183 // The last focused user's id. |
| 182 std::string focused_user_id_; | 184 user_manager::UserID focused_user_id_; |
| 183 ObserverList<Observer, true> observers_; | 185 ObserverList<Observer, true> observers_; |
| 184 | 186 |
| 185 DISALLOW_COPY_AND_ASSIGN(ScreenlockBridge); | 187 DISALLOW_COPY_AND_ASSIGN(ScreenlockBridge); |
| 186 }; | 188 }; |
| 187 | 189 |
| 188 } // namespace proximity_auth | 190 } // namespace proximity_auth |
| 189 | 191 |
| 190 #endif // COMPONENTS_PROXIMITY_AUTH_SCREENLOCK_BRIDGE_H_ | 192 #endif // COMPONENTS_PROXIMITY_AUTH_SCREENLOCK_BRIDGE_H_ |
| OLD | NEW |