| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/proximity_auth/proximity_monitor_impl.h" | 5 #include "components/proximity_auth/proximity_monitor_impl.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 ProximityMonitorImpl::ProximityMonitorImpl( | 35 ProximityMonitorImpl::ProximityMonitorImpl( |
| 36 const cryptauth::RemoteDevice& remote_device, | 36 const cryptauth::RemoteDevice& remote_device, |
| 37 std::unique_ptr<base::TickClock> clock) | 37 std::unique_ptr<base::TickClock> clock) |
| 38 : remote_device_(remote_device), | 38 : remote_device_(remote_device), |
| 39 strategy_(Strategy::NONE), | 39 strategy_(Strategy::NONE), |
| 40 remote_device_is_in_proximity_(false), | 40 remote_device_is_in_proximity_(false), |
| 41 is_active_(false), | 41 is_active_(false), |
| 42 clock_(std::move(clock)), | 42 clock_(std::move(clock)), |
| 43 polling_weak_ptr_factory_(this), | 43 polling_weak_ptr_factory_(this), |
| 44 weak_ptr_factory_(this) { | 44 weak_ptr_factory_(this) { |
| 45 if (device::BluetoothAdapterFactory::IsBluetoothAdapterAvailable()) { | 45 if (device::BluetoothAdapterFactory::IsBluetoothSupported()) { |
| 46 device::BluetoothAdapterFactory::GetAdapter( | 46 device::BluetoothAdapterFactory::GetAdapter( |
| 47 base::Bind(&ProximityMonitorImpl::OnAdapterInitialized, | 47 base::Bind(&ProximityMonitorImpl::OnAdapterInitialized, |
| 48 weak_ptr_factory_.GetWeakPtr())); | 48 weak_ptr_factory_.GetWeakPtr())); |
| 49 } else { | 49 } else { |
| 50 PA_LOG(ERROR) << "[Proximity] Proximity monitoring unavailable: " | 50 PA_LOG(ERROR) << "[Proximity] Proximity monitoring unavailable: " |
| 51 << "Bluetooth is unsupported on this platform."; | 51 << "Bluetooth is unsupported on this platform."; |
| 52 } | 52 } |
| 53 | 53 |
| 54 // TODO(isherman): Test prefs to set the strategy. Need to read from "Local | 54 // TODO(isherman): Test prefs to set the strategy. Need to read from "Local |
| 55 // State" prefs on the sign-in screen, and per-user prefs on the lock screen. | 55 // State" prefs on the sign-in screen, and per-user prefs on the lock screen. |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 if (remote_device_is_in_proximity_ != is_now_in_proximity) { | 272 if (remote_device_is_in_proximity_ != is_now_in_proximity) { |
| 273 PA_LOG(INFO) << "[Proximity] Updated proximity state: " | 273 PA_LOG(INFO) << "[Proximity] Updated proximity state: " |
| 274 << (is_now_in_proximity ? "proximate" : "distant"); | 274 << (is_now_in_proximity ? "proximate" : "distant"); |
| 275 remote_device_is_in_proximity_ = is_now_in_proximity; | 275 remote_device_is_in_proximity_ = is_now_in_proximity; |
| 276 for (auto& observer : observers_) | 276 for (auto& observer : observers_) |
| 277 observer.OnProximityStateChanged(); | 277 observer.OnProximityStateChanged(); |
| 278 } | 278 } |
| 279 } | 279 } |
| 280 | 280 |
| 281 } // namespace proximity_auth | 281 } // namespace proximity_auth |
| OLD | NEW |