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 "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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 } | 97 } |
98 | 98 |
99 class EasyUnlockService::BluetoothDetector | 99 class EasyUnlockService::BluetoothDetector |
100 : public device::BluetoothAdapter::Observer { | 100 : public device::BluetoothAdapter::Observer { |
101 public: | 101 public: |
102 explicit BluetoothDetector(EasyUnlockService* service) | 102 explicit BluetoothDetector(EasyUnlockService* service) |
103 : service_(service), | 103 : service_(service), |
104 weak_ptr_factory_(this) { | 104 weak_ptr_factory_(this) { |
105 } | 105 } |
106 | 106 |
107 virtual ~BluetoothDetector() { | 107 ~BluetoothDetector() override { |
108 if (adapter_.get()) | 108 if (adapter_.get()) |
109 adapter_->RemoveObserver(this); | 109 adapter_->RemoveObserver(this); |
110 } | 110 } |
111 | 111 |
112 void Initialize() { | 112 void Initialize() { |
113 if (!device::BluetoothAdapterFactory::IsBluetoothAdapterAvailable()) | 113 if (!device::BluetoothAdapterFactory::IsBluetoothAdapterAvailable()) |
114 return; | 114 return; |
115 | 115 |
116 device::BluetoothAdapterFactory::GetAdapter( | 116 device::BluetoothAdapterFactory::GetAdapter( |
117 base::Bind(&BluetoothDetector::OnAdapterInitialized, | 117 base::Bind(&BluetoothDetector::OnAdapterInitialized, |
118 weak_ptr_factory_.GetWeakPtr())); | 118 weak_ptr_factory_.GetWeakPtr())); |
119 } | 119 } |
120 | 120 |
121 bool IsPresent() const { return adapter_.get() && adapter_->IsPresent(); } | 121 bool IsPresent() const { return adapter_.get() && adapter_->IsPresent(); } |
122 | 122 |
123 // device::BluetoothAdapter::Observer: | 123 // device::BluetoothAdapter::Observer: |
124 virtual void AdapterPresentChanged(device::BluetoothAdapter* adapter, | 124 void AdapterPresentChanged(device::BluetoothAdapter* adapter, |
125 bool present) override { | 125 bool present) override { |
126 service_->OnBluetoothAdapterPresentChanged(); | 126 service_->OnBluetoothAdapterPresentChanged(); |
127 } | 127 } |
128 | 128 |
129 private: | 129 private: |
130 void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter) { | 130 void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter) { |
131 adapter_ = adapter; | 131 adapter_ = adapter; |
132 adapter_->AddObserver(this); | 132 adapter_->AddObserver(this); |
133 service_->OnBluetoothAdapterPresentChanged(); | 133 service_->OnBluetoothAdapterPresentChanged(); |
134 } | 134 } |
135 | 135 |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 #endif | 601 #endif |
602 | 602 |
603 void EasyUnlockService::PrepareForSuspend() { | 603 void EasyUnlockService::PrepareForSuspend() { |
604 DisableAppIfLoaded(); | 604 DisableAppIfLoaded(); |
605 if (screenlock_state_handler_ && screenlock_state_handler_->IsActive()) { | 605 if (screenlock_state_handler_ && screenlock_state_handler_->IsActive()) { |
606 UpdateScreenlockState( | 606 UpdateScreenlockState( |
607 EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING); | 607 EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING); |
608 } | 608 } |
609 } | 609 } |
610 | 610 |
OLD | NEW |