Chromium Code Reviews| Index: chrome/browser/signin/easy_unlock_service.cc |
| diff --git a/chrome/browser/signin/easy_unlock_service.cc b/chrome/browser/signin/easy_unlock_service.cc |
| index a5ee5179f3a26e477364e1da49a07f1f524335b1..a2e5fd82469a495c4b7ba0011bc5422809810d84 100644 |
| --- a/chrome/browser/signin/easy_unlock_service.cc |
| +++ b/chrome/browser/signin/easy_unlock_service.cc |
| @@ -156,11 +156,14 @@ class EasyUnlockService::PowerMonitor |
| private: |
| // chromeos::PowerManagerClient::Observer: |
| virtual void SuspendImminent() override { |
| - service_->DisableAppIfLoaded(); |
| + service_->DisableAppIfLoaded(false /* don't reset screenlock state */); |
| + service_->GetScreenlockStateHandler()->ChangeState( |
| + EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING); |
| } |
| virtual void SuspendDone(const base::TimeDelta& sleep_duration) override { |
| - service_->LoadApp(); |
| + service_->UpdateAppState(); |
| + // Note that |this| may get deleted after |UpdateAppState| is called. |
| } |
| EasyUnlockService* service_; |
| @@ -229,8 +232,9 @@ bool EasyUnlockService::IsAllowed() { |
| return false; |
| #if defined(OS_CHROMEOS) |
| - if (!bluetooth_detector_->IsPresent()) |
| + if (bluetooth_detector_.get() && !bluetooth_detector_->IsPresent()) { |
|
Tim Song
2014/10/10 06:46:14
Comment that bluetooth_detector_ is NULL if we suc
|
| return false; |
| + } |
| return true; |
| #else |
| @@ -419,9 +423,9 @@ void EasyUnlockService::LoadApp() { |
| #endif // defined(GOOGLE_CHROME_BUILD) |
| } |
| -void EasyUnlockService::DisableAppIfLoaded() { |
| - // Make sure lock screen state set by the extension gets reset. |
| - ResetScreenlockState(); |
| +void EasyUnlockService::DisableAppIfLoaded(bool reset_screenlock_state) { |
| + if (reset_screenlock_state) |
| + ResetScreenlockState(); |
| extensions::ComponentLoader* loader = GetComponentLoader(profile_); |
| if (!loader->Exists(extension_misc::kEasyUnlockAppId)) |
| @@ -452,6 +456,13 @@ void EasyUnlockService::ReloadApp() { |
| void EasyUnlockService::UpdateAppState() { |
| if (IsAllowed()) { |
| + // Bluetooth detector is used to make sure Easy Unlock is not enabled on |
| + // devices that do not support Bluetooth. If Easy Unlock is allowed, that |
| + // means that the bluetooth is supported on the device, so bluetooth |
| + // detector is not needed any more (and might actually prolong time needed |
| + // for the app to get reloaded after suspend). |
| + bluetooth_detector_.reset(); |
|
tbarzic
2014/10/10 01:12:54
Let me know if you don't like this and I'll try to
Tim Song
2014/10/10 06:46:14
I'm fine with this, and improving the start-up tim
xiyuan
2014/10/10 15:45:53
The detector is kept around to support devices tha
tbarzic
2014/10/10 17:59:43
Yeah, I though there may be a reason for keeping d
|
| + |
| LoadApp(); |
| #if defined(OS_CHROMEOS) |
| @@ -459,7 +470,7 @@ void EasyUnlockService::UpdateAppState() { |
| power_monitor_.reset(new PowerMonitor(this)); |
| #endif |
| } else { |
| - DisableAppIfLoaded(); |
| + DisableAppIfLoaded(true /* reset screenlock state */); |
| #if defined(OS_CHROMEOS) |
| power_monitor_.reset(); |
| #endif |