Home | History | Annotate | Download | only in sync
      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.
      4 
      5 #include "chrome/browser/sync/managed_user_signin_manager_wrapper.h"
      6 
      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"
     10 
     11 #if defined(ENABLE_MANAGED_USERS)
     12 #include "chrome/browser/supervised_user/supervised_user_constants.h"
     13 #endif
     14 
     15 ManagedUserSigninManagerWrapper::ManagedUserSigninManagerWrapper(
     16     Profile* profile,
     17     SigninManagerBase* original)
     18     : profile_(profile), original_(original) {}
     19 
     20 ManagedUserSigninManagerWrapper::~ManagedUserSigninManagerWrapper() {
     21 }
     22 
     23 SigninManagerBase* ManagedUserSigninManagerWrapper::GetOriginal() {
     24   return original_;
     25 }
     26 
     27 std::string ManagedUserSigninManagerWrapper::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;
     32 #endif
     33   return auth_username;
     34 }
     35 
     36 std::string ManagedUserSigninManagerWrapper::GetAccountIdToUse() const {
     37   const std::string& auth_account = original_->GetAuthenticatedAccountId();
     38 #if defined(ENABLE_MANAGED_USERS)
     39   if (auth_account.empty() && profile_->IsSupervised())
     40     return supervised_users::kSupervisedUserPseudoEmail;
     41 #endif
     42   return auth_account;
     43 }
     44 
     45 std::string ManagedUserSigninManagerWrapper::GetSyncScopeToUse() const {
     46 #if defined(ENABLE_MANAGED_USERS)
     47   const std::string& auth_account = original_->GetAuthenticatedAccountId();
     48   if (auth_account.empty() && profile_->IsSupervised())
     49     return GaiaConstants::kChromeSyncSupervisedOAuth2Scope;
     50 #endif
     51   return GaiaConstants::kChromeSyncOAuth2Scope;
     52 }
     53