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

Side by Side Diff: chrome/browser/chromeos/login/fake_user_manager.cc

Issue 117263002: Prevent ONC-pushed certificates from being used with multiprofiles. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Philipps suggestion, another test Created 7 years 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/fake_user_manager.h" 5 #include "chrome/browser/chromeos/login/fake_user_manager.h"
6 6
7 #include "chrome/browser/chromeos/login/fake_supervised_user_manager.h" 7 #include "chrome/browser/chromeos/login/fake_supervised_user_manager.h"
8 8
9 namespace { 9 namespace {
10 10
11 // As defined in /chromeos/dbus/cryptohome_client.cc. 11 // As defined in /chromeos/dbus/cryptohome_client.cc.
12 static const char kUserIdHashSuffix[] = "-hash"; 12 static const char kUserIdHashSuffix[] = "-hash";
13 13
14 } // namespace 14 } // namespace
15 15
16 namespace chromeos { 16 namespace chromeos {
17 17
18 FakeUserManager::FakeUserManager() 18 FakeUserManager::FakeUserManager()
19 : supervised_user_manager_(new FakeSupervisedUserManager), 19 : supervised_user_manager_(new FakeSupervisedUserManager),
20 primary_user_(NULL) {} 20 primary_user_(NULL) {}
21 21
22 FakeUserManager::~FakeUserManager() { 22 FakeUserManager::~FakeUserManager() {
23 // Can't use STLDeleteElements because of the private destructor of User. 23 // Can't use STLDeleteElements because of the private destructor of User.
24 for (UserList::iterator it = user_list_.begin(); it != user_list_.end(); 24 for (UserList::iterator it = user_list_.begin(); it != user_list_.end();
25 it = user_list_.erase(it)) { 25 it = user_list_.erase(it)) {
26 delete *it; 26 delete *it;
27 } 27 }
28 } 28 }
29 29
30 void FakeUserManager::AddUser(const std::string& email) { 30 const User* FakeUserManager::AddUser(const std::string& email) {
31 User* user = User::CreateRegularUser(email); 31 User* user = User::CreateRegularUser(email);
32 user->set_username_hash(email + kUserIdHashSuffix); 32 user->set_username_hash(email + kUserIdHashSuffix);
33 user->SetStubImage(User::kProfileImageIndex, false); 33 user->SetStubImage(User::kProfileImageIndex, false);
34 user_list_.push_back(user); 34 user_list_.push_back(user);
35 return user;
35 } 36 }
36 37
37 void FakeUserManager::AddKioskAppUser(const std::string& kiosk_app_username) { 38 void FakeUserManager::AddKioskAppUser(const std::string& kiosk_app_username) {
38 User* user = User::CreateKioskAppUser(kiosk_app_username); 39 User* user = User::CreateKioskAppUser(kiosk_app_username);
39 user->set_username_hash(kiosk_app_username + kUserIdHashSuffix); 40 user->set_username_hash(kiosk_app_username + kUserIdHashSuffix);
40 user_list_.push_back(user); 41 user_list_.push_back(user);
41 } 42 }
42 43
43 void FakeUserManager::LoginUser(const std::string& email) { 44 void FakeUserManager::LoginUser(const std::string& email) {
44 UserLoggedIn(email, email + kUserIdHashSuffix, false); 45 UserLoggedIn(email, email + kUserIdHashSuffix, false);
45 } 46 }
46 47
48 void FakeUserManager::SetProfileForUser(const User* user, Profile* profile) {
49 user_to_profile_[user] = profile;
50 }
51
47 const UserList& FakeUserManager::GetUsers() const { 52 const UserList& FakeUserManager::GetUsers() const {
48 return user_list_; 53 return user_list_;
49 } 54 }
50 55
51 UserList FakeUserManager::GetUsersAdmittedForMultiProfile() const { 56 UserList FakeUserManager::GetUsersAdmittedForMultiProfile() const {
52 UserList result; 57 UserList result;
53 for (UserList::const_iterator it = user_list_.begin(); 58 for (UserList::const_iterator it = user_list_.begin();
54 it != user_list_.end(); 59 it != user_list_.end();
55 ++it) { 60 ++it) {
56 if ((*it)->GetType() == User::USER_TYPE_REGULAR && !(*it)->is_logged_in()) 61 if ((*it)->GetType() == User::USER_TYPE_REGULAR && !(*it)->is_logged_in())
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 const std::string& user_name = profile->GetProfileName(); 171 const std::string& user_name = profile->GetProfileName();
167 for (UserList::const_iterator it = user_list_.begin(); 172 for (UserList::const_iterator it = user_list_.begin();
168 it != user_list_.end(); ++it) { 173 it != user_list_.end(); ++it) {
169 if ((*it)->email() == user_name) 174 if ((*it)->email() == user_name)
170 return *it; 175 return *it;
171 } 176 }
172 return primary_user_; 177 return primary_user_;
173 } 178 }
174 179
175 Profile* FakeUserManager::GetProfileByUser(const User* user) const { 180 Profile* FakeUserManager::GetProfileByUser(const User* user) const {
176 NOTIMPLEMENTED(); 181 std::map<const User*, Profile*>::const_iterator it =
177 return NULL; 182 user_to_profile_.find(user);
183 return it == user_to_profile_.end() ? NULL : it->second;
178 } 184 }
179 185
180 base::string16 FakeUserManager::GetUserDisplayName( 186 base::string16 FakeUserManager::GetUserDisplayName(
181 const std::string& username) const { 187 const std::string& username) const {
182 return base::string16(); 188 return base::string16();
183 } 189 }
184 190
185 std::string FakeUserManager::GetUserDisplayEmail( 191 std::string FakeUserManager::GetUserDisplayEmail(
186 const std::string& username) const { 192 const std::string& username) const {
187 return std::string(); 193 return std::string();
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 } 285 }
280 286
281 bool FakeUserManager::RespectLocalePreference( 287 bool FakeUserManager::RespectLocalePreference(
282 Profile* profile, 288 Profile* profile,
283 const User* user, 289 const User* user,
284 scoped_ptr<locale_util::SwitchLanguageCallback> callback) const { 290 scoped_ptr<locale_util::SwitchLanguageCallback> callback) const {
285 return false; 291 return false;
286 } 292 }
287 293
288 } // namespace chromeos 294 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698