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

Side by Side Diff: chrome/browser/chromeos/login/managed/managed_user_creation_controller_old.cc

Issue 335833003: Rename "managed (mode|user)" to "supervised user" (part 2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments (+ a few other cleanups) Created 6 years, 6 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/managed/managed_user_creation_controller _old.h" 5 #include "chrome/browser/chromeos/login/managed/managed_user_creation_controller _old.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 25 matching lines...) Expand all
36 namespace { 36 namespace {
37 37
38 const int kUserCreationTimeoutSeconds = 30; // 30 seconds. 38 const int kUserCreationTimeoutSeconds = 30; // 30 seconds.
39 39
40 bool StoreManagedUserFiles(const std::string& token, 40 bool StoreManagedUserFiles(const std::string& token,
41 const base::FilePath& base_path) { 41 const base::FilePath& base_path) {
42 if (!base::SysInfo::IsRunningOnChromeOS()) { 42 if (!base::SysInfo::IsRunningOnChromeOS()) {
43 // If running on desktop, cryptohome stub does not create home directory. 43 // If running on desktop, cryptohome stub does not create home directory.
44 base::CreateDirectory(base_path); 44 base::CreateDirectory(base_path);
45 } 45 }
46 base::FilePath token_file = base_path.Append(kManagedUserTokenFilename); 46 base::FilePath token_file = base_path.Append(kSupervisedUserTokenFilename);
47 int bytes = base::WriteFile(token_file, token.c_str(), token.length()); 47 int bytes = base::WriteFile(token_file, token.c_str(), token.length());
48 return bytes >= 0; 48 return bytes >= 0;
49 } 49 }
50 50
51 } // namespace 51 } // namespace
52 52
53 ManagedUserCreationControllerOld::UserCreationContext::UserCreationContext() 53 ManagedUserCreationControllerOld::UserCreationContext::UserCreationContext()
54 : avatar_index(kDummyAvatarIndex), 54 : avatar_index(kDummyAvatarIndex),
55 token_acquired(false), 55 token_acquired(false),
56 token_succesfully_written(false), 56 token_succesfully_written(false),
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 this, 136 this,
137 &ManagedUserCreationControllerOld::CreationTimedOut); 137 &ManagedUserCreationControllerOld::CreationTimedOut);
138 SupervisedUserManager* manager = 138 SupervisedUserManager* manager =
139 UserManager::Get()->GetSupervisedUserManager(); 139 UserManager::Get()->GetSupervisedUserManager();
140 manager->StartCreationTransaction(creation_context_->display_name); 140 manager->StartCreationTransaction(creation_context_->display_name);
141 141
142 creation_context_->local_user_id = manager->GenerateUserId(); 142 creation_context_->local_user_id = manager->GenerateUserId();
143 143
144 if (creation_context_->creation_type == NEW_USER) { 144 if (creation_context_->creation_type == NEW_USER) {
145 creation_context_->sync_user_id = 145 creation_context_->sync_user_id =
146 ManagedUserRegistrationUtility::GenerateNewManagedUserId(); 146 SupervisedUserRegistrationUtility::GenerateNewSupervisedUserId();
147 } 147 }
148 148
149 manager->CreateUserRecord(creation_context_->manager_id, 149 manager->CreateUserRecord(creation_context_->manager_id,
150 creation_context_->local_user_id, 150 creation_context_->local_user_id,
151 creation_context_->sync_user_id, 151 creation_context_->sync_user_id,
152 creation_context_->display_name); 152 creation_context_->display_name);
153 153
154 manager->SetCreationTransactionUserId(creation_context_->local_user_id); 154 manager->SetCreationTransactionUserId(creation_context_->local_user_id);
155 SupervisedUserAuthentication* authentication = manager->GetAuthentication(); 155 SupervisedUserAuthentication* authentication = manager->GetAuthentication();
156 base::DictionaryValue extra; 156 base::DictionaryValue extra;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 UserContext context(creation_context_->local_user_id); 210 UserContext context(creation_context_->local_user_id);
211 context.SetKey(Key(creation_context_->password)); 211 context.SetKey(Key(creation_context_->password));
212 authenticator_->AddMasterKey( 212 authenticator_->AddMasterKey(
213 creation_context_->local_user_id, 213 creation_context_->local_user_id,
214 authentication->TransformKey(context).GetKey()->GetSecret(), 214 authentication->TransformKey(context).GetKey()->GetSecret(),
215 creation_context_->master_key); 215 creation_context_->master_key);
216 } 216 }
217 217
218 void ManagedUserCreationControllerOld::OnAddKeySuccess() { 218 void ManagedUserCreationControllerOld::OnAddKeySuccess() {
219 creation_context_->registration_utility = 219 creation_context_->registration_utility =
220 ManagedUserRegistrationUtility::Create( 220 SupervisedUserRegistrationUtility::Create(
221 creation_context_->manager_profile); 221 creation_context_->manager_profile);
222 222
223 VLOG(1) << "Creating user on server"; 223 VLOG(1) << "Creating user on server";
224 // TODO(antrim) : add password data to sync once API is ready. 224 // TODO(antrim) : add password data to sync once API is ready.
225 // http://crbug.com/316168 225 // http://crbug.com/316168
226 ManagedUserRegistrationInfo info(creation_context_->display_name, 226 SupervisedUserRegistrationInfo info(creation_context_->display_name,
227 creation_context_->avatar_index); 227 creation_context_->avatar_index);
228 info.master_key = creation_context_->master_key; 228 info.master_key = creation_context_->master_key;
229 timeout_timer_.Stop(); 229 timeout_timer_.Stop();
230 creation_context_->registration_utility->Register( 230 creation_context_->registration_utility->Register(
231 creation_context_->sync_user_id, 231 creation_context_->sync_user_id,
232 info, 232 info,
233 base::Bind(&ManagedUserCreationControllerOld::RegistrationCallback, 233 base::Bind(&ManagedUserCreationControllerOld::RegistrationCallback,
234 weak_factory_.GetWeakPtr())); 234 weak_factory_.GetWeakPtr()));
235 } 235 }
236 236
237 void ManagedUserCreationControllerOld::RegistrationCallback( 237 void ManagedUserCreationControllerOld::RegistrationCallback(
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 // Assume that new token is valid. It will be automatically invalidated if 299 // Assume that new token is valid. It will be automatically invalidated if
300 // sync service fails to use it. 300 // sync service fails to use it.
301 UserManager::Get()->SaveUserOAuthStatus(creation_context_->local_user_id, 301 UserManager::Get()->SaveUserOAuthStatus(creation_context_->local_user_id,
302 User::OAUTH2_TOKEN_STATUS_VALID); 302 User::OAUTH2_TOKEN_STATUS_VALID);
303 UserManager::Get()->GetSupervisedUserManager()->CommitCreationTransaction(); 303 UserManager::Get()->GetSupervisedUserManager()->CommitCreationTransaction();
304 if (consumer_) 304 if (consumer_)
305 consumer_->OnCreationSuccess(); 305 consumer_->OnCreationSuccess();
306 } 306 }
307 307
308 } // namespace chromeos 308 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698