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

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

Issue 1094273003: Implementing a BLE connection finder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
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 "apps/app_lifetime_monitor.h" 7 #include "apps/app_lifetime_monitor.h"
8 #include "apps/app_lifetime_monitor_factory.h" 8 #include "apps/app_lifetime_monitor_factory.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/guid.h" 11 #include "base/guid.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/metrics/histogram_macros.h" 13 #include "base/metrics/histogram_macros.h"
14 #include "base/prefs/pref_registry_simple.h" 14 #include "base/prefs/pref_registry_simple.h"
15 #include "base/prefs/pref_service.h" 15 #include "base/prefs/pref_service.h"
16 #include "base/prefs/scoped_user_pref_update.h" 16 #include "base/prefs/scoped_user_pref_update.h"
17 #include "base/thread_task_runner_handle.h" 17 #include "base/thread_task_runner_handle.h"
18 #include "base/time/time.h" 18 #include "base/time/time.h"
19 #include "base/values.h" 19 #include "base/values.h"
20 #include "chrome/browser/browser_process.h" 20 #include "chrome/browser/browser_process.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/signin/easy_unlock_app_manager.h" 22 #include "chrome/browser/signin/easy_unlock_app_manager.h"
23 #include "chrome/browser/signin/easy_unlock_service_factory.h" 23 #include "chrome/browser/signin/easy_unlock_service_factory.h"
24 #include "chrome/browser/signin/easy_unlock_service_observer.h" 24 #include "chrome/browser/signin/easy_unlock_service_observer.h"
25 #include "chrome/browser/signin/screenlock_bridge.h" 25 #include "chrome/browser/signin/screenlock_bridge.h"
26 #include "chrome/common/chrome_switches.h" 26 #include "chrome/common/chrome_switches.h"
27 #include "chrome/common/extensions/extension_constants.h" 27 #include "chrome/common/extensions/extension_constants.h"
28 #include "chrome/common/pref_names.h" 28 #include "chrome/common/pref_names.h"
29 #include "components/pref_registry/pref_registry_syncable.h" 29 #include "components/pref_registry/pref_registry_syncable.h"
30 #include "components/proximity_auth/ble/proximity_auth_ble_system.h"
30 #include "components/proximity_auth/switches.h" 31 #include "components/proximity_auth/switches.h"
31 #include "components/user_manager/user.h" 32 #include "components/user_manager/user.h"
32 #include "device/bluetooth/bluetooth_adapter.h" 33 #include "device/bluetooth/bluetooth_adapter.h"
33 #include "device/bluetooth/bluetooth_adapter_factory.h" 34 #include "device/bluetooth/bluetooth_adapter_factory.h"
34 35
35 #if defined(OS_CHROMEOS) 36 #if defined(OS_CHROMEOS)
36 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h" 37 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h"
37 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager. h" 38 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager. h"
38 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_ factory.h" 39 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_ factory.h"
39 #include "chrome/browser/chromeos/login/session/user_session_manager.h" 40 #include "chrome/browser/chromeos/login/session/user_session_manager.h"
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 app_manager_->ReloadApp(); 640 app_manager_->ReloadApp();
640 NotifyUserUpdated(); 641 NotifyUserUpdated();
641 } 642 }
642 643
643 void EasyUnlockService::UpdateAppState() { 644 void EasyUnlockService::UpdateAppState() {
644 if (IsAllowed()) { 645 if (IsAllowed()) {
645 EnsureTpmKeyPresentIfNeeded(); 646 EnsureTpmKeyPresentIfNeeded();
646 app_manager_->LoadApp(); 647 app_manager_->LoadApp();
647 NotifyUserUpdated(); 648 NotifyUserUpdated();
648 649
650 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
651 proximity_auth::switches::kEnableBluetoothLowEnergyDiscovery) &&
652 !proximity_auth_ble_system_) {
653 proximity_auth_ble_system_.reset(
654 new proximity_auth::ProximityAuthBleSystem());
655 }
656
649 #if defined(OS_CHROMEOS) 657 #if defined(OS_CHROMEOS)
650 if (!power_monitor_) 658 if (!power_monitor_)
651 power_monitor_.reset(new PowerMonitor(this)); 659 power_monitor_.reset(new PowerMonitor(this));
652 #endif 660 #endif
653 } else { 661 } else {
654 bool bluetooth_waking_up = false; 662 bool bluetooth_waking_up = false;
655 #if defined(OS_CHROMEOS) 663 #if defined(OS_CHROMEOS)
656 // If the service is not allowed due to bluetooth not being detected just 664 // If the service is not allowed due to bluetooth not being detected just
657 // after system suspend is done, give bluetooth more time to be detected 665 // after system suspend is done, give bluetooth more time to be detected
658 // before disabling the app (and resetting screenlock state). 666 // before disabling the app (and resetting screenlock state).
659 bluetooth_waking_up = 667 bluetooth_waking_up =
660 power_monitor_.get() && power_monitor_->waking_up() && 668 power_monitor_.get() && power_monitor_->waking_up() &&
661 !bluetooth_detector_->IsPresent(); 669 !bluetooth_detector_->IsPresent();
662 #endif 670 #endif
663 671
664 if (!bluetooth_waking_up) { 672 if (!bluetooth_waking_up) {
665 app_manager_->DisableAppIfLoaded(); 673 app_manager_->DisableAppIfLoaded();
666 ResetScreenlockState(); 674 ResetScreenlockState();
675 proximity_auth_ble_system_.reset();
667 #if defined(OS_CHROMEOS) 676 #if defined(OS_CHROMEOS)
668 power_monitor_.reset(); 677 power_monitor_.reset();
669 #endif 678 #endif
670 } 679 }
671 } 680 }
672 } 681 }
673 682
674 void EasyUnlockService::DisableAppWithoutResettingScreenlockState() { 683 void EasyUnlockService::DisableAppWithoutResettingScreenlockState() {
675 app_manager_->DisableAppIfLoaded(); 684 app_manager_->DisableAppIfLoaded();
676 } 685 }
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 866
858 // TODO(tbarzic): Set check_private_key only if previous sign-in attempt 867 // TODO(tbarzic): Set check_private_key only if previous sign-in attempt
859 // failed. 868 // failed.
860 EasyUnlockTpmKeyManagerFactory::GetInstance()->Get(profile_) 869 EasyUnlockTpmKeyManagerFactory::GetInstance()->Get(profile_)
861 ->PrepareTpmKey(true /* check_private_key */, 870 ->PrepareTpmKey(true /* check_private_key */,
862 base::Closure()); 871 base::Closure());
863 #endif // defined(OS_CHROMEOS) 872 #endif // defined(OS_CHROMEOS)
864 873
865 tpm_key_checked_ = true; 874 tpm_key_checked_ = true;
866 } 875 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698