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

Unified Diff: chrome/browser/signin/easy_unlock_service.cc

Issue 979353002: Disable Bluetooth discoverability when Easy Unlock app closes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: safeguard in case of crash during setup Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/signin/easy_unlock_service.cc
diff --git a/chrome/browser/signin/easy_unlock_service.cc b/chrome/browser/signin/easy_unlock_service.cc
index a70603804decb19104df90895c716cd811bb2642..e974e90cbe89852cd55abf00c4a878d58bc0e882 100644
--- a/chrome/browser/signin/easy_unlock_service.cc
+++ b/chrome/browser/signin/easy_unlock_service.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/signin/easy_unlock_service.h"
+#include "apps/app_lifetime_monitor.h"
+#include "apps/app_lifetime_monitor_factory.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/guid.h"
@@ -23,6 +25,7 @@
#include "chrome/browser/signin/easy_unlock_service_observer.h"
#include "chrome/browser/signin/screenlock_bridge.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/pref_names.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/proximity_auth/switches.h"
@@ -81,7 +84,8 @@ bool EasyUnlockService::IsSignInEnabled() {
}
class EasyUnlockService::BluetoothDetector
- : public device::BluetoothAdapter::Observer {
+ : public device::BluetoothAdapter::Observer,
+ public apps::AppLifetimeMonitor::Observer {
public:
explicit BluetoothDetector(EasyUnlockService* service)
: service_(service),
@@ -115,6 +119,32 @@ class EasyUnlockService::BluetoothDetector
adapter_ = adapter;
adapter_->AddObserver(this);
service_->OnBluetoothAdapterPresentChanged();
+
+ // TODO(tengs): At the moment, there is no way for Bluetooth discoverability
+ // to be turned on except through the Easy Unlock setup. If we step on any
+ // toes in the future then we need to revisit this guard.
+ if (adapter_->IsDiscoverable())
+ TurnOffBluetoothDiscoverability();
+ }
+
+ // apps::AppLifetimeMonitor::Observer:
+ void OnAppDeactivated(Profile* profile, const std::string& app_id) override {
+ // TODO(tengs): Refactor the lifetime management to EasyUnlockAppManager.
+ if (app_id == extension_misc::kEasyUnlockAppId)
+ TurnOffBluetoothDiscoverability();
+ }
+
+ void OnAppStop(Profile* profile, const std::string& app_id) override {
+ // TODO(tengs): Refactor the lifetime management to EasyUnlockAppManager.
+ if (app_id == extension_misc::kEasyUnlockAppId)
+ TurnOffBluetoothDiscoverability();
+ }
+
+ void TurnOffBluetoothDiscoverability() {
+ if (adapter_) {
+ adapter_->SetDiscoverable(
+ false, base::Bind(&base::DoNothing), base::Bind(&base::DoNothing));
+ }
}
// Owner of this class and should out-live this class.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698