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

Side by Side Diff: chrome/browser/signin/easy_unlock_service.cc

Issue 877033005: Use a stable device-user identifier for CryptAuth enrollments. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months 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
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 "chrome/browser/signin/easy_unlock_service.h" 5 #include "chrome/browser/signin/easy_unlock_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/guid.h"
9 #include "base/logging.h" 10 #include "base/logging.h"
10 #include "base/metrics/histogram_macros.h" 11 #include "base/metrics/histogram_macros.h"
11 #include "base/prefs/pref_registry_simple.h" 12 #include "base/prefs/pref_registry_simple.h"
12 #include "base/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
13 #include "base/prefs/scoped_user_pref_update.h" 14 #include "base/prefs/scoped_user_pref_update.h"
14 #include "base/thread_task_runner_handle.h" 15 #include "base/thread_task_runner_handle.h"
15 #include "base/time/time.h" 16 #include "base/time/time.h"
16 #include "base/values.h" 17 #include "base/values.h"
17 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/extensions/component_loader.h" 19 #include "chrome/browser/extensions/component_loader.h"
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 new base::DictionaryValue(), 234 new base::DictionaryValue(),
234 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 235 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
235 registry->RegisterBooleanPref( 236 registry->RegisterBooleanPref(
236 prefs::kEasyUnlockProximityRequired, 237 prefs::kEasyUnlockProximityRequired,
237 false, 238 false,
238 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); 239 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
239 } 240 }
240 241
241 // static 242 // static
242 void EasyUnlockService::RegisterPrefs(PrefRegistrySimple* registry) { 243 void EasyUnlockService::RegisterPrefs(PrefRegistrySimple* registry) {
244 registry->RegisterStringPref(prefs::kEasyUnlockDeviceId, std::string());
245 registry->RegisterDictionaryPref(prefs::kEasyUnlockHardlockState);
243 registry->RegisterDictionaryPref(prefs::kEasyUnlockLocalStateUserPrefs); 246 registry->RegisterDictionaryPref(prefs::kEasyUnlockLocalStateUserPrefs);
244 registry->RegisterDictionaryPref(prefs::kEasyUnlockHardlockState);
245 #if defined(OS_CHROMEOS) 247 #if defined(OS_CHROMEOS)
246 EasyUnlockTpmKeyManager::RegisterLocalStatePrefs(registry); 248 EasyUnlockTpmKeyManager::RegisterLocalStatePrefs(registry);
247 #endif 249 #endif
248 } 250 }
249 251
250 // static 252 // static
251 void EasyUnlockService::ResetLocalStateForUser(const std::string& user_id) { 253 void EasyUnlockService::ResetLocalStateForUser(const std::string& user_id) {
252 DCHECK(!user_id.empty()); 254 DCHECK(!user_id.empty());
253 255
254 PrefService* local_state = GetLocalState(); 256 PrefService* local_state = GetLocalState();
(...skipping 28 matching lines...) Expand all
283 &user_prefs_dict)) 285 &user_prefs_dict))
284 return user_settings; 286 return user_settings;
285 287
286 user_prefs_dict->GetBooleanWithoutPathExpansion( 288 user_prefs_dict->GetBooleanWithoutPathExpansion(
287 prefs::kEasyUnlockProximityRequired, 289 prefs::kEasyUnlockProximityRequired,
288 &user_settings.require_close_proximity); 290 &user_settings.require_close_proximity);
289 291
290 return user_settings; 292 return user_settings;
291 } 293 }
292 294
295 // static
296 std::string EasyUnlockService::GetDeviceId() {
297 PrefService* local_state = GetLocalState();
298 if (!local_state)
299 return std::string();
300
301 std::string device_id =
302 local_state->GetString(prefs::kEasyUnlockDeviceId);
303 if (device_id.empty()) {
304 device_id = base::GenerateGUID();
305 local_state->SetString(prefs::kEasyUnlockDeviceId, device_id);
306 }
307 return device_id;
308 }
309
293 bool EasyUnlockService::IsAllowed() { 310 bool EasyUnlockService::IsAllowed() {
294 if (shut_down_) 311 if (shut_down_)
295 return false; 312 return false;
296 313
297 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 314 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
298 proximity_auth::switches::kDisableEasyUnlock)) { 315 proximity_auth::switches::kDisableEasyUnlock)) {
299 return false; 316 return false;
300 } 317 }
301 318
302 if (!IsAllowedInternal()) 319 if (!IsAllowedInternal())
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 779
763 // TODO(tbarzic): Set check_private_key only if previous sign-in attempt 780 // TODO(tbarzic): Set check_private_key only if previous sign-in attempt
764 // failed. 781 // failed.
765 EasyUnlockTpmKeyManagerFactory::GetInstance()->Get(profile_) 782 EasyUnlockTpmKeyManagerFactory::GetInstance()->Get(profile_)
766 ->PrepareTpmKey(true /* check_private_key */, 783 ->PrepareTpmKey(true /* check_private_key */,
767 base::Closure()); 784 base::Closure());
768 #endif // defined(OS_CHROMEOS) 785 #endif // defined(OS_CHROMEOS)
769 786
770 tpm_key_checked_ = true; 787 tpm_key_checked_ = true;
771 } 788 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698