| OLD | NEW |
| 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/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 registry->RegisterDictionaryPref(kSupervisedUserPasswordRevision); | 126 registry->RegisterDictionaryPref(kSupervisedUserPasswordRevision); |
| 127 | 127 |
| 128 registry->RegisterDictionaryPref(kSupervisedUserNeedPasswordUpdate); | 128 registry->RegisterDictionaryPref(kSupervisedUserNeedPasswordUpdate); |
| 129 registry->RegisterDictionaryPref(kSupervisedUserIncompleteKey); | 129 registry->RegisterDictionaryPref(kSupervisedUserIncompleteKey); |
| 130 } | 130 } |
| 131 | 131 |
| 132 SupervisedUserManagerImpl::SupervisedUserManagerImpl( | 132 SupervisedUserManagerImpl::SupervisedUserManagerImpl( |
| 133 ChromeUserManagerImpl* owner) | 133 ChromeUserManagerImpl* owner) |
| 134 : owner_(owner), cros_settings_(CrosSettings::Get()) { | 134 : owner_(owner), cros_settings_(CrosSettings::Get()) { |
| 135 // SupervisedUserManager instance should be used only on UI thread. | 135 // SupervisedUserManager instance should be used only on UI thread. |
| 136 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 136 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 137 authentication_.reset(new SupervisedUserAuthentication(this)); | 137 authentication_.reset(new SupervisedUserAuthentication(this)); |
| 138 } | 138 } |
| 139 | 139 |
| 140 SupervisedUserManagerImpl::~SupervisedUserManagerImpl() { | 140 SupervisedUserManagerImpl::~SupervisedUserManagerImpl() { |
| 141 } | 141 } |
| 142 | 142 |
| 143 std::string SupervisedUserManagerImpl::GenerateUserId() { | 143 std::string SupervisedUserManagerImpl::GenerateUserId() { |
| 144 int counter = g_browser_process->local_state()-> | 144 int counter = g_browser_process->local_state()-> |
| 145 GetInteger(kSupervisedUsersNextId); | 145 GetInteger(kSupervisedUsersNextId); |
| 146 std::string id; | 146 std::string id; |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 void SupervisedUserManagerImpl::SetUserBooleanValue(const std::string& user_id, | 350 void SupervisedUserManagerImpl::SetUserBooleanValue(const std::string& user_id, |
| 351 const char* key, | 351 const char* key, |
| 352 const bool value) { | 352 const bool value) { |
| 353 PrefService* local_state = g_browser_process->local_state(); | 353 PrefService* local_state = g_browser_process->local_state(); |
| 354 DictionaryPrefUpdate update(local_state, key); | 354 DictionaryPrefUpdate update(local_state, key); |
| 355 update->SetBooleanWithoutPathExpansion(user_id, value); | 355 update->SetBooleanWithoutPathExpansion(user_id, value); |
| 356 } | 356 } |
| 357 | 357 |
| 358 const user_manager::User* SupervisedUserManagerImpl::FindByDisplayName( | 358 const user_manager::User* SupervisedUserManagerImpl::FindByDisplayName( |
| 359 const base::string16& display_name) const { | 359 const base::string16& display_name) const { |
| 360 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 360 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 361 const user_manager::UserList& users = owner_->GetUsers(); | 361 const user_manager::UserList& users = owner_->GetUsers(); |
| 362 for (user_manager::UserList::const_iterator it = users.begin(); | 362 for (user_manager::UserList::const_iterator it = users.begin(); |
| 363 it != users.end(); | 363 it != users.end(); |
| 364 ++it) { | 364 ++it) { |
| 365 if (((*it)->GetType() == user_manager::USER_TYPE_SUPERVISED) && | 365 if (((*it)->GetType() == user_manager::USER_TYPE_SUPERVISED) && |
| 366 ((*it)->display_name() == display_name)) { | 366 ((*it)->display_name() == display_name)) { |
| 367 return *it; | 367 return *it; |
| 368 } | 368 } |
| 369 } | 369 } |
| 370 return NULL; | 370 return NULL; |
| 371 } | 371 } |
| 372 | 372 |
| 373 const user_manager::User* SupervisedUserManagerImpl::FindBySyncId( | 373 const user_manager::User* SupervisedUserManagerImpl::FindBySyncId( |
| 374 const std::string& sync_id) const { | 374 const std::string& sync_id) const { |
| 375 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 375 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 376 const user_manager::UserList& users = owner_->GetUsers(); | 376 const user_manager::UserList& users = owner_->GetUsers(); |
| 377 for (user_manager::UserList::const_iterator it = users.begin(); | 377 for (user_manager::UserList::const_iterator it = users.begin(); |
| 378 it != users.end(); | 378 it != users.end(); |
| 379 ++it) { | 379 ++it) { |
| 380 if (((*it)->GetType() == user_manager::USER_TYPE_SUPERVISED) && | 380 if (((*it)->GetType() == user_manager::USER_TYPE_SUPERVISED) && |
| 381 (GetUserSyncId((*it)->email()) == sync_id)) { | 381 (GetUserSyncId((*it)->email()) == sync_id)) { |
| 382 return *it; | 382 return *it; |
| 383 } | 383 } |
| 384 } | 384 } |
| 385 return NULL; | 385 return NULL; |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 } | 519 } |
| 520 | 520 |
| 521 void SupervisedUserManagerImpl::ConfigureSyncWithToken( | 521 void SupervisedUserManagerImpl::ConfigureSyncWithToken( |
| 522 Profile* profile, | 522 Profile* profile, |
| 523 const std::string& token) { | 523 const std::string& token) { |
| 524 if (!token.empty()) | 524 if (!token.empty()) |
| 525 SupervisedUserServiceFactory::GetForProfile(profile)->InitSync(token); | 525 SupervisedUserServiceFactory::GetForProfile(profile)->InitSync(token); |
| 526 } | 526 } |
| 527 | 527 |
| 528 } // namespace chromeos | 528 } // namespace chromeos |
| OLD | NEW |