| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 std::string pending_managed_user_token_; | 100 std::string pending_managed_user_token_; |
| 101 bool pending_managed_user_acknowledged_; | 101 bool pending_managed_user_acknowledged_; |
| 102 bool is_existing_managed_user_; | 102 bool is_existing_managed_user_; |
| 103 RegistrationCallback callback_; | 103 RegistrationCallback callback_; |
| 104 | 104 |
| 105 DISALLOW_COPY_AND_ASSIGN(ManagedUserRegistrationUtilityImpl); | 105 DISALLOW_COPY_AND_ASSIGN(ManagedUserRegistrationUtilityImpl); |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 } // namespace | 108 } // namespace |
| 109 | 109 |
| 110 ManagedUserRegistrationInfo::ManagedUserRegistrationInfo(const string16& name) | 110 ManagedUserRegistrationInfo::ManagedUserRegistrationInfo(const string16& name, |
| 111 : name(name) { | 111 int avatar_index) |
| 112 : avatar_index(avatar_index), |
| 113 name(name) { |
| 112 } | 114 } |
| 113 | 115 |
| 114 ScopedTestingManagedUserRegistrationUtility:: | 116 ScopedTestingManagedUserRegistrationUtility:: |
| 115 ScopedTestingManagedUserRegistrationUtility( | 117 ScopedTestingManagedUserRegistrationUtility( |
| 116 ManagedUserRegistrationUtility* instance) { | 118 ManagedUserRegistrationUtility* instance) { |
| 117 ManagedUserRegistrationUtility::SetUtilityForTests(instance); | 119 ManagedUserRegistrationUtility::SetUtilityForTests(instance); |
| 118 } | 120 } |
| 119 | 121 |
| 120 ScopedTestingManagedUserRegistrationUtility:: | 122 ScopedTestingManagedUserRegistrationUtility:: |
| 121 ~ScopedTestingManagedUserRegistrationUtility() { | 123 ~ScopedTestingManagedUserRegistrationUtility() { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 const RegistrationCallback& callback) { | 197 const RegistrationCallback& callback) { |
| 196 DCHECK(pending_managed_user_id_.empty()); | 198 DCHECK(pending_managed_user_id_.empty()); |
| 197 callback_ = callback; | 199 callback_ = callback; |
| 198 pending_managed_user_id_ = managed_user_id; | 200 pending_managed_user_id_ = managed_user_id; |
| 199 | 201 |
| 200 const DictionaryValue* dict = prefs_->GetDictionary(prefs::kManagedUsers); | 202 const DictionaryValue* dict = prefs_->GetDictionary(prefs::kManagedUsers); |
| 201 is_existing_managed_user_ = dict->HasKey(managed_user_id); | 203 is_existing_managed_user_ = dict->HasKey(managed_user_id); |
| 202 if (!is_existing_managed_user_) { | 204 if (!is_existing_managed_user_) { |
| 203 managed_user_sync_service_->AddManagedUser(pending_managed_user_id_, | 205 managed_user_sync_service_->AddManagedUser(pending_managed_user_id_, |
| 204 base::UTF16ToUTF8(info.name), | 206 base::UTF16ToUTF8(info.name), |
| 205 info.master_key); | 207 info.master_key, |
| 208 info.avatar_index); |
| 206 } else { | 209 } else { |
| 207 // User already exists, don't wait for acknowledgment. | 210 // User already exists, don't wait for acknowledgment. |
| 208 OnManagedUserAcknowledged(managed_user_id); | 211 OnManagedUserAcknowledged(managed_user_id); |
| 209 } | 212 } |
| 210 | 213 |
| 211 browser_sync::DeviceInfo::GetClientName( | 214 browser_sync::DeviceInfo::GetClientName( |
| 212 base::Bind(&ManagedUserRegistrationUtilityImpl::FetchToken, | 215 base::Bind(&ManagedUserRegistrationUtilityImpl::FetchToken, |
| 213 weak_ptr_factory_.GetWeakPtr())); | 216 weak_ptr_factory_.GetWeakPtr())); |
| 214 } | 217 } |
| 215 | 218 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 DCHECK(success); | 294 DCHECK(success); |
| 292 managed_user_sync_service_->DeleteManagedUser(pending_managed_user_id_); | 295 managed_user_sync_service_->DeleteManagedUser(pending_managed_user_id_); |
| 293 } | 296 } |
| 294 | 297 |
| 295 if (run_callback) | 298 if (run_callback) |
| 296 callback_.Run(error, pending_managed_user_token_); | 299 callback_.Run(error, pending_managed_user_token_); |
| 297 callback_.Reset(); | 300 callback_.Reset(); |
| 298 } | 301 } |
| 299 | 302 |
| 300 } // namespace | 303 } // namespace |
| OLD | NEW |