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

Unified Diff: components/proximity_auth/ble/proximity_auth_ble_system.cc

Issue 1102473003: Unlock Chrome when a phone with Smart Lock service is found. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_screen_lock
Patch Set: Nits Created 5 years, 8 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 | « components/proximity_auth/ble/proximity_auth_ble_system.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/proximity_auth/ble/proximity_auth_ble_system.cc
diff --git a/components/proximity_auth/ble/proximity_auth_ble_system.cc b/components/proximity_auth/ble/proximity_auth_ble_system.cc
index ecdb90d05ef6655348ee361d1934c2e2360326cb..bf4c2c743c4fbadf473877284815b68d3d1afc3b 100644
--- a/components/proximity_auth/ble/proximity_auth_ble_system.cc
+++ b/components/proximity_auth/ble/proximity_auth_ble_system.cc
@@ -6,31 +6,76 @@
#include "base/bind.h"
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
+#include "components/proximity_auth/ble/bluetooth_low_energy_connection_finder.h"
#include "components/proximity_auth/connection.h"
#include "device/bluetooth/bluetooth_device.h"
-
-#include "components/proximity_auth/ble/bluetooth_low_energy_connection_finder.h"
+#include "device/bluetooth/bluetooth_gatt_connection.h"
namespace proximity_auth {
+namespace {
+
+// The UUID of the Bluetooth Low Energy service.
const char kSmartLockServiceUUID[] = "b3b7e28e-a000-3e17-bd86-6e97b9e28c11";
-void ConnectionCallback(
- scoped_ptr<device::BluetoothGattConnection> connection) {
- VLOG(1) << "Connection established";
-}
+} // namespace
-ProximityAuthBleSystem::ProximityAuthBleSystem() {
+ProximityAuthBleSystem::ProximityAuthBleSystem(
+ ScreenlockBridge* screenlock_bridge,
+ content::BrowserContext* browser_context)
+ : screenlock_bridge_(screenlock_bridge),
+ browser_context_(browser_context),
+ weak_ptr_factory_(this) {
+ DCHECK(screenlock_bridge_);
+ DCHECK(browser_context_);
VLOG(1) << "Starting Proximity Auth over Bluetooth Low Energy.";
- connection_finder_ = scoped_ptr<BluetoothLowEnergyConnectionFinder>(
- new BluetoothLowEnergyConnectionFinder(kSmartLockServiceUUID));
- connection_finder_->Find(base::Bind(&ConnectionCallback));
+ screenlock_bridge_->AddObserver(this);
}
ProximityAuthBleSystem::~ProximityAuthBleSystem() {
VLOG(1) << "Stopping Proximity over Bluetooth Low Energy.";
+ screenlock_bridge_->RemoveObserver(this);
+}
+
+void ProximityAuthBleSystem::OnScreenDidLock(
+ ScreenlockBridge::LockHandler::ScreenType screen_type) {
+ VLOG(1) << "OnScreenDidLock: " << screen_type;
+ switch (screen_type) {
+ case ScreenlockBridge::LockHandler::SIGNIN_SCREEN:
+ connection_finder_.reset();
+ break;
+ case ScreenlockBridge::LockHandler::LOCK_SCREEN:
+ DCHECK(!connection_finder_);
+ connection_finder_.reset(
+ new BluetoothLowEnergyConnectionFinder(kSmartLockServiceUUID));
+ connection_finder_->Find(
+ base::Bind(&ProximityAuthBleSystem::OnConnectionFound,
+ weak_ptr_factory_.GetWeakPtr()));
+ break;
+ case ScreenlockBridge::LockHandler::OTHER_SCREEN:
+ connection_finder_.reset();
+ break;
+ }
+};
+
+void ProximityAuthBleSystem::OnScreenDidUnlock(
+ ScreenlockBridge::LockHandler::ScreenType screen_type) {
+ VLOG(1) << "OnScreenDidUnlock: " << screen_type;
connection_finder_.reset();
+};
+
+void ProximityAuthBleSystem::OnFocusedUserChanged(const std::string& user_id) {
+ VLOG(1) << "OnFocusedUserChanged: " << user_id;
+};
+
+void ProximityAuthBleSystem::OnConnectionFound(
+ scoped_ptr<device::BluetoothGattConnection> connection) {
+ // Unlock the screen when a connection is found.
+ //
+ // Note that this magically unlocks Chrome (no user interaction is needed).
+ // This user experience for this operation will be greately improved once
+ // the Proximity Auth Unlock Manager migration to C++ is done.
+ screenlock_bridge_->Unlock(browser_context_);
}
} // namespace proximity_auth
« no previous file with comments | « components/proximity_auth/ble/proximity_auth_ble_system.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698