| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/sync/supervised_user_signin_manager_wrapper.h" | 5 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h" |
| 6 | 6 |
| 7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "components/signin/core/browser/signin_manager_base.h" | 8 #include "components/signin/core/browser/signin_manager_base.h" |
| 9 #include "google_apis/gaia/gaia_constants.h" | 9 #include "google_apis/gaia/gaia_constants.h" |
| 10 | 10 |
| 11 #if defined(ENABLE_MANAGED_USERS) | 11 #if defined(ENABLE_MANAGED_USERS) |
| 12 #include "chrome/browser/supervised_user/supervised_user_constants.h" | 12 #include "chrome/browser/supervised_user/supervised_user_constants.h" |
| 13 #endif | 13 #endif |
| 14 | 14 |
| 15 SupervisedUserSigninManagerWrapper::SupervisedUserSigninManagerWrapper( | 15 SupervisedUserSigninManagerWrapper::SupervisedUserSigninManagerWrapper( |
| 16 Profile* profile, | 16 Profile* profile, |
| 17 SigninManagerBase* original) | 17 SigninManagerBase* original) |
| 18 : profile_(profile), original_(original) {} | 18 : profile_(profile), original_(original) {} |
| 19 | 19 |
| 20 SupervisedUserSigninManagerWrapper::~SupervisedUserSigninManagerWrapper() { | 20 SupervisedUserSigninManagerWrapper::~SupervisedUserSigninManagerWrapper() { |
| 21 } | 21 } |
| 22 | 22 |
| 23 SigninManagerBase* SupervisedUserSigninManagerWrapper::GetOriginal() { | 23 SigninManagerBase* SupervisedUserSigninManagerWrapper::GetOriginal() { |
| 24 return original_; | 24 return original_; |
| 25 } | 25 } |
| 26 | 26 |
| 27 std::string SupervisedUserSigninManagerWrapper::GetEffectiveUsername() const { | 27 std::string SupervisedUserSigninManagerWrapper::GetEffectiveUsername() const { |
| 28 const std::string& auth_username = original_->GetAuthenticatedUsername(); | |
| 29 #if defined(ENABLE_MANAGED_USERS) | 28 #if defined(ENABLE_MANAGED_USERS) |
| 30 if (auth_username.empty() && profile_->IsSupervised()) | 29 if (!original_->IsAuthenticated() && profile_->IsSupervised()) |
| 31 return supervised_users::kSupervisedUserPseudoEmail; | 30 return supervised_users::kSupervisedUserPseudoEmail; |
| 32 #endif | 31 #endif |
| 33 return auth_username; | 32 return original_->GetAuthenticatedUsername(); |
| 34 } | 33 } |
| 35 | 34 |
| 36 std::string SupervisedUserSigninManagerWrapper::GetAccountIdToUse() const { | 35 std::string SupervisedUserSigninManagerWrapper::GetAccountIdToUse() const { |
| 37 #if defined(ENABLE_MANAGED_USERS) | 36 #if defined(ENABLE_MANAGED_USERS) |
| 38 if (!original_->IsAuthenticated() && profile_->IsSupervised()) | 37 if (!original_->IsAuthenticated() && profile_->IsSupervised()) |
| 39 return supervised_users::kSupervisedUserPseudoEmail; | 38 return supervised_users::kSupervisedUserPseudoEmail; |
| 40 #endif | 39 #endif |
| 41 return original_->GetAuthenticatedAccountId(); | 40 return original_->GetAuthenticatedAccountId(); |
| 42 } | 41 } |
| 43 | 42 |
| 44 std::string SupervisedUserSigninManagerWrapper::GetSyncScopeToUse() const { | 43 std::string SupervisedUserSigninManagerWrapper::GetSyncScopeToUse() const { |
| 45 #if defined(ENABLE_MANAGED_USERS) | 44 #if defined(ENABLE_MANAGED_USERS) |
| 46 if (!original_->IsAuthenticated() && profile_->IsSupervised()) | 45 if (!original_->IsAuthenticated() && profile_->IsSupervised()) |
| 47 return GaiaConstants::kChromeSyncSupervisedOAuth2Scope; | 46 return GaiaConstants::kChromeSyncSupervisedOAuth2Scope; |
| 48 #endif | 47 #endif |
| 49 return GaiaConstants::kChromeSyncOAuth2Scope; | 48 return GaiaConstants::kChromeSyncOAuth2Scope; |
| 50 } | 49 } |
| OLD | NEW |