Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(515)

Side by Side Diff: chrome/browser/chromeos/login/users/fake_chrome_user_manager.cc

Issue 745613002: [cros] Cleanup: remove LoginUtils (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: get rid of FakeChromeUserManager usage in ExistingUserController* tests Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/users/fake_chrome_user_manager.h" 5 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
6 6
7 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" 7 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
8 #include "chrome/browser/chromeos/login/users/fake_supervised_user_manager.h" 8 #include "chrome/browser/chromeos/login/users/fake_supervised_user_manager.h"
9 #include "chrome/browser/chromeos/profiles/profile_helper.h" 9 #include "chrome/browser/chromeos/profiles/profile_helper.h"
10 #include "chrome/browser/chromeos/settings/cros_settings.h" 10 #include "chrome/browser/chromeos/settings/cros_settings.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 return supervised_user_manager_.get(); 74 return supervised_user_manager_.get();
75 } 75 }
76 76
77 UserImageManager* FakeChromeUserManager::GetUserImageManager( 77 UserImageManager* FakeChromeUserManager::GetUserImageManager(
78 const std::string& /* user_id */) { 78 const std::string& /* user_id */) {
79 return nullptr; 79 return nullptr;
80 } 80 }
81 81
82 void FakeChromeUserManager::SetUserFlow(const std::string& email, 82 void FakeChromeUserManager::SetUserFlow(const std::string& email,
83 UserFlow* flow) { 83 UserFlow* flow) {
84 ResetUserFlow(email);
85 specific_flows_[email] = flow;
84 } 86 }
85 87
86 UserFlow* FakeChromeUserManager::GetCurrentUserFlow() const { 88 UserFlow* FakeChromeUserManager::GetCurrentUserFlow() const {
87 return nullptr; 89 if (!IsUserLoggedIn())
90 return GetDefaultUserFlow();
91 return GetUserFlow(GetLoggedInUser()->email());
88 } 92 }
89 93
90 UserFlow* FakeChromeUserManager::GetUserFlow(const std::string& email) const { 94 UserFlow* FakeChromeUserManager::GetUserFlow(const std::string& email) const {
91 return nullptr; 95 FlowMap::const_iterator it = specific_flows_.find(email);
96 if (it != specific_flows_.end())
97 return it->second;
98 return GetDefaultUserFlow();
92 } 99 }
93 100
94 void FakeChromeUserManager::ResetUserFlow(const std::string& email) { 101 void FakeChromeUserManager::ResetUserFlow(const std::string& email) {
102 FlowMap::iterator it = specific_flows_.find(email);
103 if (it != specific_flows_.end()) {
104 delete it->second;
105 specific_flows_.erase(it);
106 }
95 } 107 }
96 108
97 void FakeChromeUserManager::SwitchActiveUser(const std::string& email) { 109 void FakeChromeUserManager::SwitchActiveUser(const std::string& email) {
98 active_user_id_ = email; 110 active_user_id_ = email;
99 ProfileHelper::Get()->ActiveUserHashChanged( 111 ProfileHelper::Get()->ActiveUserHashChanged(
100 ProfileHelper::GetUserIdHashByUserIdForTesting(email)); 112 ProfileHelper::GetUserIdHashByUserIdForTesting(email));
101 if (!users_.empty() && !active_user_id_.empty()) { 113 if (!users_.empty() && !active_user_id_.empty()) {
102 for (user_manager::User* user : users_) 114 for (user_manager::User* user : users_)
103 user->set_is_active(user->email() == active_user_id_); 115 user->set_is_active(user->email() == active_user_id_);
104 } 116 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 for (user_manager::User* user : users) { 155 for (user_manager::User* user : users) {
144 if (user->GetType() == user_manager::USER_TYPE_REGULAR && 156 if (user->GetType() == user_manager::USER_TYPE_REGULAR &&
145 !user->is_logged_in()) { 157 !user->is_logged_in()) {
146 result.push_back(user); 158 result.push_back(user);
147 } 159 }
148 } 160 }
149 161
150 return result; 162 return result;
151 } 163 }
152 164
165 UserFlow* FakeChromeUserManager::GetDefaultUserFlow() const {
166 if (!default_flow_.get())
167 default_flow_.reset(new DefaultUserFlow());
168 return default_flow_.get();
169 }
170
153 } // namespace chromeos 171 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/users/fake_chrome_user_manager.h ('k') | chrome/browser/chromeos/login/wizard_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698