| 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_stub.h" | 5 #include "chrome/browser/supervised_user/supervised_user_registration_utility_st
ub.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "google_apis/gaia/gaia_urls.h" | 10 #include "google_apis/gaia/gaia_urls.h" |
| 11 #include "google_apis/gaia/google_service_auth_error.h" | 11 #include "google_apis/gaia/google_service_auth_error.h" |
| 12 | 12 |
| 13 ManagedUserRegistrationUtilityStub::ManagedUserRegistrationUtilityStub() | 13 SupervisedUserRegistrationUtilityStub::SupervisedUserRegistrationUtilityStub() |
| 14 : register_was_called_(false) { | 14 : register_was_called_(false) { |
| 15 } | 15 } |
| 16 | 16 |
| 17 ManagedUserRegistrationUtilityStub::~ManagedUserRegistrationUtilityStub() { | 17 SupervisedUserRegistrationUtilityStub:: |
| 18 ~SupervisedUserRegistrationUtilityStub() { |
| 18 } | 19 } |
| 19 | 20 |
| 20 void ManagedUserRegistrationUtilityStub::Register( | 21 void SupervisedUserRegistrationUtilityStub::Register( |
| 21 const std::string& managed_user_id, | 22 const std::string& supervised_user_id, |
| 22 const ManagedUserRegistrationInfo& info, | 23 const SupervisedUserRegistrationInfo& info, |
| 23 const RegistrationCallback& callback) { | 24 const RegistrationCallback& callback) { |
| 24 DCHECK(!register_was_called_); | 25 DCHECK(!register_was_called_); |
| 25 register_was_called_ = true; | 26 register_was_called_ = true; |
| 26 callback_ = callback; | 27 callback_ = callback; |
| 27 managed_user_id_ = managed_user_id; | 28 supervised_user_id_ = supervised_user_id; |
| 28 display_name_ = info.name; | 29 display_name_ = info.name; |
| 29 master_key_ = info.master_key; | 30 master_key_ = info.master_key; |
| 30 } | 31 } |
| 31 | 32 |
| 32 void ManagedUserRegistrationUtilityStub::RunSuccessCallback( | 33 void SupervisedUserRegistrationUtilityStub::RunSuccessCallback( |
| 33 const std::string& token) { | 34 const std::string& token) { |
| 34 if (callback_.is_null()) | 35 if (callback_.is_null()) |
| 35 return; | 36 return; |
| 36 callback_.Run(GoogleServiceAuthError(GoogleServiceAuthError::NONE), token); | 37 callback_.Run(GoogleServiceAuthError(GoogleServiceAuthError::NONE), token); |
| 37 callback_.Reset(); | 38 callback_.Reset(); |
| 38 } | 39 } |
| 39 | 40 |
| 40 void ManagedUserRegistrationUtilityStub::RunFailureCallback( | 41 void SupervisedUserRegistrationUtilityStub::RunFailureCallback( |
| 41 const GoogleServiceAuthError::State state) { | 42 const GoogleServiceAuthError::State state) { |
| 42 if (callback_.is_null()) | 43 if (callback_.is_null()) |
| 43 return; | 44 return; |
| 44 GoogleServiceAuthError error(state); | 45 GoogleServiceAuthError error(state); |
| 45 callback_.Run(error, std::string()); | 46 callback_.Run(error, std::string()); |
| 46 callback_.Reset(); | 47 callback_.Reset(); |
| 47 } | 48 } |
| OLD | NEW |