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

Side by Side Diff: components/user_manager/fake_user_manager.cc

Issue 1922143002: Disabled ARC for ephemeral users. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: same Created 4 years, 7 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 2014 The Chromium Authors. All rights reserved. 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 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 "components/user_manager/fake_user_manager.h" 5 #include "components/user_manager/fake_user_manager.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/sys_info.h" 9 #include "base/sys_info.h"
10 #include "base/task_runner.h" 10 #include "base/task_runner.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 return user; 52 return user;
53 } 53 }
54 54
55 void FakeUserManager::RemoveUserFromList(const AccountId& account_id) { 55 void FakeUserManager::RemoveUserFromList(const AccountId& account_id) {
56 user_manager::UserList::iterator it = users_.begin(); 56 user_manager::UserList::iterator it = users_.begin();
57 // TODO (alemate): Chenge this to GetAccountId(), once a real AccountId is 57 // TODO (alemate): Chenge this to GetAccountId(), once a real AccountId is
58 // passed. crbug.com/546876 58 // passed. crbug.com/546876
59 while (it != users_.end() && (*it)->GetEmail() != account_id.GetUserEmail()) 59 while (it != users_.end() && (*it)->GetEmail() != account_id.GetUserEmail())
60 ++it; 60 ++it;
61 if (it != users_.end()) { 61 if (it != users_.end()) {
62 delete *it; 62 if (active_user_ != *it)
63 delete *it;
63 users_.erase(it); 64 users_.erase(it);
64 } 65 }
65 } 66 }
66 67
67 const user_manager::UserList& FakeUserManager::GetUsers() const { 68 const user_manager::UserList& FakeUserManager::GetUsers() const {
68 return users_; 69 return users_;
69 } 70 }
70 71
71 user_manager::UserList FakeUserManager::GetUsersAllowedForMultiProfile() const { 72 user_manager::UserList FakeUserManager::GetUsersAllowedForMultiProfile() const {
72 user_manager::UserList result; 73 user_manager::UserList result;
(...skipping 21 matching lines...) Expand all
94 logged_in_users_.push_back(*it); 95 logged_in_users_.push_back(*it);
95 96
96 if (!primary_user_) 97 if (!primary_user_)
97 primary_user_ = *it; 98 primary_user_ = *it;
98 break; 99 break;
99 } 100 }
100 } 101 }
101 } 102 }
102 103
103 user_manager::User* FakeUserManager::GetActiveUserInternal() const { 104 user_manager::User* FakeUserManager::GetActiveUserInternal() const {
105 if (active_user_ != nullptr)
106 return active_user_;
107
104 if (!users_.empty()) { 108 if (!users_.empty()) {
105 if (active_account_id_.is_valid()) { 109 if (active_account_id_.is_valid()) {
106 for (user_manager::UserList::const_iterator it = users_.begin(); 110 for (user_manager::UserList::const_iterator it = users_.begin();
107 it != users_.end(); ++it) { 111 it != users_.end(); ++it) {
108 if ((*it)->GetAccountId() == active_account_id_) 112 if ((*it)->GetAccountId() == active_account_id_)
109 return *it; 113 return *it;
110 } 114 }
111 } 115 }
112 return users_[0]; 116 return users_[0];
113 } 117 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 const AccountId& FakeUserManager::GetOwnerAccountId() const { 152 const AccountId& FakeUserManager::GetOwnerAccountId() const {
149 return owner_account_id_; 153 return owner_account_id_;
150 } 154 }
151 155
152 bool FakeUserManager::IsKnownUser(const AccountId& account_id) const { 156 bool FakeUserManager::IsKnownUser(const AccountId& account_id) const {
153 return true; 157 return true;
154 } 158 }
155 159
156 const user_manager::User* FakeUserManager::FindUser( 160 const user_manager::User* FakeUserManager::FindUser(
157 const AccountId& account_id) const { 161 const AccountId& account_id) const {
162 if (active_user_ != nullptr && active_user_->GetAccountId() == account_id)
163 return active_user_;
164
158 const user_manager::UserList& users = GetUsers(); 165 const user_manager::UserList& users = GetUsers();
159 for (user_manager::UserList::const_iterator it = users.begin(); 166 for (user_manager::UserList::const_iterator it = users.begin();
160 it != users.end(); ++it) { 167 it != users.end(); ++it) {
161 // TODO (alemate): Chenge this to GetAccountId(), once a real AccountId is 168 if ((*it)->GetAccountId() == account_id)
162 // passed. crbug.com/546876
163 if ((*it)->GetEmail() == account_id.GetUserEmail())
164 return *it; 169 return *it;
165 } 170 }
171
166 return nullptr; 172 return nullptr;
167 } 173 }
168 174
169 user_manager::User* FakeUserManager::FindUserAndModify( 175 user_manager::User* FakeUserManager::FindUserAndModify(
170 const AccountId& account_id) { 176 const AccountId& account_id) {
171 return nullptr; 177 return nullptr;
172 } 178 }
173 179
174 const user_manager::User* FakeUserManager::GetLoggedInUser() const { 180 const user_manager::User* FakeUserManager::GetLoggedInUser() const {
175 return nullptr; 181 return nullptr;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 270
265 PrefService* FakeUserManager::GetLocalState() const { 271 PrefService* FakeUserManager::GetLocalState() const {
266 return nullptr; 272 return nullptr;
267 } 273 }
268 274
269 bool FakeUserManager::IsEnterpriseManaged() const { 275 bool FakeUserManager::IsEnterpriseManaged() const {
270 return false; 276 return false;
271 } 277 }
272 278
273 bool FakeUserManager::IsDemoApp(const AccountId& account_id) const { 279 bool FakeUserManager::IsDemoApp(const AccountId& account_id) const {
274 return false; 280 return account_id == chromeos::login::DemoAccountId();
275 } 281 }
276 282
277 bool FakeUserManager::IsDeviceLocalAccountMarkedForRemoval( 283 bool FakeUserManager::IsDeviceLocalAccountMarkedForRemoval(
278 const AccountId& account_id) const { 284 const AccountId& account_id) const {
279 return false; 285 return false;
280 } 286 }
281 287
282 void FakeUserManager::UpdateLoginState(const user_manager::User* active_user, 288 void FakeUserManager::UpdateLoginState(const user_manager::User* active_user,
283 const user_manager::User* primary_user, 289 const user_manager::User* primary_user,
284 bool is_current_user_owner) const {} 290 bool is_current_user_owner) const {}
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 NOTIMPLEMENTED(); 351 NOTIMPLEMENTED();
346 return; 352 return;
347 } 353 }
348 354
349 bool FakeUserManager::IsValidDefaultUserImageId(int image_index) const { 355 bool FakeUserManager::IsValidDefaultUserImageId(int image_index) const {
350 NOTIMPLEMENTED(); 356 NOTIMPLEMENTED();
351 return false; 357 return false;
352 } 358 }
353 359
354 } // namespace user_manager 360 } // namespace user_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698