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