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

Side by Side Diff: chrome/browser/signin/easy_unlock_service_signin_chromeos.cc

Issue 1372283002: Hook up ProximityAuthSystem in EasyUnlockService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth_connection
Patch Set: fix compile Created 5 years, 2 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 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_signin_chromeos.h" 5 #include "chrome/browser/signin/easy_unlock_service_signin_chromeos.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h"
9 #include "base/location.h" 10 #include "base/location.h"
10 #include "base/logging.h" 11 #include "base/logging.h"
11 #include "base/stl_util.h" 12 #include "base/stl_util.h"
12 #include "base/sys_info.h" 13 #include "base/sys_info.h"
13 #include "base/thread_task_runner_handle.h" 14 #include "base/thread_task_runner_handle.h"
14 #include "base/time/time.h" 15 #include "base/time/time.h"
15 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h" 16 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h"
16 #include "chrome/browser/chromeos/login/session/user_session_manager.h" 17 #include "chrome/browser/chromeos/login/session/user_session_manager.h"
17 #include "chrome/browser/signin/easy_unlock_app_manager.h" 18 #include "chrome/browser/signin/easy_unlock_app_manager.h"
18 #include "chrome/browser/signin/easy_unlock_metrics.h" 19 #include "chrome/browser/signin/easy_unlock_metrics.h"
19 #include "chromeos/login/auth/user_context.h" 20 #include "chromeos/login/auth/user_context.h"
20 #include "chromeos/tpm/tpm_token_loader.h" 21 #include "chromeos/tpm/tpm_token_loader.h"
22 #include "components/proximity_auth/cryptauth/base64url.h"
23 #include "components/proximity_auth/logging/logging.h"
24 #include "components/proximity_auth/remote_device.h"
25 #include "components/proximity_auth/switches.h"
21 26
22 namespace { 27 namespace {
23 28
24 // The maximum allowed backoff interval when waiting for cryptohome to start. 29 // The maximum allowed backoff interval when waiting for cryptohome to start.
25 uint32 kMaxCryptohomeBackoffIntervalMs = 10000u; 30 uint32 kMaxCryptohomeBackoffIntervalMs = 10000u;
26 31
27 // If the data load fails, the initial interval after which the load will be 32 // If the data load fails, the initial interval after which the load will be
28 // retried. Further intervals will exponentially increas by factor 2. 33 // retried. Further intervals will exponentially increas by factor 2.
29 uint32 kInitialCryptohomeBackoffIntervalMs = 200u; 34 uint32 kInitialCryptohomeBackoffIntervalMs = 200u;
30 35
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 !user_id_.empty() && 251 !user_id_.empty() &&
247 !chromeos::LoginState::Get()->IsUserLoggedIn(); 252 !chromeos::LoginState::Get()->IsUserLoggedIn();
248 } 253 }
249 254
250 void EasyUnlockServiceSignin::OnWillFinalizeUnlock(bool success) { 255 void EasyUnlockServiceSignin::OnWillFinalizeUnlock(bool success) {
251 // This code path should only be exercised for the lock screen, not for the 256 // This code path should only be exercised for the lock screen, not for the
252 // sign-in screen. 257 // sign-in screen.
253 NOTREACHED(); 258 NOTREACHED();
254 } 259 }
255 260
256 void EasyUnlockServiceSignin::OnSuspendDone() { 261 void EasyUnlockServiceSignin::OnSuspendDoneInternal() {
257 // Ignored. 262 // Ignored.
258 } 263 }
259 264
260 void EasyUnlockServiceSignin::OnScreenDidLock( 265 void EasyUnlockServiceSignin::OnScreenDidLock(
261 proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type) { 266 proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type) {
262 // In production code, the screen type should always be the signin screen; but 267 // In production code, the screen type should always be the signin screen; but
263 // in tests, the screen type might be different. 268 // in tests, the screen type might be different.
264 if (screen_type != 269 if (screen_type !=
265 proximity_auth::ScreenlockBridge::LockHandler::SIGNIN_SCREEN) 270 proximity_auth::ScreenlockBridge::LockHandler::SIGNIN_SCREEN)
266 return; 271 return;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 hardlock_state == EasyUnlockScreenlockStateHandler::NO_HARDLOCK) { 375 hardlock_state == EasyUnlockScreenlockStateHandler::NO_HARDLOCK) {
371 SetHardlockStateForUser(user_id, 376 SetHardlockStateForUser(user_id,
372 EasyUnlockScreenlockStateHandler::NO_PAIRING); 377 EasyUnlockScreenlockStateHandler::NO_PAIRING);
373 } 378 }
374 } 379 }
375 380
376 // If the fetched data belongs to the currently focused user, notify the app 381 // If the fetched data belongs to the currently focused user, notify the app
377 // that it has to refresh it's user data. 382 // that it has to refresh it's user data.
378 if (user_id == user_id_) 383 if (user_id == user_id_)
379 NotifyUserUpdated(); 384 NotifyUserUpdated();
385
386 if (user_id != user_id || devices.empty())
387 return;
388
389 // TODO(tengs): Currently, ProximityAuthSystem only supports one device. Once
390 // multiple devices are supported, we need to load all devices.
391 std::string decoded_public_key, decoded_psk, decoded_challenge;
392 proximity_auth::Base64UrlDecode(devices[0].public_key, &decoded_public_key);
393 proximity_auth::Base64UrlDecode(devices[0].psk, &decoded_psk);
394 proximity_auth::Base64UrlDecode(devices[0].challenge, &decoded_challenge);
395
396 // TODO(tengs): We need to store the Bluetooth type with the TPM data.
397 proximity_auth::RemoteDevice::BluetoothType bluetooth_type =
398 base::CommandLine::ForCurrentProcess()->HasSwitch(
399 proximity_auth::switches::kEnableBluetoothLowEnergyDiscovery)
400 ? proximity_auth::RemoteDevice::BLUETOOTH_LE
401 : proximity_auth::RemoteDevice::BLUETOOTH_CLASSIC;
402
403 proximity_auth::RemoteDevice remote_device(
404 user_id, std::string(), decoded_public_key, bluetooth_type,
405 devices[0].bluetooth_address, decoded_psk, decoded_challenge);
406 PA_LOG(INFO) << "Loaded Remote Device:\n"
407 << " user id: " << remote_device.user_id << "\n"
408 << " name: " << remote_device.name << "\n"
409 << " public key" << devices[0].public_key << "\n"
410 << " bt_addr:" << remote_device.bluetooth_address;
411 OnRemoteDeviceChanged(&remote_device);
380 } 412 }
381 413
382 const EasyUnlockServiceSignin::UserData* 414 const EasyUnlockServiceSignin::UserData*
383 EasyUnlockServiceSignin::FindLoadedDataForCurrentUser() const { 415 EasyUnlockServiceSignin::FindLoadedDataForCurrentUser() const {
384 if (user_id_.empty()) 416 if (user_id_.empty())
385 return NULL; 417 return NULL;
386 418
387 std::map<std::string, UserData*>::const_iterator it = 419 std::map<std::string, UserData*>::const_iterator it =
388 user_data_.find(user_id_); 420 user_data_.find(user_id_);
389 if (it == user_data_.end()) 421 if (it == user_data_.end())
390 return NULL; 422 return NULL;
391 if (it->second->state != USER_DATA_STATE_LOADED) 423 if (it->second->state != USER_DATA_STATE_LOADED)
392 return NULL; 424 return NULL;
393 return it->second; 425 return it->second;
394 } 426 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698