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

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

Issue 378513005: [Athena] Extract Chrome OS authentication stack (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix includes in one more test 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"
11 #include "base/prefs/scoped_user_pref_update.h" 11 #include "base/prefs/scoped_user_pref_update.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "base/threading/sequenced_worker_pool.h" 15 #include "base/threading/sequenced_worker_pool.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/chromeos/login/managed/locally_managed_user_constants.h " 18 #include "chrome/browser/chromeos/login/managed/locally_managed_user_constants.h "
19 #include "chrome/browser/chromeos/login/managed/supervised_user_authentication.h " 19 #include "chrome/browser/chromeos/login/managed/supervised_user_authentication.h "
20 #include "chrome/browser/chromeos/login/users/user_manager_impl.h" 20 #include "chrome/browser/chromeos/login/users/user_manager_impl.h"
21 #include "chrome/browser/chromeos/profiles/profile_helper.h" 21 #include "chrome/browser/chromeos/profiles/profile_helper.h"
22 #include "chrome/browser/supervised_user/supervised_user_service.h" 22 #include "chrome/browser/supervised_user/supervised_user_service.h"
23 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" 23 #include "chrome/browser/supervised_user/supervised_user_service_factory.h"
24 #include "chromeos/login/user_names.h"
24 #include "chromeos/settings/cros_settings_names.h" 25 #include "chromeos/settings/cros_settings_names.h"
25 #include "components/user_manager/user_type.h" 26 #include "components/user_manager/user_type.h"
26 #include "content/public/browser/browser_thread.h" 27 #include "content/public/browser/browser_thread.h"
27 #include "google_apis/gaia/gaia_auth_util.h" 28 #include "google_apis/gaia/gaia_auth_util.h"
28 29
29 using content::BrowserThread; 30 using content::BrowserThread;
30 31
31 namespace { 32 namespace {
32 33
33 // Names for pref keys in Local State. 34 // Names for pref keys in Local State.
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 143
143 SupervisedUserManagerImpl::~SupervisedUserManagerImpl() { 144 SupervisedUserManagerImpl::~SupervisedUserManagerImpl() {
144 } 145 }
145 146
146 std::string SupervisedUserManagerImpl::GenerateUserId() { 147 std::string SupervisedUserManagerImpl::GenerateUserId() {
147 int counter = g_browser_process->local_state()-> 148 int counter = g_browser_process->local_state()->
148 GetInteger(kLocallyManagedUsersNextId); 149 GetInteger(kLocallyManagedUsersNextId);
149 std::string id; 150 std::string id;
150 bool user_exists; 151 bool user_exists;
151 do { 152 do {
152 id = base::StringPrintf("%d@%s", counter, 153 id = base::StringPrintf(
153 UserManager::kLocallyManagedUserDomain); 154 "%d@%s", counter, chromeos::login::kLocallyManagedUserDomain);
154 counter++; 155 counter++;
155 user_exists = (NULL != owner_->FindUser(id)); 156 user_exists = (NULL != owner_->FindUser(id));
156 DCHECK(!user_exists); 157 DCHECK(!user_exists);
157 if (user_exists) { 158 if (user_exists) {
158 LOG(ERROR) << "Supervised user with id " << id << " already exists."; 159 LOG(ERROR) << "Supervised user with id " << id << " already exists.";
159 } 160 }
160 } while (user_exists); 161 } while (user_exists);
161 162
162 g_browser_process->local_state()-> 163 g_browser_process->local_state()->
163 SetInteger(kLocallyManagedUsersNextId, counter); 164 SetInteger(kLocallyManagedUsersNextId, counter);
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 << display_name << "/" << user_id; 424 << display_name << "/" << user_id;
424 425
425 if (user_id.empty()) { 426 if (user_id.empty()) {
426 // Not much to do - just remove transaction. 427 // Not much to do - just remove transaction.
427 prefs->ClearPref(kLocallyManagedUserCreationTransactionDisplayName); 428 prefs->ClearPref(kLocallyManagedUserCreationTransactionDisplayName);
428 prefs->CommitPendingWrite(); 429 prefs->CommitPendingWrite();
429 return; 430 return;
430 } 431 }
431 432
432 if (gaia::ExtractDomainName(user_id) != 433 if (gaia::ExtractDomainName(user_id) !=
433 UserManager::kLocallyManagedUserDomain) { 434 chromeos::login::kLocallyManagedUserDomain) {
434 LOG(WARNING) << "Clean up transaction for non-locally managed user found :" 435 LOG(WARNING) << "Clean up transaction for non-locally managed user found :"
435 << user_id << ", will not remove data"; 436 << user_id << ", will not remove data";
436 prefs->ClearPref(kLocallyManagedUserCreationTransactionDisplayName); 437 prefs->ClearPref(kLocallyManagedUserCreationTransactionDisplayName);
437 prefs->ClearPref(kLocallyManagedUserCreationTransactionUserId); 438 prefs->ClearPref(kLocallyManagedUserCreationTransactionUserId);
438 prefs->CommitPendingWrite(); 439 prefs->CommitPendingWrite();
439 return; 440 return;
440 } 441 }
441 owner_->RemoveNonOwnerUserInternal(user_id, NULL); 442 owner_->RemoveNonOwnerUserInternal(user_id, NULL);
442 443
443 prefs->ClearPref(kLocallyManagedUserCreationTransactionDisplayName); 444 prefs->ClearPref(kLocallyManagedUserCreationTransactionDisplayName);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 } 516 }
516 517
517 void SupervisedUserManagerImpl::ConfigureSyncWithToken( 518 void SupervisedUserManagerImpl::ConfigureSyncWithToken(
518 Profile* profile, 519 Profile* profile,
519 const std::string& token) { 520 const std::string& token) {
520 if (!token.empty()) 521 if (!token.empty())
521 SupervisedUserServiceFactory::GetForProfile(profile)->InitSync(token); 522 SupervisedUserServiceFactory::GetForProfile(profile)->InitSync(token);
522 } 523 }
523 524
524 } // namespace chromeos 525 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/ui/webui_login_display.cc ('k') | chrome/browser/chromeos/login/users/user.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698