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

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

Issue 398753004: [cros] Move User class to user_manager component. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 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 | Annotate | Revision Log
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 "chrome/browser/chromeos/login/users/supervised_user_manager_impl.h" 5 #include "chrome/browser/chromeos/login/users/supervised_user_manager_impl.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/prefs/pref_registry_simple.h" 9 #include "base/prefs/pref_registry_simple.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 158
159 g_browser_process->local_state()-> 159 g_browser_process->local_state()->
160 SetInteger(kSupervisedUsersNextId, counter); 160 SetInteger(kSupervisedUsersNextId, counter);
161 161
162 g_browser_process->local_state()->CommitPendingWrite(); 162 g_browser_process->local_state()->CommitPendingWrite();
163 return id; 163 return id;
164 } 164 }
165 165
166 bool SupervisedUserManagerImpl::HasSupervisedUsers( 166 bool SupervisedUserManagerImpl::HasSupervisedUsers(
167 const std::string& manager_id) const { 167 const std::string& manager_id) const {
168 const UserList& users = owner_->GetUsers(); 168 const user_manager::UserList& users = owner_->GetUsers();
169 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { 169 for (user_manager::UserList::const_iterator it = users.begin();
170 it != users.end();
171 ++it) {
170 if ((*it)->GetType() == user_manager::USER_TYPE_SUPERVISED) { 172 if ((*it)->GetType() == user_manager::USER_TYPE_SUPERVISED) {
171 if (manager_id == GetManagerUserId((*it)->email())) 173 if (manager_id == GetManagerUserId((*it)->email()))
172 return true; 174 return true;
173 } 175 }
174 } 176 }
175 return false; 177 return false;
176 } 178 }
177 179
178 const User* SupervisedUserManagerImpl::CreateUserRecord( 180 const user_manager::User* SupervisedUserManagerImpl::CreateUserRecord(
179 const std::string& manager_id, 181 const std::string& manager_id,
180 const std::string& local_user_id, 182 const std::string& local_user_id,
181 const std::string& sync_user_id, 183 const std::string& sync_user_id,
182 const base::string16& display_name) { 184 const base::string16& display_name) {
183 const User* user = FindByDisplayName(display_name); 185 const user_manager::User* user = FindByDisplayName(display_name);
184 DCHECK(!user); 186 DCHECK(!user);
185 if (user) 187 if (user)
186 return user; 188 return user;
187 const User* manager = owner_->FindUser(manager_id); 189 const user_manager::User* manager = owner_->FindUser(manager_id);
188 CHECK(manager); 190 CHECK(manager);
189 191
190 PrefService* local_state = g_browser_process->local_state(); 192 PrefService* local_state = g_browser_process->local_state();
191 193
192 User* new_user = User::CreateSupervisedUser(local_user_id); 194 user_manager::User* new_user =
195 user_manager::User::CreateSupervisedUser(local_user_id);
193 196
194 owner_->AddUserRecord(new_user); 197 owner_->AddUserRecord(new_user);
195 198
196 ListPrefUpdate prefs_new_users_update(local_state, 199 ListPrefUpdate prefs_new_users_update(local_state,
197 kSupervisedUsersFirstRun); 200 kSupervisedUsersFirstRun);
198 DictionaryPrefUpdate sync_id_update(local_state, kSupervisedUserSyncId); 201 DictionaryPrefUpdate sync_id_update(local_state, kSupervisedUserSyncId);
199 DictionaryPrefUpdate manager_update(local_state, kSupervisedUserManagers); 202 DictionaryPrefUpdate manager_update(local_state, kSupervisedUserManagers);
200 DictionaryPrefUpdate manager_name_update(local_state, 203 DictionaryPrefUpdate manager_name_update(local_state,
201 kSupervisedUserManagerNames); 204 kSupervisedUserManagerNames);
202 DictionaryPrefUpdate manager_email_update( 205 DictionaryPrefUpdate manager_email_update(
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 } 348 }
346 349
347 void SupervisedUserManagerImpl::SetUserBooleanValue(const std::string& user_id, 350 void SupervisedUserManagerImpl::SetUserBooleanValue(const std::string& user_id,
348 const char* key, 351 const char* key,
349 const bool value) { 352 const bool value) {
350 PrefService* local_state = g_browser_process->local_state(); 353 PrefService* local_state = g_browser_process->local_state();
351 DictionaryPrefUpdate update(local_state, key); 354 DictionaryPrefUpdate update(local_state, key);
352 update->SetBooleanWithoutPathExpansion(user_id, value); 355 update->SetBooleanWithoutPathExpansion(user_id, value);
353 } 356 }
354 357
355 const User* SupervisedUserManagerImpl::FindByDisplayName( 358 const user_manager::User* SupervisedUserManagerImpl::FindByDisplayName(
356 const base::string16& display_name) const { 359 const base::string16& display_name) const {
357 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 360 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
358 const UserList& users = owner_->GetUsers(); 361 const user_manager::UserList& users = owner_->GetUsers();
359 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { 362 for (user_manager::UserList::const_iterator it = users.begin();
363 it != users.end();
364 ++it) {
360 if (((*it)->GetType() == user_manager::USER_TYPE_SUPERVISED) && 365 if (((*it)->GetType() == user_manager::USER_TYPE_SUPERVISED) &&
361 ((*it)->display_name() == display_name)) { 366 ((*it)->display_name() == display_name)) {
362 return *it; 367 return *it;
363 } 368 }
364 } 369 }
365 return NULL; 370 return NULL;
366 } 371 }
367 372
368 const User* SupervisedUserManagerImpl::FindBySyncId( 373 const user_manager::User* SupervisedUserManagerImpl::FindBySyncId(
369 const std::string& sync_id) const { 374 const std::string& sync_id) const {
370 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 375 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
371 const UserList& users = owner_->GetUsers(); 376 const user_manager::UserList& users = owner_->GetUsers();
372 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { 377 for (user_manager::UserList::const_iterator it = users.begin();
378 it != users.end();
379 ++it) {
373 if (((*it)->GetType() == user_manager::USER_TYPE_SUPERVISED) && 380 if (((*it)->GetType() == user_manager::USER_TYPE_SUPERVISED) &&
374 (GetUserSyncId((*it)->email()) == sync_id)) { 381 (GetUserSyncId((*it)->email()) == sync_id)) {
375 return *it; 382 return *it;
376 } 383 }
377 } 384 }
378 return NULL; 385 return NULL;
379 } 386 }
380 387
381 void SupervisedUserManagerImpl::StartCreationTransaction( 388 void SupervisedUserManagerImpl::StartCreationTransaction(
382 const base::string16& display_name) { 389 const base::string16& display_name) {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 } 519 }
513 520
514 void SupervisedUserManagerImpl::ConfigureSyncWithToken( 521 void SupervisedUserManagerImpl::ConfigureSyncWithToken(
515 Profile* profile, 522 Profile* profile,
516 const std::string& token) { 523 const std::string& token) {
517 if (!token.empty()) 524 if (!token.empty())
518 SupervisedUserServiceFactory::GetForProfile(profile)->InitSync(token); 525 SupervisedUserServiceFactory::GetForProfile(profile)->InitSync(token);
519 } 526 }
520 527
521 } // namespace chromeos 528 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/users/supervised_user_manager_impl.h ('k') | chrome/browser/chromeos/login/users/user.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698