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/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 63 |
64 class EasyUnlockService::BluetoothDetector | 64 class EasyUnlockService::BluetoothDetector |
65 : public device::BluetoothAdapter::Observer { | 65 : public device::BluetoothAdapter::Observer { |
66 public: | 66 public: |
67 explicit BluetoothDetector(EasyUnlockService* service) | 67 explicit BluetoothDetector(EasyUnlockService* service) |
68 : service_(service), | 68 : service_(service), |
69 weak_ptr_factory_(this) { | 69 weak_ptr_factory_(this) { |
70 } | 70 } |
71 | 71 |
72 virtual ~BluetoothDetector() { | 72 virtual ~BluetoothDetector() { |
73 if (adapter_) | 73 if (adapter_.get()) |
74 adapter_->RemoveObserver(this); | 74 adapter_->RemoveObserver(this); |
75 } | 75 } |
76 | 76 |
77 void Initialize() { | 77 void Initialize() { |
78 if (!device::BluetoothAdapterFactory::IsBluetoothAdapterAvailable()) | 78 if (!device::BluetoothAdapterFactory::IsBluetoothAdapterAvailable()) |
79 return; | 79 return; |
80 | 80 |
81 device::BluetoothAdapterFactory::GetAdapter( | 81 device::BluetoothAdapterFactory::GetAdapter( |
82 base::Bind(&BluetoothDetector::OnAdapterInitialized, | 82 base::Bind(&BluetoothDetector::OnAdapterInitialized, |
83 weak_ptr_factory_.GetWeakPtr())); | 83 weak_ptr_factory_.GetWeakPtr())); |
84 } | 84 } |
85 | 85 |
86 bool IsPresent() const { | 86 bool IsPresent() const { return adapter_.get() && adapter_->IsPresent(); } |
87 return adapter_ && adapter_->IsPresent(); | |
88 } | |
89 | 87 |
90 // device::BluetoothAdapter::Observer: | 88 // device::BluetoothAdapter::Observer: |
91 virtual void AdapterPresentChanged(device::BluetoothAdapter* adapter, | 89 virtual void AdapterPresentChanged(device::BluetoothAdapter* adapter, |
92 bool present) OVERRIDE { | 90 bool present) OVERRIDE { |
93 service_->OnBluetoothAdapterPresentChanged(); | 91 service_->OnBluetoothAdapterPresentChanged(); |
94 } | 92 } |
95 | 93 |
96 private: | 94 private: |
97 void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter) { | 95 void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter) { |
98 adapter_ = adapter; | 96 adapter_ = adapter; |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 // Make sure lock screen state set by the extension gets reset. | 370 // Make sure lock screen state set by the extension gets reset. |
373 screenlock_state_handler_.reset(); | 371 screenlock_state_handler_.reset(); |
374 | 372 |
375 if (GetComponentLoader(profile_)->Exists(extension_misc::kEasyUnlockAppId)) { | 373 if (GetComponentLoader(profile_)->Exists(extension_misc::kEasyUnlockAppId)) { |
376 extensions::ExtensionSystem* extension_system = | 374 extensions::ExtensionSystem* extension_system = |
377 extensions::ExtensionSystem::Get(profile_); | 375 extensions::ExtensionSystem::Get(profile_); |
378 extension_system->extension_service()->ReloadExtension( | 376 extension_system->extension_service()->ReloadExtension( |
379 extension_misc::kEasyUnlockAppId); | 377 extension_misc::kEasyUnlockAppId); |
380 } | 378 } |
381 } | 379 } |
OLD | NEW |