Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / chromeos / login / auth / chrome_cryptohome_authenticator.cc
blob97b24d2138f003d6841adac7feef0a7323a313ae
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/chromeos/login/auth/chrome_cryptohome_authenticator.h"
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"
16 using content::BrowserThread;
18 namespace chromeos {
20 ChromeCryptohomeAuthenticator::ChromeCryptohomeAuthenticator(
21 AuthStatusConsumer* consumer)
22 : CryptohomeAuthenticator(base::ThreadTaskRunnerHandle::Get(), consumer) {
25 ChromeCryptohomeAuthenticator::~ChromeCryptohomeAuthenticator() {
28 bool ChromeCryptohomeAuthenticator::IsKnownUser(const UserContext& context) {
29 return user_manager::UserManager::Get()->IsKnownUser(context.GetUserID());
32 bool ChromeCryptohomeAuthenticator::IsSafeMode() {
33 bool is_safe_mode = false;
34 CrosSettings::Get()->GetBoolean(kPolicyMissingMitigationMode, &is_safe_mode);
35 return is_safe_mode;
38 void 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);
48 OwnerSettingsServiceChromeOS::IsOwnerForSafeModeAsync(
49 context.GetUserIDHash(),
50 OwnerSettingsServiceChromeOSFactory::GetInstance()->GetOwnerKeyUtil(),
51 callback);
54 } // namespace chromeos