Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "chrome/browser/signin/easy_unlock_util.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" |
| 21 | 22 |
|
sdefresne
2015/04/24 14:22:02
#include "components/proximity_auth/screenlock_bri
msarda
2015/04/24 15:47:05
Not needed - already included by its header chrom
| |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 24 // The maximum allowed backoff interval when waiting for cryptohome to start. | 25 // The maximum allowed backoff interval when waiting for cryptohome to start. |
| 25 uint32 kMaxCryptohomeBackoffIntervalMs = 10000u; | 26 uint32 kMaxCryptohomeBackoffIntervalMs = 10000u; |
| 26 | 27 |
| 27 // If the data load fails, the initial interval after which the load will be | 28 // If the data load fails, the initial interval after which the load will be |
| 28 // retried. Further intervals will exponentially increas by factor 2. | 29 // retried. Further intervals will exponentially increas by factor 2. |
| 29 uint32 kInitialCryptohomeBackoffIntervalMs = 200u; | 30 uint32 kInitialCryptohomeBackoffIntervalMs = 200u; |
| 30 | 31 |
| 31 // Calculates the backoff interval that should be used next. | 32 // Calculates the backoff interval that should be used next. |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 NOTREACHED(); | 216 NOTREACHED(); |
| 216 } | 217 } |
| 217 | 218 |
| 218 void EasyUnlockServiceSignin::InitializeInternal() { | 219 void EasyUnlockServiceSignin::InitializeInternal() { |
| 219 if (chromeos::LoginState::Get()->IsUserLoggedIn()) | 220 if (chromeos::LoginState::Get()->IsUserLoggedIn()) |
| 220 return; | 221 return; |
| 221 | 222 |
| 222 service_active_ = true; | 223 service_active_ = true; |
| 223 | 224 |
| 224 chromeos::LoginState::Get()->AddObserver(this); | 225 chromeos::LoginState::Get()->AddObserver(this); |
| 225 ScreenlockBridge* screenlock_bridge = ScreenlockBridge::Get(); | 226 ScreenlockBridge* screenlock_bridge = GetScreenlockBridgeInstance(); |
| 226 screenlock_bridge->AddObserver(this); | 227 screenlock_bridge->AddObserver(this); |
| 227 if (!screenlock_bridge->focused_user_id().empty()) | 228 if (!screenlock_bridge->focused_user_id().empty()) |
| 228 OnFocusedUserChanged(screenlock_bridge->focused_user_id()); | 229 OnFocusedUserChanged(screenlock_bridge->focused_user_id()); |
| 229 } | 230 } |
| 230 | 231 |
| 231 void EasyUnlockServiceSignin::ShutdownInternal() { | 232 void EasyUnlockServiceSignin::ShutdownInternal() { |
| 232 if (!service_active_) | 233 if (!service_active_) |
| 233 return; | 234 return; |
| 234 service_active_ = false; | 235 service_active_ = false; |
| 235 | 236 |
| 236 weak_ptr_factory_.InvalidateWeakPtrs(); | 237 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 237 ScreenlockBridge::Get()->RemoveObserver(this); | 238 GetScreenlockBridgeInstance()->RemoveObserver(this); |
| 238 chromeos::LoginState::Get()->RemoveObserver(this); | 239 chromeos::LoginState::Get()->RemoveObserver(this); |
| 239 STLDeleteContainerPairSecondPointers(user_data_.begin(), user_data_.end()); | 240 STLDeleteContainerPairSecondPointers(user_data_.begin(), user_data_.end()); |
| 240 user_data_.clear(); | 241 user_data_.clear(); |
| 241 } | 242 } |
| 242 | 243 |
| 243 bool EasyUnlockServiceSignin::IsAllowedInternal() const { | 244 bool EasyUnlockServiceSignin::IsAllowedInternal() const { |
| 244 return service_active_ && | 245 return service_active_ && |
| 245 !user_id_.empty() && | 246 !user_id_.empty() && |
| 246 !chromeos::LoginState::Get()->IsUserLoggedIn(); | 247 !chromeos::LoginState::Get()->IsUserLoggedIn(); |
| 247 } | 248 } |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 382 return NULL; | 383 return NULL; |
| 383 | 384 |
| 384 std::map<std::string, UserData*>::const_iterator it = | 385 std::map<std::string, UserData*>::const_iterator it = |
| 385 user_data_.find(user_id_); | 386 user_data_.find(user_id_); |
| 386 if (it == user_data_.end()) | 387 if (it == user_data_.end()) |
| 387 return NULL; | 388 return NULL; |
| 388 if (it->second->state != USER_DATA_STATE_LOADED) | 389 if (it->second->state != USER_DATA_STATE_LOADED) |
| 389 return NULL; | 390 return NULL; |
| 390 return it->second; | 391 return it->second; |
| 391 } | 392 } |
| OLD | NEW |