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/chromeos/login/auth/chrome_cryptohome_authenticator.h" 6 7 #include "base/thread_task_runner_handle.h" 8 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" 9 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_factory.h" 10 #include "chrome/browser/chromeos/settings/cros_settings.h" 11 #include "chromeos/login/login_state.h" 12 #include "components/ownership/owner_key_util.h" 13 #include "components/user_manager/user_manager.h" 14 #include "content/public/browser/browser_thread.h" 15 16 using content::BrowserThread; 17 18 namespace chromeos { 19 ChromeCryptohomeAuthenticator(AuthStatusConsumer * consumer)20ChromeCryptohomeAuthenticator::ChromeCryptohomeAuthenticator( 21 AuthStatusConsumer* consumer) 22 : CryptohomeAuthenticator(base::ThreadTaskRunnerHandle::Get(), consumer) { 23 } 24 ~ChromeCryptohomeAuthenticator()25ChromeCryptohomeAuthenticator::~ChromeCryptohomeAuthenticator() { 26 } 27 IsKnownUser(const UserContext & context)28bool ChromeCryptohomeAuthenticator::IsKnownUser(const UserContext& context) { 29 return user_manager::UserManager::Get()->IsKnownUser(context.GetUserID()); 30 } 31 IsSafeMode()32bool ChromeCryptohomeAuthenticator::IsSafeMode() { 33 bool is_safe_mode = false; 34 CrosSettings::Get()->GetBoolean(kPolicyMissingMitigationMode, &is_safe_mode); 35 return is_safe_mode; 36 } 37 CheckSafeModeOwnership(const UserContext & context,const IsOwnerCallback & callback)38void ChromeCryptohomeAuthenticator::CheckSafeModeOwnership( 39 const UserContext& context, 40 const IsOwnerCallback& callback) { 41 // |IsOwnerForSafeModeAsync| expects logged in state to be 42 // LOGGED_IN_SAFE_MODE. 43 if (LoginState::IsInitialized()) { 44 LoginState::Get()->SetLoggedInState(LoginState::LOGGED_IN_SAFE_MODE, 45 LoginState::LOGGED_IN_USER_NONE); 46 } 47 48 OwnerSettingsServiceChromeOS::IsOwnerForSafeModeAsync( 49 context.GetUserIDHash(), 50 OwnerSettingsServiceChromeOSFactory::GetInstance()->GetOwnerKeyUtil(), 51 callback); 52 } 53 54 } // namespace chromeos 55