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/chromeos/login/session/user_session_manager.h" | 5 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1292 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 1292 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
1293 user_sessions_restored_ = true; | 1293 user_sessions_restored_ = true; |
1294 user_sessions_restore_in_progress_ = false; | 1294 user_sessions_restore_in_progress_ = false; |
1295 FOR_EACH_OBSERVER(chromeos::UserSessionStateObserver, | 1295 FOR_EACH_OBSERVER(chromeos::UserSessionStateObserver, |
1296 session_state_observer_list_, | 1296 session_state_observer_list_, |
1297 PendingUserSessionsRestoreFinished()); | 1297 PendingUserSessionsRestoreFinished()); |
1298 } | 1298 } |
1299 | 1299 |
1300 void UserSessionManager::UpdateEasyUnlockKeys(const UserContext& user_context) { | 1300 void UserSessionManager::UpdateEasyUnlockKeys(const UserContext& user_context) { |
1301 // Skip key update because FakeCryptohomeClient always return success | 1301 // Skip key update because FakeCryptohomeClient always return success |
1302 // and RemoveKey op expects a failure to stop. As a result, some tests would | 1302 // and RefreshKeys op expects a failure to stop. As a result, some tests would |
1303 // timeout. | 1303 // timeout. |
1304 // TODO(xiyuan): Revisit this when adding tests. | 1304 // TODO(xiyuan): Revisit this when adding tests. |
1305 if (!base::SysInfo::IsRunningOnChromeOS()) | 1305 if (!base::SysInfo::IsRunningOnChromeOS()) |
1306 return; | 1306 return; |
1307 | 1307 |
1308 // Only update Easy unlock keys for regular user. | 1308 // Only update Easy unlock keys for regular user. |
1309 // TODO(xiyuan): Fix inconsistency user type of |user_context| introduced in | 1309 // TODO(xiyuan): Fix inconsistency user type of |user_context| introduced in |
1310 // authenticator. | 1310 // authenticator. |
1311 const user_manager::User* user = | 1311 const user_manager::User* user = |
1312 user_manager::UserManager::Get()->FindUser(user_context.GetUserID()); | 1312 user_manager::UserManager::Get()->FindUser(user_context.GetUserID()); |
1313 if (!user || !user->HasGaiaAccount()) | 1313 if (!user || !user->HasGaiaAccount()) |
1314 return; | 1314 return; |
1315 | 1315 |
1316 // Bail if |user_context| does not have secret. | 1316 // Bail if |user_context| does not have secret. |
1317 if (user_context.GetKey()->GetSecret().empty()) | 1317 if (user_context.GetKey()->GetSecret().empty()) |
1318 return; | 1318 return; |
1319 | 1319 |
1320 const base::ListValue* device_list = NULL; | 1320 const base::ListValue* device_list = NULL; |
1321 EasyUnlockService* easy_unlock_service = EasyUnlockService::GetForUser(*user); | 1321 EasyUnlockService* easy_unlock_service = EasyUnlockService::GetForUser(*user); |
1322 if (easy_unlock_service) { | 1322 if (easy_unlock_service) { |
1323 device_list = easy_unlock_service->GetRemoteDevices(); | 1323 device_list = easy_unlock_service->GetRemoteDevices(); |
1324 easy_unlock_service->SetHardlockState( | 1324 easy_unlock_service->SetHardlockState( |
1325 EasyUnlockScreenlockStateHandler::NO_HARDLOCK); | 1325 EasyUnlockScreenlockStateHandler::NO_HARDLOCK); |
1326 } | 1326 } |
1327 | 1327 |
| 1328 base::ListValue empty_list; |
| 1329 if (!device_list) |
| 1330 device_list = &empty_list; |
| 1331 |
1328 EasyUnlockKeyManager* key_manager = GetEasyUnlockKeyManager(); | 1332 EasyUnlockKeyManager* key_manager = GetEasyUnlockKeyManager(); |
1329 running_easy_unlock_key_ops_ = true; | 1333 running_easy_unlock_key_ops_ = true; |
1330 if (device_list) { | 1334 key_manager->RefreshKeys( |
1331 key_manager->RefreshKeys( | 1335 user_context, *device_list, |
1332 user_context, | 1336 base::Bind(&UserSessionManager::OnEasyUnlockKeyOpsFinished, AsWeakPtr(), |
1333 *device_list, | 1337 user_context.GetUserID())); |
1334 base::Bind(&UserSessionManager::OnEasyUnlockKeyOpsFinished, | |
1335 AsWeakPtr(), | |
1336 user_context.GetUserID())); | |
1337 } else { | |
1338 key_manager->RemoveKeys( | |
1339 user_context, | |
1340 0, | |
1341 base::Bind(&UserSessionManager::OnEasyUnlockKeyOpsFinished, | |
1342 AsWeakPtr(), | |
1343 user_context.GetUserID())); | |
1344 } | |
1345 } | 1338 } |
1346 | 1339 |
1347 void UserSessionManager::AttemptRestart(Profile* profile) { | 1340 void UserSessionManager::AttemptRestart(Profile* profile) { |
1348 if (CheckEasyUnlockKeyOps(base::Bind(&UserSessionManager::AttemptRestart, | 1341 if (CheckEasyUnlockKeyOps(base::Bind(&UserSessionManager::AttemptRestart, |
1349 AsWeakPtr(), profile))) { | 1342 AsWeakPtr(), profile))) { |
1350 return; | 1343 return; |
1351 } | 1344 } |
1352 | 1345 |
1353 if (session_restore_strategy_ != | 1346 if (session_restore_strategy_ != |
1354 OAuth2LoginManager::RESTORE_FROM_COOKIE_JAR) { | 1347 OAuth2LoginManager::RESTORE_FROM_COOKIE_JAR) { |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1499 InputEventsBlocker* /* input_events_blocker */, | 1492 InputEventsBlocker* /* input_events_blocker */, |
1500 const locale_util::LanguageSwitchResult& /* result */) { | 1493 const locale_util::LanguageSwitchResult& /* result */) { |
1501 callback.Run(); | 1494 callback.Run(); |
1502 } | 1495 } |
1503 | 1496 |
1504 void UserSessionManager::RemoveProfileForTesting(Profile* profile) { | 1497 void UserSessionManager::RemoveProfileForTesting(Profile* profile) { |
1505 default_ime_states_.erase(profile); | 1498 default_ime_states_.erase(profile); |
1506 } | 1499 } |
1507 | 1500 |
1508 } // namespace chromeos | 1501 } // namespace chromeos |
OLD | NEW |