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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 ManagedUserSyncServiceFactory::GetForProfile(profile); | 143 ManagedUserSyncServiceFactory::GetForProfile(profile); |
144 return make_scoped_ptr(ManagedUserRegistrationUtility::CreateImpl( | 144 return make_scoped_ptr(ManagedUserRegistrationUtility::CreateImpl( |
145 profile->GetPrefs(), | 145 profile->GetPrefs(), |
146 token_fetcher.Pass(), | 146 token_fetcher.Pass(), |
147 managed_user_sync_service)); | 147 managed_user_sync_service)); |
148 } | 148 } |
149 | 149 |
150 // static | 150 // static |
151 std::string ManagedUserRegistrationUtility::GenerateNewManagedUserId() { | 151 std::string ManagedUserRegistrationUtility::GenerateNewManagedUserId() { |
152 std::string new_managed_user_id; | 152 std::string new_managed_user_id; |
153 bool success = base::Base64Encode(base::RandBytesAsString(8), | 153 base::Base64Encode(base::RandBytesAsString(8), &new_managed_user_id); |
154 &new_managed_user_id); | |
155 DCHECK(success); | |
156 return new_managed_user_id; | 154 return new_managed_user_id; |
157 } | 155 } |
158 | 156 |
159 // static | 157 // static |
160 void ManagedUserRegistrationUtility::SetUtilityForTests( | 158 void ManagedUserRegistrationUtility::SetUtilityForTests( |
161 ManagedUserRegistrationUtility* utility) { | 159 ManagedUserRegistrationUtility* utility) { |
162 if (g_instance_for_tests) | 160 if (g_instance_for_tests) |
163 delete g_instance_for_tests; | 161 delete g_instance_for_tests; |
164 g_instance_for_tests = utility; | 162 g_instance_for_tests = utility; |
165 } | 163 } |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 pending_managed_user_id_); | 305 pending_managed_user_id_); |
308 } | 306 } |
309 } | 307 } |
310 | 308 |
311 if (run_callback) | 309 if (run_callback) |
312 callback_.Run(error, pending_managed_user_token_); | 310 callback_.Run(error, pending_managed_user_token_); |
313 callback_.Reset(); | 311 callback_.Reset(); |
314 } | 312 } |
315 | 313 |
316 } // namespace | 314 } // namespace |
OLD | NEW |