OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/managed_mode/managed_user_registration_utility.h" | 5 #include "chrome/browser/managed_mode/managed_user_registration_utility.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 void ManagedUserRegistrationUtilityImpl::Register( | 223 void ManagedUserRegistrationUtilityImpl::Register( |
224 const std::string& managed_user_id, | 224 const std::string& managed_user_id, |
225 const ManagedUserRegistrationInfo& info, | 225 const ManagedUserRegistrationInfo& info, |
226 const RegistrationCallback& callback) { | 226 const RegistrationCallback& callback) { |
227 DCHECK(pending_managed_user_id_.empty()); | 227 DCHECK(pending_managed_user_id_.empty()); |
228 callback_ = callback; | 228 callback_ = callback; |
229 pending_managed_user_id_ = managed_user_id; | 229 pending_managed_user_id_ = managed_user_id; |
230 | 230 |
231 bool need_password_update = !info.password_data.empty(); | 231 bool need_password_update = !info.password_data.empty(); |
232 const base::DictionaryValue* dict = | 232 const base::DictionaryValue* dict = |
233 prefs_->GetDictionary(prefs::kManagedUsers); | 233 prefs_->GetDictionary(prefs::kSupervisedUsers); |
234 is_existing_managed_user_ = dict->HasKey(managed_user_id); | 234 is_existing_managed_user_ = dict->HasKey(managed_user_id); |
235 if (!is_existing_managed_user_) { | 235 if (!is_existing_managed_user_) { |
236 managed_user_sync_service_->AddManagedUser(pending_managed_user_id_, | 236 managed_user_sync_service_->AddManagedUser(pending_managed_user_id_, |
237 base::UTF16ToUTF8(info.name), | 237 base::UTF16ToUTF8(info.name), |
238 info.master_key, | 238 info.master_key, |
239 info.password_signature_key, | 239 info.password_signature_key, |
240 info.password_encryption_key, | 240 info.password_encryption_key, |
241 info.avatar_index); | 241 info.avatar_index); |
242 } else { | 242 } else { |
243 const base::DictionaryValue* value = NULL; | 243 const base::DictionaryValue* value = NULL; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 return; | 344 return; |
345 } | 345 } |
346 | 346 |
347 DCHECK(!token.empty()); | 347 DCHECK(!token.empty()); |
348 pending_managed_user_token_ = token; | 348 pending_managed_user_token_ = token; |
349 CompleteRegistrationIfReady(); | 349 CompleteRegistrationIfReady(); |
350 } | 350 } |
351 | 351 |
352 void ManagedUserRegistrationUtilityImpl::CompleteRegistrationIfReady() { | 352 void ManagedUserRegistrationUtilityImpl::CompleteRegistrationIfReady() { |
353 bool skip_check = CommandLine::ForCurrentProcess()->HasSwitch( | 353 bool skip_check = CommandLine::ForCurrentProcess()->HasSwitch( |
354 switches::kNoManagedUserAcknowledgmentCheck); | 354 switches::kNoSupervisedUserAcknowledgmentCheck); |
355 | 355 |
356 if (!pending_managed_user_acknowledged_ && !skip_check) | 356 if (!pending_managed_user_acknowledged_ && !skip_check) |
357 return; | 357 return; |
358 if (password_update_ && !skip_check) | 358 if (password_update_ && !skip_check) |
359 return; | 359 return; |
360 if (pending_managed_user_token_.empty()) | 360 if (pending_managed_user_token_.empty()) |
361 return; | 361 return; |
362 | 362 |
363 GoogleServiceAuthError error(GoogleServiceAuthError::NONE); | 363 GoogleServiceAuthError error(GoogleServiceAuthError::NONE); |
364 CompleteRegistration(true, error); | 364 CompleteRegistration(true, error); |
(...skipping 28 matching lines...) Expand all Loading... |
393 pending_managed_user_id_); | 393 pending_managed_user_id_); |
394 } | 394 } |
395 } | 395 } |
396 | 396 |
397 if (run_callback) | 397 if (run_callback) |
398 callback_.Run(error, pending_managed_user_token_); | 398 callback_.Run(error, pending_managed_user_token_); |
399 callback_.Reset(); | 399 callback_.Reset(); |
400 } | 400 } |
401 | 401 |
402 } // namespace | 402 } // namespace |
OLD | NEW |