Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / components / user_manager / user_manager.cc
blob597407fa581800990a53f22a873c8beab7a07911
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 "components/user_manager/user_manager.h"
7 #include "base/logging.h"
9 namespace user_manager {
11 UserManager* UserManager::instance = NULL;
13 UserManager::Observer::~Observer() {
16 void UserManager::Observer::LocalStateChanged(UserManager* user_manager) {
19 void UserManager::UserSessionStateObserver::ActiveUserChanged(
20 const User* active_user) {
23 void UserManager::UserSessionStateObserver::UserAddedToSession(
24 const User* active_user) {
27 void UserManager::UserSessionStateObserver::ActiveUserHashChanged(
28 const std::string& hash) {
31 UserManager::UserSessionStateObserver::~UserSessionStateObserver() {
34 UserManager::UserAccountData::UserAccountData(
35 const base::string16& display_name,
36 const base::string16& given_name,
37 const std::string& locale)
38 : display_name_(display_name), given_name_(given_name), locale_(locale) {
41 UserManager::UserAccountData::~UserAccountData() {
44 void UserManager::Initialize() {
45 DCHECK(!UserManager::instance);
46 UserManager::SetInstance(this);
49 // static
50 bool UserManager::IsInitialized() {
51 return UserManager::instance;
54 void UserManager::Destroy() {
55 DCHECK(UserManager::instance == this);
56 UserManager::SetInstance(NULL);
59 // static
60 UserManager* user_manager::UserManager::Get() {
61 CHECK(UserManager::instance);
62 return UserManager::instance;
65 UserManager::~UserManager() {
68 // static
69 void UserManager::SetInstance(UserManager* user_manager) {
70 UserManager::instance = user_manager;
73 // static
74 UserManager* user_manager::UserManager::GetForTesting() {
75 return UserManager::instance;
78 // static
79 UserManager* UserManager::SetForTesting(UserManager* user_manager) {
80 UserManager* previous_instance = UserManager::instance;
81 UserManager::instance = user_manager;
82 return previous_instance;
85 } // namespace user_manager