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

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

Powered by Google App Engine
This is Rietveld 408576698