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

Side by Side Diff: components/proximity_auth/ble/proximity_auth_ble_system.cc

Issue 1209193003: [Proximity Auth] Create one ProximityAuthClient per profile, rather than one global one. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 unified diff | Download patch
OLDNEW
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/ble/proximity_auth_ble_system.h" 5 #include "components/proximity_auth/ble/proximity_auth_ble_system.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 ScreenlockBridge::Observer* observer) { 61 ScreenlockBridge::Observer* observer) {
62 screenlock_bridge_->AddObserver(observer); 62 screenlock_bridge_->AddObserver(observer);
63 } 63 }
64 64
65 void ProximityAuthBleSystem::ScreenlockBridgeAdapter::RemoveObserver( 65 void ProximityAuthBleSystem::ScreenlockBridgeAdapter::RemoveObserver(
66 ScreenlockBridge::Observer* observer) { 66 ScreenlockBridge::Observer* observer) {
67 screenlock_bridge_->RemoveObserver(observer); 67 screenlock_bridge_->RemoveObserver(observer);
68 } 68 }
69 69
70 void ProximityAuthBleSystem::ScreenlockBridgeAdapter::Unlock( 70 void ProximityAuthBleSystem::ScreenlockBridgeAdapter::Unlock(
71 content::BrowserContext* browser_context) { 71 ProximityAuthClient* client) {
72 screenlock_bridge_->Unlock(browser_context); 72 screenlock_bridge_->Unlock(client);
73 } 73 }
74 74
75 ProximityAuthBleSystem::ProximityAuthBleSystem( 75 ProximityAuthBleSystem::ProximityAuthBleSystem(
76 ScreenlockBridge* screenlock_bridge, 76 ScreenlockBridge* screenlock_bridge,
77 content::BrowserContext* browser_context, 77 ProximityAuthClient* proximity_auth_client,
78 scoped_ptr<CryptAuthClientFactory> cryptauth_client_factory) 78 scoped_ptr<CryptAuthClientFactory> cryptauth_client_factory)
79 : screenlock_bridge_(new ProximityAuthBleSystem::ScreenlockBridgeAdapter( 79 : screenlock_bridge_(new ProximityAuthBleSystem::ScreenlockBridgeAdapter(
80 screenlock_bridge)), 80 screenlock_bridge)),
81 browser_context_(browser_context), 81 proximity_auth_client_(proximity_auth_client),
82 cryptauth_client_factory_(cryptauth_client_factory.Pass()), 82 cryptauth_client_factory_(cryptauth_client_factory.Pass()),
83 is_polling_screen_state_(false), 83 is_polling_screen_state_(false),
84 weak_ptr_factory_(this) { 84 weak_ptr_factory_(this) {
85 VLOG(1) << "Starting Proximity Auth over Bluetooth Low Energy."; 85 VLOG(1) << "Starting Proximity Auth over Bluetooth Low Energy.";
86 screenlock_bridge_->AddObserver(this); 86 screenlock_bridge_->AddObserver(this);
87 } 87 }
88 88
89 ProximityAuthBleSystem::ProximityAuthBleSystem( 89 ProximityAuthBleSystem::ProximityAuthBleSystem(
90 ScreenlockBridgeAdapter* screenlock_bridge, 90 scoped_ptr<ScreenlockBridgeAdapter> screenlock_bridge,
91 content::BrowserContext* browser_context) 91 ProximityAuthClient* proximity_auth_client)
92 : screenlock_bridge_(screenlock_bridge), 92 : screenlock_bridge_(screenlock_bridge.Pass()),
93 browser_context_(browser_context), 93 proximity_auth_client_(proximity_auth_client),
94 is_polling_screen_state_(false), 94 is_polling_screen_state_(false),
95 weak_ptr_factory_(this) { 95 weak_ptr_factory_(this) {
96 VLOG(1) << "Starting Proximity Auth over Bluetooth Low Energy."; 96 VLOG(1) << "Starting Proximity Auth over Bluetooth Low Energy.";
97 screenlock_bridge_->AddObserver(this); 97 screenlock_bridge_->AddObserver(this);
98 } 98 }
99 99
100 ProximityAuthBleSystem::~ProximityAuthBleSystem() { 100 ProximityAuthBleSystem::~ProximityAuthBleSystem() {
101 VLOG(1) << "Stopping Proximity over Bluetooth Low Energy."; 101 VLOG(1) << "Stopping Proximity over Bluetooth Low Energy.";
102 screenlock_bridge_->RemoveObserver(this); 102 screenlock_bridge_->RemoveObserver(this);
103 if (connection_) 103 if (connection_)
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 const WireMessage& message) { 199 const WireMessage& message) {
200 VLOG(1) << "Message received: " << message.payload(); 200 VLOG(1) << "Message received: " << message.payload();
201 201
202 // Unlock the screen when the remote device sends an unlock signal. 202 // Unlock the screen when the remote device sends an unlock signal.
203 // 203 //
204 // Note that this magically unlocks Chrome (no user interaction is needed). 204 // Note that this magically unlocks Chrome (no user interaction is needed).
205 // This user experience for this operation will be greately improved once 205 // This user experience for this operation will be greately improved once
206 // the Proximity Auth Unlock Manager migration to C++ is done. 206 // the Proximity Auth Unlock Manager migration to C++ is done.
207 if (message.payload() == kScreenUnlocked) { 207 if (message.payload() == kScreenUnlocked) {
208 VLOG(1) << "Device unlocked. Unlock."; 208 VLOG(1) << "Device unlocked. Unlock.";
209 screenlock_bridge_->Unlock(browser_context_); 209 screenlock_bridge_->Unlock(proximity_auth_client_);
210 } 210 }
211 } 211 }
212 212
213 void ProximityAuthBleSystem::OnConnectionFound( 213 void ProximityAuthBleSystem::OnConnectionFound(
214 scoped_ptr<Connection> connection) { 214 scoped_ptr<Connection> connection) {
215 VLOG(1) << "Connection found."; 215 VLOG(1) << "Connection found.";
216 216
217 connection_ = connection.Pass(); 217 connection_ = connection.Pass();
218 if (connection_) { 218 if (connection_) {
219 connection_->AddObserver(this); 219 connection_->AddObserver(this);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 weak_ptr_factory_.GetWeakPtr()), 261 weak_ptr_factory_.GetWeakPtr()),
262 base::TimeDelta::FromSeconds(kPollingIntervalSeconds)); 262 base::TimeDelta::FromSeconds(kPollingIntervalSeconds));
263 } 263 }
264 } 264 }
265 265
266 void ProximityAuthBleSystem::StopPollingScreenState() { 266 void ProximityAuthBleSystem::StopPollingScreenState() {
267 is_polling_screen_state_ = false; 267 is_polling_screen_state_ = false;
268 } 268 }
269 269
270 } // namespace proximity_auth 270 } // namespace proximity_auth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698