| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 EasyUnlockServiceSignin::UserData::UserData() | 89 EasyUnlockServiceSignin::UserData::UserData() |
| 90 : state(EasyUnlockServiceSignin::USER_DATA_STATE_INITIAL) { | 90 : state(EasyUnlockServiceSignin::USER_DATA_STATE_INITIAL) { |
| 91 } | 91 } |
| 92 | 92 |
| 93 EasyUnlockServiceSignin::UserData::~UserData() {} | 93 EasyUnlockServiceSignin::UserData::~UserData() {} |
| 94 | 94 |
| 95 EasyUnlockServiceSignin::EasyUnlockServiceSignin(Profile* profile) | 95 EasyUnlockServiceSignin::EasyUnlockServiceSignin(Profile* profile) |
| 96 : EasyUnlockService(profile), | 96 : EasyUnlockService(profile), |
| 97 allow_cryptohome_backoff_(true), | 97 allow_cryptohome_backoff_(true), |
| 98 service_active_(false), | 98 service_active_(false), |
| 99 user_pod_last_focused_timestamp_(base::TimeTicks::Now()), |
| 99 weak_ptr_factory_(this) { | 100 weak_ptr_factory_(this) { |
| 100 } | 101 } |
| 101 | 102 |
| 102 EasyUnlockServiceSignin::~EasyUnlockServiceSignin() { | 103 EasyUnlockServiceSignin::~EasyUnlockServiceSignin() { |
| 103 } | 104 } |
| 104 | 105 |
| 105 EasyUnlockService::Type EasyUnlockServiceSignin::GetType() const { | 106 EasyUnlockService::Type EasyUnlockServiceSignin::GetType() const { |
| 106 return EasyUnlockService::TYPE_SIGNIN; | 107 return EasyUnlockService::TYPE_SIGNIN; |
| 107 } | 108 } |
| 108 | 109 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 return data->devices[device_index].wrapped_secret; | 171 return data->devices[device_index].wrapped_secret; |
| 171 } | 172 } |
| 172 | 173 |
| 173 void EasyUnlockServiceSignin::RecordEasySignInOutcome( | 174 void EasyUnlockServiceSignin::RecordEasySignInOutcome( |
| 174 const std::string& user_id, | 175 const std::string& user_id, |
| 175 bool success) const { | 176 bool success) const { |
| 176 DCHECK_EQ(GetUserEmail(), user_id); | 177 DCHECK_EQ(GetUserEmail(), user_id); |
| 177 | 178 |
| 178 RecordEasyUnlockSigninEvent( | 179 RecordEasyUnlockSigninEvent( |
| 179 success ? EASY_UNLOCK_SUCCESS : EASY_UNLOCK_FAILURE); | 180 success ? EASY_UNLOCK_SUCCESS : EASY_UNLOCK_FAILURE); |
| 181 if (success) { |
| 182 RecordEasyUnlockSigninDuration( |
| 183 base::TimeTicks::Now() - user_pod_last_focused_timestamp_); |
| 184 } |
| 180 DVLOG(1) << "Easy sign-in " << (success ? "success" : "failure"); | 185 DVLOG(1) << "Easy sign-in " << (success ? "success" : "failure"); |
| 181 } | 186 } |
| 182 | 187 |
| 183 void EasyUnlockServiceSignin::RecordPasswordLoginEvent( | 188 void EasyUnlockServiceSignin::RecordPasswordLoginEvent( |
| 184 const std::string& user_id) const { | 189 const std::string& user_id) const { |
| 185 // This happens during tests, where a user could log in without the user pod | 190 // This happens during tests, where a user could log in without the user pod |
| 186 // being focused. | 191 // being focused. |
| 187 if (GetUserEmail() != user_id) | 192 if (GetUserEmail() != user_id) |
| 188 return; | 193 return; |
| 189 | 194 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 | 250 |
| 246 void EasyUnlockServiceSignin::OnScreenDidLock( | 251 void EasyUnlockServiceSignin::OnScreenDidLock( |
| 247 ScreenlockBridge::LockHandler::ScreenType screen_type) { | 252 ScreenlockBridge::LockHandler::ScreenType screen_type) { |
| 248 // In production code, the screen type should always be the signin screen; but | 253 // In production code, the screen type should always be the signin screen; but |
| 249 // in tests, the screen type might be different. | 254 // in tests, the screen type might be different. |
| 250 if (screen_type != ScreenlockBridge::LockHandler::SIGNIN_SCREEN) | 255 if (screen_type != ScreenlockBridge::LockHandler::SIGNIN_SCREEN) |
| 251 return; | 256 return; |
| 252 | 257 |
| 253 // Update initial UI is when the account picker on login screen is ready. | 258 // Update initial UI is when the account picker on login screen is ready. |
| 254 ShowInitialUserState(); | 259 ShowInitialUserState(); |
| 260 user_pod_last_focused_timestamp_ = base::TimeTicks::Now(); |
| 255 } | 261 } |
| 256 | 262 |
| 257 void EasyUnlockServiceSignin::OnScreenDidUnlock( | 263 void EasyUnlockServiceSignin::OnScreenDidUnlock( |
| 258 ScreenlockBridge::LockHandler::ScreenType screen_type) { | 264 ScreenlockBridge::LockHandler::ScreenType screen_type) { |
| 259 // In production code, the screen type should always be the signin screen; but | 265 // In production code, the screen type should always be the signin screen; but |
| 260 // in tests, the screen type might be different. | 266 // in tests, the screen type might be different. |
| 261 if (screen_type != ScreenlockBridge::LockHandler::SIGNIN_SCREEN) | 267 if (screen_type != ScreenlockBridge::LockHandler::SIGNIN_SCREEN) |
| 262 return; | 268 return; |
| 263 | 269 |
| 264 DisableAppWithoutResettingScreenlockState(); | 270 DisableAppWithoutResettingScreenlockState(); |
| 265 | 271 |
| 266 Shutdown(); | 272 Shutdown(); |
| 267 } | 273 } |
| 268 | 274 |
| 269 void EasyUnlockServiceSignin::OnFocusedUserChanged(const std::string& user_id) { | 275 void EasyUnlockServiceSignin::OnFocusedUserChanged(const std::string& user_id) { |
| 270 if (user_id_ == user_id) | 276 if (user_id_ == user_id) |
| 271 return; | 277 return; |
| 272 | 278 |
| 273 // Setting or clearing the user_id may changed |IsAllowed| value, so in these | 279 // Setting or clearing the user_id may changed |IsAllowed| value, so in these |
| 274 // cases update the app state. Otherwise, it's enough to notify the app the | 280 // cases update the app state. Otherwise, it's enough to notify the app the |
| 275 // user data has been updated. | 281 // user data has been updated. |
| 276 bool should_update_app_state = user_id_.empty() != user_id.empty(); | 282 bool should_update_app_state = user_id_.empty() != user_id.empty(); |
| 277 user_id_ = user_id; | 283 user_id_ = user_id; |
| 284 user_pod_last_focused_timestamp_ = base::TimeTicks::Now(); |
| 278 | 285 |
| 279 ResetScreenlockState(); | 286 ResetScreenlockState(); |
| 280 ShowInitialUserState(); | 287 ShowInitialUserState(); |
| 281 | 288 |
| 282 if (should_update_app_state) { | 289 if (should_update_app_state) { |
| 283 UpdateAppState(); | 290 UpdateAppState(); |
| 284 } else { | 291 } else { |
| 285 NotifyUserUpdated(); | 292 NotifyUserUpdated(); |
| 286 } | 293 } |
| 287 | 294 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 return NULL; | 362 return NULL; |
| 356 | 363 |
| 357 std::map<std::string, UserData*>::const_iterator it = | 364 std::map<std::string, UserData*>::const_iterator it = |
| 358 user_data_.find(user_id_); | 365 user_data_.find(user_id_); |
| 359 if (it == user_data_.end()) | 366 if (it == user_data_.end()) |
| 360 return NULL; | 367 return NULL; |
| 361 if (it->second->state != USER_DATA_STATE_LOADED) | 368 if (it->second->state != USER_DATA_STATE_LOADED) |
| 362 return NULL; | 369 return NULL; |
| 363 return it->second; | 370 return it->second; |
| 364 } | 371 } |
| OLD | NEW |