Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "chromeos/login/scoped_test_public_session_login_state.h" | 5 #include "chromeos/login/scoped_test_public_session_login_state.h" |
| 6 | 6 |
| 7 #include "chromeos/login/login_state.h" | 7 #include "chromeos/login/login_state.h" |
| 8 | 8 |
| 9 namespace chromeos { | 9 namespace chromeos { |
| 10 | 10 |
| 11 ScopedTestPublicSessionLoginState::ScopedTestPublicSessionLoginState() { | 11 ScopedTestPublicSessionLoginState::ScopedTestPublicSessionLoginState() { |
| 12 // Set Public Session state. | 12 // Set Public Session state. |
| 13 chromeos::LoginState::Initialize(); | 13 if (!LoginState::IsInitialized()) { |
| 14 chromeos::LoginState::Get()->SetLoggedInState( | 14 LoginState::Initialize(); |
| 15 chromeos::LoginState::LOGGED_IN_ACTIVE, | 15 needs_shutdown_ = true; |
|
Devlin
2017/05/04 18:03:17
It might be worth noting (in the class comments in
| |
| 16 chromeos::LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT); | 16 } |
| 17 LoginState::Get()->SetLoggedInState( | |
| 18 LoginState::LOGGED_IN_ACTIVE, | |
| 19 LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT); | |
| 17 } | 20 } |
| 18 | 21 |
| 19 ScopedTestPublicSessionLoginState::~ScopedTestPublicSessionLoginState() { | 22 ScopedTestPublicSessionLoginState::~ScopedTestPublicSessionLoginState() { |
| 20 // Reset state at the end of test. | 23 // Reset state at the end of test. |
| 21 chromeos::LoginState::Shutdown(); | 24 if (needs_shutdown_) { |
| 25 LoginState::Shutdown(); | |
| 26 } | |
| 22 } | 27 } |
| 23 | 28 |
| 24 } // namespace chromeos | 29 } // namespace chromeos |
| OLD | NEW |