| 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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 } | 47 } |
| 48 | 48 |
| 49 ManagedUserRegistrationUtility::~ManagedUserRegistrationUtility() { | 49 ManagedUserRegistrationUtility::~ManagedUserRegistrationUtility() { |
| 50 managed_user_sync_service_->RemoveObserver(this); | 50 managed_user_sync_service_->RemoveObserver(this); |
| 51 CancelPendingRegistration(); | 51 CancelPendingRegistration(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 // static | 54 // static |
| 55 scoped_ptr<ManagedUserRegistrationUtility> | 55 scoped_ptr<ManagedUserRegistrationUtility> |
| 56 ManagedUserRegistrationUtility::Create(Profile* profile) { | 56 ManagedUserRegistrationUtility::Create(Profile* profile) { |
| 57 ProfileOAuth2TokenService* token_service = |
| 58 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
| 57 scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher = | 59 scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher = |
| 58 ManagedUserRefreshTokenFetcher::Create( | 60 ManagedUserRefreshTokenFetcher::Create( |
| 59 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), | 61 token_service, |
| 62 token_service->GetPrimaryAccountId(), |
| 60 profile->GetRequestContext()); | 63 profile->GetRequestContext()); |
| 61 ManagedUserSyncService* managed_user_sync_service = | 64 ManagedUserSyncService* managed_user_sync_service = |
| 62 ManagedUserSyncServiceFactory::GetForProfile(profile); | 65 ManagedUserSyncServiceFactory::GetForProfile(profile); |
| 63 return make_scoped_ptr(new ManagedUserRegistrationUtility( | 66 return make_scoped_ptr(new ManagedUserRegistrationUtility( |
| 64 profile->GetPrefs(), token_fetcher.Pass(), managed_user_sync_service)); | 67 profile->GetPrefs(), token_fetcher.Pass(), managed_user_sync_service)); |
| 65 } | 68 } |
| 66 | 69 |
| 67 // static | 70 // static |
| 68 std::string ManagedUserRegistrationUtility::GenerateNewManagedUserId() { | 71 std::string ManagedUserRegistrationUtility::GenerateNewManagedUserId() { |
| 69 std::string new_managed_user_id; | 72 std::string new_managed_user_id; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 bool success = | 174 bool success = |
| 172 update->RemoveWithoutPathExpansion(pending_managed_user_id_, NULL); | 175 update->RemoveWithoutPathExpansion(pending_managed_user_id_, NULL); |
| 173 DCHECK(success); | 176 DCHECK(success); |
| 174 managed_user_sync_service_->DeleteManagedUser(pending_managed_user_id_); | 177 managed_user_sync_service_->DeleteManagedUser(pending_managed_user_id_); |
| 175 } | 178 } |
| 176 | 179 |
| 177 if (run_callback) | 180 if (run_callback) |
| 178 callback_.Run(error, pending_managed_user_token_); | 181 callback_.Run(error, pending_managed_user_token_); |
| 179 callback_.Reset(); | 182 callback_.Reset(); |
| 180 } | 183 } |
| OLD | NEW |