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_service.h" | 5 #include "chrome/browser/managed_mode/managed_user_registration_service.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/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 SyncError error = | 100 SyncError error = |
101 sync_processor_->ProcessSyncChanges(FROM_HERE, change_list); | 101 sync_processor_->ProcessSyncChanges(FROM_HERE, change_list); |
102 DCHECK(!error.IsSet()) << error.ToString(); | 102 DCHECK(!error.IsSet()) << error.ToString(); |
103 } | 103 } |
104 | 104 |
105 callback_ = callback; | 105 callback_ = callback; |
106 OnReceivedToken("abcdef"); // TODO(bauerb): This is a stub implementation. | 106 OnReceivedToken("abcdef"); // TODO(bauerb): This is a stub implementation. |
107 } | 107 } |
108 | 108 |
109 ProfileManager::CreateCallback | 109 ProfileManager::CreateCallback |
110 ManagedUserRegistrationService::GetRegistrationAndInitCallback() { | 110 ManagedUserRegistrationService::GetRegistrationAndInitCallback( |
111 const ProfileManager::CreateCallback& callback) { | |
Bernhard Bauer
2013/06/03 10:52:47
I wonder if we still need this now that our client
Pam (message me for reviews)
2013/06/03 13:39:28
Cleaned up following our live discussion. Thanks,
| |
111 return base::Bind(&ManagedUserRegistrationService::OnProfileCreated, | 112 return base::Bind(&ManagedUserRegistrationService::OnProfileCreated, |
112 weak_ptr_factory_.GetWeakPtr()); | 113 weak_ptr_factory_.GetWeakPtr(), callback); |
113 } | 114 } |
114 | 115 |
115 void ManagedUserRegistrationService::Shutdown() { | 116 void ManagedUserRegistrationService::Shutdown() { |
116 CancelPendingRegistration(); | 117 CancelPendingRegistration(); |
117 } | 118 } |
118 | 119 |
119 SyncMergeResult ManagedUserRegistrationService::MergeDataAndStartSyncing( | 120 SyncMergeResult ManagedUserRegistrationService::MergeDataAndStartSyncing( |
120 ModelType type, | 121 ModelType type, |
121 const SyncDataList& initial_sync_data, | 122 const SyncDataList& initial_sync_data, |
122 scoped_ptr<SyncChangeProcessor> sync_processor, | 123 scoped_ptr<SyncChangeProcessor> sync_processor, |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
303 return; | 304 return; |
304 | 305 |
305 callback_.Run(error, pending_managed_user_token_); | 306 callback_.Run(error, pending_managed_user_token_); |
306 callback_.Reset(); | 307 callback_.Reset(); |
307 pending_managed_user_token_.clear(); | 308 pending_managed_user_token_.clear(); |
308 pending_managed_user_id_.clear(); | 309 pending_managed_user_id_.clear(); |
309 pending_managed_user_acknowledged_ = false; | 310 pending_managed_user_acknowledged_ = false; |
310 } | 311 } |
311 | 312 |
312 void ManagedUserRegistrationService::OnProfileCreated( | 313 void ManagedUserRegistrationService::OnProfileCreated( |
314 const ProfileManager::CreateCallback& callback, | |
313 Profile* profile, | 315 Profile* profile, |
314 Profile::CreateStatus status) { | 316 Profile::CreateStatus status) { |
315 // We're being called back twice: once after the profile has been created on | 317 // We're being called back twice: once after the profile has been created on |
316 // disk, and once after all the profile services (including the | 318 // disk, and once after all the profile services (including the |
317 // ManagedUserService) have been initialized. Ignore the first one. | 319 // ManagedUserService) have been initialized. Ignore the first one, as well as |
320 // any failure statuses. | |
318 if (status != Profile::CREATE_STATUS_INITIALIZED) | 321 if (status != Profile::CREATE_STATUS_INITIALIZED) |
319 return; | 322 return; |
320 | 323 |
321 ManagedUserService* managed_user_service = | 324 ManagedUserService* managed_user_service = |
322 ManagedUserServiceFactory::GetForProfile(profile); | 325 ManagedUserServiceFactory::GetForProfile(profile); |
323 DCHECK(managed_user_service->ProfileIsManaged()); | 326 DCHECK(managed_user_service->ProfileIsManaged()); |
324 managed_user_service->RegisterAndInitSync(this); | 327 managed_user_service->RegisterAndInitSync(this, callback); |
325 } | 328 } |
OLD | NEW |