Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: chromeos/tpm/tpm_token_loader.cc

Issue 741593002: If easy sign-in is set up, allow TPMTokenLoader to start before login (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chromeos/tpm/tpm_token_loader.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chromeos/tpm/tpm_token_loader.h" 5 #include "chromeos/tpm/tpm_token_loader.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 } 63 }
64 64
65 TPMTokenLoader::TPMTokenLoader(bool for_test) 65 TPMTokenLoader::TPMTokenLoader(bool for_test)
66 : initialized_for_test_(for_test), 66 : initialized_for_test_(for_test),
67 tpm_token_state_(TPM_STATE_UNKNOWN), 67 tpm_token_state_(TPM_STATE_UNKNOWN),
68 tpm_token_info_getter_( 68 tpm_token_info_getter_(
69 TPMTokenInfoGetter::CreateForSystemToken( 69 TPMTokenInfoGetter::CreateForSystemToken(
70 DBusThreadManager::Get()->GetCryptohomeClient(), 70 DBusThreadManager::Get()->GetCryptohomeClient(),
71 base::ThreadTaskRunnerHandle::Get())), 71 base::ThreadTaskRunnerHandle::Get())),
72 tpm_token_slot_id_(-1), 72 tpm_token_slot_id_(-1),
73 can_start_before_login_(false),
73 weak_factory_(this) { 74 weak_factory_(this) {
74 if (!initialized_for_test_ && LoginState::IsInitialized()) 75 if (!initialized_for_test_ && LoginState::IsInitialized())
75 LoginState::Get()->AddObserver(this); 76 LoginState::Get()->AddObserver(this);
76 77
77 if (initialized_for_test_) { 78 if (initialized_for_test_) {
78 tpm_token_state_ = TPM_TOKEN_INITIALIZED; 79 tpm_token_state_ = TPM_TOKEN_INITIALIZED;
79 tpm_user_pin_ = "111111"; 80 tpm_user_pin_ = "111111";
80 } 81 }
81 } 82 }
82 83
83 void TPMTokenLoader::SetCryptoTaskRunner( 84 void TPMTokenLoader::SetCryptoTaskRunner(
84 const scoped_refptr<base::SequencedTaskRunner>& crypto_task_runner) { 85 const scoped_refptr<base::SequencedTaskRunner>& crypto_task_runner) {
85 crypto_task_runner_ = crypto_task_runner; 86 crypto_task_runner_ = crypto_task_runner;
86 MaybeStartTokenInitialization(); 87 MaybeStartTokenInitialization();
87 } 88 }
88 89
90 void TPMTokenLoader::EnsureStarted() {
91 if (can_start_before_login_)
92 return;
93 can_start_before_login_ = true;
94 MaybeStartTokenInitialization();
95 }
96
89 TPMTokenLoader::~TPMTokenLoader() { 97 TPMTokenLoader::~TPMTokenLoader() {
90 if (!initialized_for_test_ && LoginState::IsInitialized()) 98 if (!initialized_for_test_ && LoginState::IsInitialized())
91 LoginState::Get()->RemoveObserver(this); 99 LoginState::Get()->RemoveObserver(this);
92 } 100 }
93 101
94 TPMTokenLoader::TPMTokenStatus TPMTokenLoader::IsTPMTokenEnabled( 102 TPMTokenLoader::TPMTokenStatus TPMTokenLoader::IsTPMTokenEnabled(
95 const TPMReadyCallback& callback) { 103 const TPMReadyCallback& callback) {
96 if (tpm_token_state_ == TPM_TOKEN_INITIALIZED) 104 if (tpm_token_state_ == TPM_TOKEN_INITIALIZED)
97 return TPM_TOKEN_STATUS_ENABLED; 105 return TPM_TOKEN_STATUS_ENABLED;
98 if (!IsTPMLoadingEnabled() || tpm_token_state_ == TPM_DISABLED) 106 if (!IsTPMLoadingEnabled() || tpm_token_state_ == TPM_DISABLED)
(...skipping 13 matching lines...) Expand all
112 } 120 }
113 121
114 void TPMTokenLoader::MaybeStartTokenInitialization() { 122 void TPMTokenLoader::MaybeStartTokenInitialization() {
115 CHECK(thread_checker_.CalledOnValidThread()); 123 CHECK(thread_checker_.CalledOnValidThread());
116 124
117 // This is the entry point to the TPM token initialization process, 125 // This is the entry point to the TPM token initialization process,
118 // which we should do at most once. 126 // which we should do at most once.
119 if (tpm_token_state_ != TPM_STATE_UNKNOWN || !crypto_task_runner_.get()) 127 if (tpm_token_state_ != TPM_STATE_UNKNOWN || !crypto_task_runner_.get())
120 return; 128 return;
121 129
122 if (!LoginState::IsInitialized()) 130 bool start_initialization =
123 return; 131 (LoginState::IsInitialized() && LoginState::Get()->IsUserLoggedIn()) ||
124 132 can_start_before_login_;
125 bool start_initialization = LoginState::Get()->IsUserLoggedIn();
126 133
127 VLOG(1) << "StartTokenInitialization: " << start_initialization; 134 VLOG(1) << "StartTokenInitialization: " << start_initialization;
128 if (!start_initialization) 135 if (!start_initialization)
129 return; 136 return;
130 137
131 if (!IsTPMLoadingEnabled()) 138 if (!IsTPMLoadingEnabled())
132 tpm_token_state_ = TPM_DISABLED; 139 tpm_token_state_ = TPM_DISABLED;
133 140
134 ContinueTokenInitialization(); 141 ContinueTokenInitialization();
135 142
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 } 229 }
223 tpm_ready_callback_list_.clear(); 230 tpm_ready_callback_list_.clear();
224 } 231 }
225 232
226 void TPMTokenLoader::LoggedInStateChanged() { 233 void TPMTokenLoader::LoggedInStateChanged() {
227 VLOG(1) << "LoggedInStateChanged"; 234 VLOG(1) << "LoggedInStateChanged";
228 MaybeStartTokenInitialization(); 235 MaybeStartTokenInitialization();
229 } 236 }
230 237
231 } // namespace chromeos 238 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/tpm/tpm_token_loader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698