| 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_regular.h" | 5 #include "chrome/browser/signin/easy_unlock_service_regular.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/prefs/scoped_user_pref_update.h" | 10 #include "base/prefs/scoped_user_pref_update.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 // Key name of the remote device list in kEasyUnlockPairing. | 46 // Key name of the remote device list in kEasyUnlockPairing. |
| 47 const char kKeyDevices[] = "devices"; | 47 const char kKeyDevices[] = "devices"; |
| 48 | 48 |
| 49 } // namespace | 49 } // namespace |
| 50 | 50 |
| 51 EasyUnlockServiceRegular::EasyUnlockServiceRegular(Profile* profile) | 51 EasyUnlockServiceRegular::EasyUnlockServiceRegular(Profile* profile) |
| 52 : EasyUnlockService(profile), | 52 : EasyUnlockService(profile), |
| 53 turn_off_flow_status_(EasyUnlockService::IDLE), | 53 turn_off_flow_status_(EasyUnlockService::IDLE), |
| 54 will_unlock_using_easy_unlock_(false), | 54 will_unlock_using_easy_unlock_(false), |
| 55 lock_screen_last_shown_timestamp_(base::TimeTicks::Now()), |
| 55 weak_ptr_factory_(this) { | 56 weak_ptr_factory_(this) { |
| 56 } | 57 } |
| 57 | 58 |
| 58 EasyUnlockServiceRegular::~EasyUnlockServiceRegular() { | 59 EasyUnlockServiceRegular::~EasyUnlockServiceRegular() { |
| 59 } | 60 } |
| 60 | 61 |
| 61 EasyUnlockService::Type EasyUnlockServiceRegular::GetType() const { | 62 EasyUnlockService::Type EasyUnlockServiceRegular::GetType() const { |
| 62 return EasyUnlockService::TYPE_REGULAR; | 63 return EasyUnlockService::TYPE_REGULAR; |
| 63 } | 64 } |
| 64 | 65 |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 #else | 315 #else |
| 315 // TODO(xiyuan): Revisit when non-chromeos platforms are supported. | 316 // TODO(xiyuan): Revisit when non-chromeos platforms are supported. |
| 316 return false; | 317 return false; |
| 317 #endif | 318 #endif |
| 318 } | 319 } |
| 319 | 320 |
| 320 void EasyUnlockServiceRegular::OnWillFinalizeUnlock(bool success) { | 321 void EasyUnlockServiceRegular::OnWillFinalizeUnlock(bool success) { |
| 321 will_unlock_using_easy_unlock_ = success; | 322 will_unlock_using_easy_unlock_ = success; |
| 322 } | 323 } |
| 323 | 324 |
| 325 void EasyUnlockServiceRegular::OnSuspendDone() { |
| 326 lock_screen_last_shown_timestamp_ = base::TimeTicks::Now(); |
| 327 } |
| 328 |
| 324 void EasyUnlockServiceRegular::OnScreenDidLock( | 329 void EasyUnlockServiceRegular::OnScreenDidLock( |
| 325 ScreenlockBridge::LockHandler::ScreenType screen_type) { | 330 ScreenlockBridge::LockHandler::ScreenType screen_type) { |
| 326 will_unlock_using_easy_unlock_ = false; | 331 will_unlock_using_easy_unlock_ = false; |
| 332 lock_screen_last_shown_timestamp_ = base::TimeTicks::Now(); |
| 327 } | 333 } |
| 328 | 334 |
| 329 void EasyUnlockServiceRegular::OnScreenDidUnlock( | 335 void EasyUnlockServiceRegular::OnScreenDidUnlock( |
| 330 ScreenlockBridge::LockHandler::ScreenType screen_type) { | 336 ScreenlockBridge::LockHandler::ScreenType screen_type) { |
| 331 // Notifications of signin screen unlock events can also reach this code path; | 337 // Notifications of signin screen unlock events can also reach this code path; |
| 332 // disregard them. | 338 // disregard them. |
| 333 if (screen_type != ScreenlockBridge::LockHandler::LOCK_SCREEN) | 339 if (screen_type != ScreenlockBridge::LockHandler::LOCK_SCREEN) |
| 334 return; | 340 return; |
| 335 | 341 |
| 336 // Only record metrics for users who have enabled the feature. | 342 // Only record metrics for users who have enabled the feature. |
| 337 if (IsEnabled()) { | 343 if (IsEnabled()) { |
| 338 EasyUnlockAuthEvent event = | 344 EasyUnlockAuthEvent event = |
| 339 will_unlock_using_easy_unlock_ | 345 will_unlock_using_easy_unlock_ |
| 340 ? EASY_UNLOCK_SUCCESS | 346 ? EASY_UNLOCK_SUCCESS |
| 341 : GetPasswordAuthEvent(); | 347 : GetPasswordAuthEvent(); |
| 342 RecordEasyUnlockScreenUnlockEvent(event); | 348 RecordEasyUnlockScreenUnlockEvent(event); |
| 349 |
| 350 if (will_unlock_using_easy_unlock_) { |
| 351 RecordEasyUnlockScreenUnlockDuration( |
| 352 base::TimeTicks::Now() - lock_screen_last_shown_timestamp_); |
| 353 } |
| 343 } | 354 } |
| 344 | 355 |
| 345 will_unlock_using_easy_unlock_ = false; | 356 will_unlock_using_easy_unlock_ = false; |
| 346 } | 357 } |
| 347 | 358 |
| 348 void EasyUnlockServiceRegular::OnFocusedUserChanged( | 359 void EasyUnlockServiceRegular::OnFocusedUserChanged( |
| 349 const std::string& user_id) { | 360 const std::string& user_id) { |
| 350 // Nothing to do. | 361 // Nothing to do. |
| 351 } | 362 } |
| 352 | 363 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 new base::DictionaryValue()); | 399 new base::DictionaryValue()); |
| 389 user_prefs_dict->SetBooleanWithoutPathExpansion( | 400 user_prefs_dict->SetBooleanWithoutPathExpansion( |
| 390 prefs::kEasyUnlockProximityRequired, | 401 prefs::kEasyUnlockProximityRequired, |
| 391 profile_prefs->GetBoolean(prefs::kEasyUnlockProximityRequired)); | 402 profile_prefs->GetBoolean(prefs::kEasyUnlockProximityRequired)); |
| 392 | 403 |
| 393 DictionaryPrefUpdate update(local_state, | 404 DictionaryPrefUpdate update(local_state, |
| 394 prefs::kEasyUnlockLocalStateUserPrefs); | 405 prefs::kEasyUnlockLocalStateUserPrefs); |
| 395 std::string user_email = GetUserEmail(); | 406 std::string user_email = GetUserEmail(); |
| 396 update->SetWithoutPathExpansion(user_email, user_prefs_dict.Pass()); | 407 update->SetWithoutPathExpansion(user_email, user_prefs_dict.Pass()); |
| 397 } | 408 } |
| OLD | NEW |