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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 pending_managed_user_id_, base::UTF16ToUTF8(name), false))); | 99 pending_managed_user_id_, base::UTF16ToUTF8(name), false))); |
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 | |
110 ManagedUserRegistrationService::GetRegistrationAndInitCallback() { | |
111 return base::Bind(&ManagedUserRegistrationService::OnProfileCreated, | |
112 weak_ptr_factory_.GetWeakPtr()); | |
113 } | |
114 | |
115 void ManagedUserRegistrationService::Shutdown() { | 109 void ManagedUserRegistrationService::Shutdown() { |
116 CancelPendingRegistration(); | 110 CancelPendingRegistration(); |
117 } | 111 } |
118 | 112 |
119 SyncMergeResult ManagedUserRegistrationService::MergeDataAndStartSyncing( | 113 SyncMergeResult ManagedUserRegistrationService::MergeDataAndStartSyncing( |
120 ModelType type, | 114 ModelType type, |
121 const SyncDataList& initial_sync_data, | 115 const SyncDataList& initial_sync_data, |
122 scoped_ptr<SyncChangeProcessor> sync_processor, | 116 scoped_ptr<SyncChangeProcessor> sync_processor, |
123 scoped_ptr<SyncErrorFactory> error_handler) { | 117 scoped_ptr<SyncErrorFactory> error_handler) { |
124 DCHECK_EQ(MANAGED_USERS, type); | 118 DCHECK_EQ(MANAGED_USERS, type); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 const GoogleServiceAuthError& error) { | 295 const GoogleServiceAuthError& error) { |
302 if (callback_.is_null()) | 296 if (callback_.is_null()) |
303 return; | 297 return; |
304 | 298 |
305 callback_.Run(error, pending_managed_user_token_); | 299 callback_.Run(error, pending_managed_user_token_); |
306 callback_.Reset(); | 300 callback_.Reset(); |
307 pending_managed_user_token_.clear(); | 301 pending_managed_user_token_.clear(); |
308 pending_managed_user_id_.clear(); | 302 pending_managed_user_id_.clear(); |
309 pending_managed_user_acknowledged_ = false; | 303 pending_managed_user_acknowledged_ = false; |
310 } | 304 } |
311 | |
312 void ManagedUserRegistrationService::OnProfileCreated( | |
313 Profile* profile, | |
314 Profile::CreateStatus status) { | |
315 // 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 | |
317 // ManagedUserService) have been initialized. Ignore the first one. | |
318 if (status != Profile::CREATE_STATUS_INITIALIZED) | |
319 return; | |
320 | |
321 ManagedUserService* managed_user_service = | |
322 ManagedUserServiceFactory::GetForProfile(profile); | |
323 DCHECK(managed_user_service->ProfileIsManaged()); | |
324 managed_user_service->RegisterAndInitSync(this); | |
325 } | |
OLD | NEW |