Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / chromeos / login / users / scoped_user_manager_enabler.cc
blob8ae87befb01faf52a9aac55b247af740ebe3f977
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
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
7 #include "components/user_manager/user_manager.h"
9 namespace chromeos {
11 ScopedUserManagerEnabler::ScopedUserManagerEnabler(
12 user_manager::UserManager* user_manager) {
13 if (user_manager::UserManager::GetForTesting())
14 user_manager::UserManager::GetForTesting()->Shutdown();
16 previous_user_manager_ =
17 user_manager::UserManager::SetForTesting(user_manager);
20 ScopedUserManagerEnabler::~ScopedUserManagerEnabler() {
21 // Shutdown and destroy current UserManager instance that we track.
22 user_manager::UserManager::Get()->Shutdown();
23 delete user_manager::UserManager::Get();
24 user_manager::UserManager::SetInstance(NULL);
26 user_manager::UserManager::SetForTesting(previous_user_manager_);
29 } // namespace chromeos