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 #include "chrome/browser/signin/easy_unlock_service_signin_chromeos.h" | 5 #include "chrome/browser/signin/easy_unlock_service_signin_chromeos.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 154 |
155 std::string EasyUnlockServiceSignin::GetChallenge() const { | 155 std::string EasyUnlockServiceSignin::GetChallenge() const { |
156 const UserData* data = FindLoadedDataForCurrentUser(); | 156 const UserData* data = FindLoadedDataForCurrentUser(); |
157 // TODO(xiyuan): Use correct remote device instead of hard coded first one. | 157 // TODO(xiyuan): Use correct remote device instead of hard coded first one. |
158 uint32 device_index = 0; | 158 uint32 device_index = 0; |
159 if (!data || data->devices.size() <= device_index) | 159 if (!data || data->devices.size() <= device_index) |
160 return std::string(); | 160 return std::string(); |
161 return data->devices[device_index].challenge; | 161 return data->devices[device_index].challenge; |
162 } | 162 } |
163 | 163 |
| 164 std::string EasyUnlockServiceSignin::GetWrappedSecret() const { |
| 165 const UserData* data = FindLoadedDataForCurrentUser(); |
| 166 // TODO(xiyuan): Use correct remote device instead of hard coded first one. |
| 167 uint32 device_index = 0; |
| 168 if (!data || data->devices.size() <= device_index) |
| 169 return std::string(); |
| 170 return data->devices[device_index].wrapped_secret; |
| 171 } |
| 172 |
164 void EasyUnlockServiceSignin::InitializeInternal() { | 173 void EasyUnlockServiceSignin::InitializeInternal() { |
165 if (chromeos::LoginState::Get()->IsUserLoggedIn()) | 174 if (chromeos::LoginState::Get()->IsUserLoggedIn()) |
166 return; | 175 return; |
167 | 176 |
168 service_active_ = true; | 177 service_active_ = true; |
169 | 178 |
170 chromeos::LoginState::Get()->AddObserver(this); | 179 chromeos::LoginState::Get()->AddObserver(this); |
171 ScreenlockBridge* screenlock_bridge = ScreenlockBridge::Get(); | 180 ScreenlockBridge* screenlock_bridge = ScreenlockBridge::Get(); |
172 screenlock_bridge->AddObserver(this); | 181 screenlock_bridge->AddObserver(this); |
173 if (!screenlock_bridge->focused_user_id().empty()) | 182 if (!screenlock_bridge->focused_user_id().empty()) |
(...skipping 27 matching lines...) Expand all Loading... |
201 void EasyUnlockServiceSignin::OnFocusedUserChanged(const std::string& user_id) { | 210 void EasyUnlockServiceSignin::OnFocusedUserChanged(const std::string& user_id) { |
202 if (user_id_ == user_id) | 211 if (user_id_ == user_id) |
203 return; | 212 return; |
204 | 213 |
205 // Setting or clearing the user_id may changed |IsAllowed| value, so in these | 214 // Setting or clearing the user_id may changed |IsAllowed| value, so in these |
206 // cases update the app state. Otherwise, it's enough to notify the app the | 215 // cases update the app state. Otherwise, it's enough to notify the app the |
207 // user data has been updated. | 216 // user data has been updated. |
208 bool should_update_app_state = user_id_.empty() != user_id.empty(); | 217 bool should_update_app_state = user_id_.empty() != user_id.empty(); |
209 user_id_ = user_id; | 218 user_id_ = user_id; |
210 | 219 |
211 ResetScreenlockStateHandler(); | 220 ResetScreenlockState(); |
212 | 221 |
213 if (should_update_app_state) { | 222 if (should_update_app_state) { |
214 UpdateAppState(); | 223 UpdateAppState(); |
215 } else { | 224 } else { |
216 NotifyUserUpdated(); | 225 NotifyUserUpdated(); |
217 } | 226 } |
218 | 227 |
219 LoadCurrentUserDataIfNeeded(); | 228 LoadCurrentUserDataIfNeeded(); |
220 } | 229 } |
221 | 230 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 return NULL; | 283 return NULL; |
275 | 284 |
276 std::map<std::string, UserData*>::const_iterator it = | 285 std::map<std::string, UserData*>::const_iterator it = |
277 user_data_.find(user_id_); | 286 user_data_.find(user_id_); |
278 if (it == user_data_.end()) | 287 if (it == user_data_.end()) |
279 return NULL; | 288 return NULL; |
280 if (it->second->state != USER_DATA_STATE_LOADED) | 289 if (it->second->state != USER_DATA_STATE_LOADED) |
281 return NULL; | 290 return NULL; |
282 return it->second; | 291 return it->second; |
283 } | 292 } |
OLD | NEW |