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.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" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 proximity_auth::switches::kDisableEasyUnlock); | 83 proximity_auth::switches::kDisableEasyUnlock); |
84 } | 84 } |
85 | 85 |
86 class EasyUnlockService::BluetoothDetector | 86 class EasyUnlockService::BluetoothDetector |
87 : public device::BluetoothAdapter::Observer, | 87 : public device::BluetoothAdapter::Observer, |
88 public apps::AppLifetimeMonitor::Observer { | 88 public apps::AppLifetimeMonitor::Observer { |
89 public: | 89 public: |
90 explicit BluetoothDetector(EasyUnlockService* service) | 90 explicit BluetoothDetector(EasyUnlockService* service) |
91 : service_(service), | 91 : service_(service), |
92 weak_ptr_factory_(this) { | 92 weak_ptr_factory_(this) { |
| 93 apps::AppLifetimeMonitorFactory::GetForProfile(service_->profile()) |
| 94 ->AddObserver(this); |
93 } | 95 } |
94 | 96 |
95 ~BluetoothDetector() override { | 97 ~BluetoothDetector() override { |
96 if (adapter_.get()) | 98 if (adapter_.get()) |
97 adapter_->RemoveObserver(this); | 99 adapter_->RemoveObserver(this); |
| 100 apps::AppLifetimeMonitorFactory::GetForProfile(service_->profile()) |
| 101 ->RemoveObserver(this); |
98 } | 102 } |
99 | 103 |
100 void Initialize() { | 104 void Initialize() { |
101 if (!device::BluetoothAdapterFactory::IsBluetoothAdapterAvailable()) | 105 if (!device::BluetoothAdapterFactory::IsBluetoothAdapterAvailable()) |
102 return; | 106 return; |
103 | 107 |
104 device::BluetoothAdapterFactory::GetAdapter( | 108 device::BluetoothAdapterFactory::GetAdapter( |
105 base::Bind(&BluetoothDetector::OnAdapterInitialized, | 109 base::Bind(&BluetoothDetector::OnAdapterInitialized, |
106 weak_ptr_factory_.GetWeakPtr())); | 110 weak_ptr_factory_.GetWeakPtr())); |
107 } | 111 } |
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 | 799 |
796 // TODO(tbarzic): Set check_private_key only if previous sign-in attempt | 800 // TODO(tbarzic): Set check_private_key only if previous sign-in attempt |
797 // failed. | 801 // failed. |
798 EasyUnlockTpmKeyManagerFactory::GetInstance()->Get(profile_) | 802 EasyUnlockTpmKeyManagerFactory::GetInstance()->Get(profile_) |
799 ->PrepareTpmKey(true /* check_private_key */, | 803 ->PrepareTpmKey(true /* check_private_key */, |
800 base::Closure()); | 804 base::Closure()); |
801 #endif // defined(OS_CHROMEOS) | 805 #endif // defined(OS_CHROMEOS) |
802 | 806 |
803 tpm_key_checked_ = true; | 807 tpm_key_checked_ = true; |
804 } | 808 } |
OLD | NEW |