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
3 // found in the LICENSE file.
5 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h"
7 #include "chrome/browser/profiles/profile.h"
8 #include "components/signin/core/browser/signin_manager_base.h"
9 #include "google_apis/gaia/gaia_constants.h"
11 #if defined(ENABLE_MANAGED_USERS)
12 #include "chrome/browser/supervised_user/supervised_user_constants.h"
15 SupervisedUserSigninManagerWrapper::SupervisedUserSigninManagerWrapper(
17 SigninManagerBase
* original
)
18 : profile_(profile
), original_(original
) {}
20 SupervisedUserSigninManagerWrapper::~SupervisedUserSigninManagerWrapper() {
23 SigninManagerBase
* SupervisedUserSigninManagerWrapper::GetOriginal() {
27 std::string
SupervisedUserSigninManagerWrapper::GetEffectiveUsername() const {
28 const std::string
& auth_username
= original_
->GetAuthenticatedUsername();
29 #if defined(ENABLE_MANAGED_USERS)
30 if (auth_username
.empty() && profile_
->IsSupervised())
31 return supervised_users::kSupervisedUserPseudoEmail
;
36 std::string
SupervisedUserSigninManagerWrapper::GetAccountIdToUse() const {
37 #if defined(ENABLE_MANAGED_USERS)
38 if (!original_
->IsAuthenticated() && profile_
->IsSupervised())
39 return supervised_users::kSupervisedUserPseudoEmail
;
41 return original_
->GetAuthenticatedAccountId();
44 std::string
SupervisedUserSigninManagerWrapper::GetSyncScopeToUse() const {
45 #if defined(ENABLE_MANAGED_USERS)
46 if (!original_
->IsAuthenticated() && profile_
->IsSupervised())
47 return GaiaConstants::kChromeSyncSupervisedOAuth2Scope
;
49 return GaiaConstants::kChromeSyncOAuth2Scope
;