Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(418)

Side by Side Diff: chrome/browser/signin/easy_unlock_service.cc

Issue 644873002: Easy Unlock Show connecting user pod icon when waking up from sleep (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/signin/easy_unlock_service.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.h" 5 #include "chrome/browser/signin/easy_unlock_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 } 149 }
150 150
151 virtual ~PowerMonitor() { 151 virtual ~PowerMonitor() {
152 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> 152 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
153 RemoveObserver(this); 153 RemoveObserver(this);
154 } 154 }
155 155
156 private: 156 private:
157 // chromeos::PowerManagerClient::Observer: 157 // chromeos::PowerManagerClient::Observer:
158 virtual void SuspendImminent() override { 158 virtual void SuspendImminent() override {
159 service_->DisableAppIfLoaded(); 159 service_->DisableAppIfLoaded(false /* don't reset screenlock state */);
160 service_->GetScreenlockStateHandler()->ChangeState(
161 EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING);
160 } 162 }
161 163
162 virtual void SuspendDone(const base::TimeDelta& sleep_duration) override { 164 virtual void SuspendDone(const base::TimeDelta& sleep_duration) override {
163 service_->LoadApp(); 165 service_->UpdateAppState();
166 // Note that |this| may get deleted after |UpdateAppState| is called.
164 } 167 }
165 168
166 EasyUnlockService* service_; 169 EasyUnlockService* service_;
167 170
168 DISALLOW_COPY_AND_ASSIGN(PowerMonitor); 171 DISALLOW_COPY_AND_ASSIGN(PowerMonitor);
169 }; 172 };
170 #endif 173 #endif
171 174
172 EasyUnlockService::EasyUnlockService(Profile* profile) 175 EasyUnlockService::EasyUnlockService(Profile* profile)
173 : profile_(profile), 176 : profile_(profile),
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 } 225 }
223 226
224 bool EasyUnlockService::IsAllowed() { 227 bool EasyUnlockService::IsAllowed() {
225 if (shut_down_) 228 if (shut_down_)
226 return false; 229 return false;
227 230
228 if (!IsAllowedInternal()) 231 if (!IsAllowedInternal())
229 return false; 232 return false;
230 233
231 #if defined(OS_CHROMEOS) 234 #if defined(OS_CHROMEOS)
232 if (!bluetooth_detector_->IsPresent()) 235 if (bluetooth_detector_.get() && !bluetooth_detector_->IsPresent()) {
Tim Song 2014/10/10 06:46:14 Comment that bluetooth_detector_ is NULL if we suc
233 return false; 236 return false;
237 }
234 238
235 return true; 239 return true;
236 #else 240 #else
237 // TODO(xiyuan): Revisit when non-chromeos platforms are supported. 241 // TODO(xiyuan): Revisit when non-chromeos platforms are supported.
238 return false; 242 return false;
239 #endif 243 #endif
240 } 244 }
241 245
242 void EasyUnlockService::SetHardlockState( 246 void EasyUnlockService::SetHardlockState(
243 EasyUnlockScreenlockStateHandler::HardlockState state) { 247 EasyUnlockScreenlockStateHandler::HardlockState state) {
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 416
413 ExtensionService* extension_service = 417 ExtensionService* extension_service =
414 extensions::ExtensionSystem::Get(profile_)->extension_service(); 418 extensions::ExtensionSystem::Get(profile_)->extension_service();
415 extension_service->EnableExtension(extension_misc::kEasyUnlockAppId); 419 extension_service->EnableExtension(extension_misc::kEasyUnlockAppId);
416 420
417 NotifyUserUpdated(); 421 NotifyUserUpdated();
418 } 422 }
419 #endif // defined(GOOGLE_CHROME_BUILD) 423 #endif // defined(GOOGLE_CHROME_BUILD)
420 } 424 }
421 425
422 void EasyUnlockService::DisableAppIfLoaded() { 426 void EasyUnlockService::DisableAppIfLoaded(bool reset_screenlock_state) {
423 // Make sure lock screen state set by the extension gets reset. 427 if (reset_screenlock_state)
424 ResetScreenlockState(); 428 ResetScreenlockState();
425 429
426 extensions::ComponentLoader* loader = GetComponentLoader(profile_); 430 extensions::ComponentLoader* loader = GetComponentLoader(profile_);
427 if (!loader->Exists(extension_misc::kEasyUnlockAppId)) 431 if (!loader->Exists(extension_misc::kEasyUnlockAppId))
428 return; 432 return;
429 433
430 ExtensionService* extension_service = 434 ExtensionService* extension_service =
431 extensions::ExtensionSystem::Get(profile_)->extension_service(); 435 extensions::ExtensionSystem::Get(profile_)->extension_service();
432 extension_service->DisableExtension(extension_misc::kEasyUnlockAppId, 436 extension_service->DisableExtension(extension_misc::kEasyUnlockAppId,
433 extensions::Extension::DISABLE_RELOAD); 437 extensions::Extension::DISABLE_RELOAD);
434 } 438 }
(...skipping 10 matching lines...) Expand all
445 return; 449 return;
446 extensions::ExtensionSystem* extension_system = 450 extensions::ExtensionSystem* extension_system =
447 extensions::ExtensionSystem::Get(profile_); 451 extensions::ExtensionSystem::Get(profile_);
448 extension_system->extension_service()->ReloadExtension( 452 extension_system->extension_service()->ReloadExtension(
449 extension_misc::kEasyUnlockAppId); 453 extension_misc::kEasyUnlockAppId);
450 NotifyUserUpdated(); 454 NotifyUserUpdated();
451 } 455 }
452 456
453 void EasyUnlockService::UpdateAppState() { 457 void EasyUnlockService::UpdateAppState() {
454 if (IsAllowed()) { 458 if (IsAllowed()) {
459 // Bluetooth detector is used to make sure Easy Unlock is not enabled on
460 // devices that do not support Bluetooth. If Easy Unlock is allowed, that
461 // means that the bluetooth is supported on the device, so bluetooth
462 // detector is not needed any more (and might actually prolong time needed
463 // for the app to get reloaded after suspend).
464 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
465
455 LoadApp(); 466 LoadApp();
456 467
457 #if defined(OS_CHROMEOS) 468 #if defined(OS_CHROMEOS)
458 if (!power_monitor_) 469 if (!power_monitor_)
459 power_monitor_.reset(new PowerMonitor(this)); 470 power_monitor_.reset(new PowerMonitor(this));
460 #endif 471 #endif
461 } else { 472 } else {
462 DisableAppIfLoaded(); 473 DisableAppIfLoaded(true /* reset screenlock state */);
463 #if defined(OS_CHROMEOS) 474 #if defined(OS_CHROMEOS)
464 power_monitor_.reset(); 475 power_monitor_.reset();
465 #endif 476 #endif
466 } 477 }
467 } 478 }
468 479
469 void EasyUnlockService::NotifyUserUpdated() { 480 void EasyUnlockService::NotifyUserUpdated() {
470 std::string user_id = GetUserEmail(); 481 std::string user_id = GetUserEmail();
471 if (user_id.empty()) 482 if (user_id.empty())
472 return; 483 return;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 for (const auto& device_key_data : key_data_list) 569 for (const auto& device_key_data : key_data_list)
559 devices_in_cryptohome.insert(device_key_data.public_key); 570 devices_in_cryptohome.insert(device_key_data.public_key);
560 571
561 if (paired_devices != devices_in_cryptohome) { 572 if (paired_devices != devices_in_cryptohome) {
562 SetHardlockStateForUser(user_id, 573 SetHardlockStateForUser(user_id,
563 EasyUnlockScreenlockStateHandler::PAIRING_CHANGED); 574 EasyUnlockScreenlockStateHandler::PAIRING_CHANGED);
564 } 575 }
565 } 576 }
566 #endif 577 #endif
567 578
OLDNEW
« no previous file with comments | « chrome/browser/signin/easy_unlock_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698