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

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: remove log 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 !user_id_.empty() && 256 !user_id_.empty() &&
252 !chromeos::LoginState::Get()->IsUserLoggedIn(); 257 !chromeos::LoginState::Get()->IsUserLoggedIn();
253 } 258 }
254 259
255 void EasyUnlockServiceSignin::OnWillFinalizeUnlock(bool success) { 260 void EasyUnlockServiceSignin::OnWillFinalizeUnlock(bool success) {
256 // This code path should only be exercised for the lock screen, not for the 261 // This code path should only be exercised for the lock screen, not for the
257 // sign-in screen. 262 // sign-in screen.
258 NOTREACHED(); 263 NOTREACHED();
259 } 264 }
260 265
261 void EasyUnlockServiceSignin::OnSuspendDone() { 266 void EasyUnlockServiceSignin::OnSuspendDoneInternal() {
262 // Ignored. 267 // Ignored.
263 } 268 }
264 269
265 void EasyUnlockServiceSignin::OnScreenDidLock( 270 void EasyUnlockServiceSignin::OnScreenDidLock(
266 proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type) { 271 proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type) {
267 // In production code, the screen type should always be the signin screen; but 272 // In production code, the screen type should always be the signin screen; but
268 // in tests, the screen type might be different. 273 // in tests, the screen type might be different.
269 if (screen_type != 274 if (screen_type !=
270 proximity_auth::ScreenlockBridge::LockHandler::SIGNIN_SCREEN) 275 proximity_auth::ScreenlockBridge::LockHandler::SIGNIN_SCREEN)
271 return; 276 return;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 hardlock_state == EasyUnlockScreenlockStateHandler::NO_HARDLOCK) { 380 hardlock_state == EasyUnlockScreenlockStateHandler::NO_HARDLOCK) {
376 SetHardlockStateForUser(user_id, 381 SetHardlockStateForUser(user_id,
377 EasyUnlockScreenlockStateHandler::NO_PAIRING); 382 EasyUnlockScreenlockStateHandler::NO_PAIRING);
378 } 383 }
379 } 384 }
380 385
381 // If the fetched data belongs to the currently focused user, notify the app 386 // If the fetched data belongs to the currently focused user, notify the app
382 // that it has to refresh it's user data. 387 // that it has to refresh it's user data.
383 if (user_id == user_id_) 388 if (user_id == user_id_)
384 NotifyUserUpdated(); 389 NotifyUserUpdated();
390
391 if (user_id != user_id || devices.empty())
392 return;
393
394 // TODO(tengs): Currently, ProximityAuthSystem only supports one device. Once
395 // multiple devices are supported, we need to load all devices.
396 std::string decoded_public_key, decoded_psk, decoded_challenge;
397 proximity_auth::Base64UrlDecode(devices[0].public_key, &decoded_public_key);
398 proximity_auth::Base64UrlDecode(devices[0].psk, &decoded_psk);
399 proximity_auth::Base64UrlDecode(devices[0].challenge, &decoded_challenge);
400
401 // TODO(tengs): We need to store the Bluetooth type with the TPM data.
402 proximity_auth::RemoteDevice::BluetoothType bluetooth_type =
403 base::CommandLine::ForCurrentProcess()->HasSwitch(
404 proximity_auth::switches::kEnableBluetoothLowEnergyDiscovery)
405 ? proximity_auth::RemoteDevice::BLUETOOTH_LE
406 : proximity_auth::RemoteDevice::BLUETOOTH_CLASSIC;
407
408 proximity_auth::RemoteDevice remote_device(
409 user_id, std::string(), decoded_public_key, bluetooth_type,
410 devices[0].bluetooth_address, decoded_psk, decoded_challenge);
411 PA_LOG(INFO) << "Loaded Remote Device:\n"
412 << " user id: " << remote_device.user_id << "\n"
413 << " name: " << remote_device.name << "\n"
414 << " public key" << devices[0].public_key << "\n"
415 << " bt_addr:" << remote_device.bluetooth_address;
416 OnRemoteDeviceChanged(&remote_device);
385 } 417 }
386 418
387 const EasyUnlockServiceSignin::UserData* 419 const EasyUnlockServiceSignin::UserData*
388 EasyUnlockServiceSignin::FindLoadedDataForCurrentUser() const { 420 EasyUnlockServiceSignin::FindLoadedDataForCurrentUser() const {
389 if (user_id_.empty()) 421 if (user_id_.empty())
390 return NULL; 422 return NULL;
391 423
392 std::map<std::string, UserData*>::const_iterator it = 424 std::map<std::string, UserData*>::const_iterator it =
393 user_data_.find(user_id_); 425 user_data_.find(user_id_);
394 if (it == user_data_.end()) 426 if (it == user_data_.end())
395 return NULL; 427 return NULL;
396 if (it->second->state != USER_DATA_STATE_LOADED) 428 if (it->second->state != USER_DATA_STATE_LOADED)
397 return NULL; 429 return NULL;
398 return it->second; 430 return it->second;
399 } 431 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698