| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/user_manager.h" | 5 #include "chrome/browser/chromeos/login/user_manager.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/prefs/pref_registry_simple.h" | 8 #include "base/prefs/pref_registry_simple.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/browser_process_platform_part_chromeos.h" | 10 #include "chrome/browser/browser_process_platform_part_chromeos.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 delete g_user_manager; | 84 delete g_user_manager; |
| 85 g_user_manager = NULL; | 85 g_user_manager = NULL; |
| 86 } | 86 } |
| 87 | 87 |
| 88 // static | 88 // static |
| 89 UserManager* UserManager::Get() { | 89 UserManager* UserManager::Get() { |
| 90 CHECK(g_user_manager); | 90 CHECK(g_user_manager); |
| 91 return g_user_manager; | 91 return g_user_manager; |
| 92 } | 92 } |
| 93 | 93 |
| 94 // static | |
| 95 bool UserManager::IsMultipleProfilesAllowed() { | |
| 96 return CommandLine::ForCurrentProcess()->HasSwitch( | |
| 97 ::switches::kMultiProfiles); | |
| 98 } | |
| 99 | |
| 100 UserManager::~UserManager() { | 94 UserManager::~UserManager() { |
| 101 } | 95 } |
| 102 | 96 |
| 103 // static | 97 // static |
| 104 UserManager* UserManager::SetForTesting(UserManager* user_manager) { | 98 UserManager* UserManager::SetForTesting(UserManager* user_manager) { |
| 105 UserManager* previous_user_manager = g_user_manager; | 99 UserManager* previous_user_manager = g_user_manager; |
| 100 if (previous_user_manager) |
| 101 previous_user_manager->Shutdown(); |
| 102 |
| 106 g_user_manager = user_manager; | 103 g_user_manager = user_manager; |
| 107 return previous_user_manager; | 104 return previous_user_manager; |
| 108 } | 105 } |
| 109 | 106 |
| 110 ScopedUserManagerEnabler::ScopedUserManagerEnabler(UserManager* user_manager) | 107 ScopedUserManagerEnabler::ScopedUserManagerEnabler(UserManager* user_manager) |
| 111 : previous_user_manager_(UserManager::SetForTesting(user_manager)) { | 108 : previous_user_manager_(UserManager::SetForTesting(user_manager)) { |
| 112 } | 109 } |
| 113 | 110 |
| 114 ScopedUserManagerEnabler::~ScopedUserManagerEnabler() { | 111 ScopedUserManagerEnabler::~ScopedUserManagerEnabler() { |
| 115 UserManager::Get()->Shutdown(); | 112 UserManager::Get()->Shutdown(); |
| 116 UserManager::Destroy(); | 113 UserManager::Destroy(); |
| 117 UserManager::SetForTesting(previous_user_manager_); | 114 UserManager::SetForTesting(previous_user_manager_); |
| 118 } | 115 } |
| 119 | 116 |
| 120 ScopedTestUserManager::ScopedTestUserManager() { | 117 ScopedTestUserManager::ScopedTestUserManager() { |
| 121 UserManager::Initialize(); | 118 UserManager::Initialize(); |
| 122 | 119 |
| 123 // ProfileHelper has to be initialized after UserManager instance is created. | 120 // ProfileHelper has to be initialized after UserManager instance is created. |
| 124 g_browser_process->platform_part()->profile_helper()->Initialize(); | 121 g_browser_process->platform_part()->profile_helper()->Initialize(); |
| 125 } | 122 } |
| 126 | 123 |
| 127 ScopedTestUserManager::~ScopedTestUserManager() { | 124 ScopedTestUserManager::~ScopedTestUserManager() { |
| 128 UserManager::Get()->Shutdown(); | 125 UserManager::Get()->Shutdown(); |
| 129 UserManager::Destroy(); | 126 UserManager::Destroy(); |
| 130 } | 127 } |
| 131 | 128 |
| 132 } // namespace chromeos | 129 } // namespace chromeos |
| OLD | NEW |