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