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

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

Issue 880603003: Copy Smart Lock user preferences to local state so we can access them on the sign-in screen. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: change name to requireCloseProximity 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/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 ExtensionService* extension_service = extension_system->extension_service(); 58 ExtensionService* extension_service = extension_system->extension_service();
59 return extension_service->component_loader(); 59 return extension_service->component_loader();
60 } 60 }
61 61
62 PrefService* GetLocalState() { 62 PrefService* GetLocalState() {
63 return g_browser_process ? g_browser_process->local_state() : NULL; 63 return g_browser_process ? g_browser_process->local_state() : NULL;
64 } 64 }
65 65
66 } // namespace 66 } // namespace
67 67
68 EasyUnlockService::UserSettings::UserSettings()
69 : require_close_proximity(false) {
70 }
71
72 EasyUnlockService::UserSettings::~UserSettings() {
73 }
74
68 // static 75 // static
69 EasyUnlockService* EasyUnlockService::Get(Profile* profile) { 76 EasyUnlockService* EasyUnlockService::Get(Profile* profile) {
70 return EasyUnlockServiceFactory::GetForProfile(profile); 77 return EasyUnlockServiceFactory::GetForProfile(profile);
71 } 78 }
72 79
73 // static 80 // static
74 EasyUnlockService* EasyUnlockService::GetForUser( 81 EasyUnlockService* EasyUnlockService::GetForUser(
75 const user_manager::User& user) { 82 const user_manager::User& user) {
76 #if defined(OS_CHROMEOS) 83 #if defined(OS_CHROMEOS)
77 Profile* profile = chromeos::ProfileHelper::Get()->GetProfileByUser(&user); 84 Profile* profile = chromeos::ProfileHelper::Get()->GetProfileByUser(&user);
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 new base::DictionaryValue(), 233 new base::DictionaryValue(),
227 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 234 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
228 registry->RegisterBooleanPref( 235 registry->RegisterBooleanPref(
229 prefs::kEasyUnlockProximityRequired, 236 prefs::kEasyUnlockProximityRequired,
230 false, 237 false,
231 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); 238 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
232 } 239 }
233 240
234 // static 241 // static
235 void EasyUnlockService::RegisterPrefs(PrefRegistrySimple* registry) { 242 void EasyUnlockService::RegisterPrefs(PrefRegistrySimple* registry) {
243 registry->RegisterDictionaryPref(prefs::kEasyUnlockLocalStateUserPrefs);
236 registry->RegisterDictionaryPref(prefs::kEasyUnlockHardlockState); 244 registry->RegisterDictionaryPref(prefs::kEasyUnlockHardlockState);
237 #if defined(OS_CHROMEOS) 245 #if defined(OS_CHROMEOS)
238 EasyUnlockTpmKeyManager::RegisterLocalStatePrefs(registry); 246 EasyUnlockTpmKeyManager::RegisterLocalStatePrefs(registry);
239 #endif 247 #endif
240 } 248 }
241 249
242 // static 250 // static
243 void EasyUnlockService::ResetLocalStateForUser(const std::string& user_id) { 251 void EasyUnlockService::ResetLocalStateForUser(const std::string& user_id) {
244 DCHECK(!user_id.empty()); 252 DCHECK(!user_id.empty());
245 253
246 PrefService* local_state = GetLocalState(); 254 PrefService* local_state = GetLocalState();
247 if (!local_state) 255 if (!local_state)
248 return; 256 return;
249 257
250 DictionaryPrefUpdate update(local_state, prefs::kEasyUnlockHardlockState); 258 DictionaryPrefUpdate update(local_state, prefs::kEasyUnlockHardlockState);
251 update->RemoveWithoutPathExpansion(user_id, NULL); 259 update->RemoveWithoutPathExpansion(user_id, NULL);
252 260
253 #if defined(OS_CHROMEOS) 261 #if defined(OS_CHROMEOS)
254 EasyUnlockTpmKeyManager::ResetLocalStateForUser(user_id); 262 EasyUnlockTpmKeyManager::ResetLocalStateForUser(user_id);
255 #endif 263 #endif
256 } 264 }
257 265
266 // static
267 EasyUnlockService::UserSettings EasyUnlockService::GetUserSettings(
268 const std::string& user_id) {
269 DCHECK(!user_id.empty());
270 UserSettings user_settings;
271
272 PrefService* local_state = GetLocalState();
273 if (!local_state)
274 return user_settings;
275
276 const base::DictionaryValue* all_user_prefs_dict =
277 local_state->GetDictionary(prefs::kEasyUnlockLocalStateUserPrefs);
278 if (!all_user_prefs_dict)
279 return user_settings;
280
281 const base::DictionaryValue* user_prefs_dict;
282 if (!all_user_prefs_dict->GetDictionaryWithoutPathExpansion(user_id,
283 &user_prefs_dict))
284 return user_settings;
285
286 user_prefs_dict->GetBooleanWithoutPathExpansion(
287 prefs::kEasyUnlockProximityRequired,
288 &user_settings.require_close_proximity);
289
290 return user_settings;
291 }
292
258 bool EasyUnlockService::IsAllowed() { 293 bool EasyUnlockService::IsAllowed() {
259 if (shut_down_) 294 if (shut_down_)
260 return false; 295 return false;
261 296
262 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 297 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
263 proximity_auth::switches::kDisableEasyUnlock)) { 298 proximity_auth::switches::kDisableEasyUnlock)) {
264 return false; 299 return false;
265 } 300 }
266 301
267 if (!IsAllowedInternal()) 302 if (!IsAllowedInternal())
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 756
722 // TODO(tbarzic): Set check_private_key only if previous sign-in attempt 757 // TODO(tbarzic): Set check_private_key only if previous sign-in attempt
723 // failed. 758 // failed.
724 EasyUnlockTpmKeyManagerFactory::GetInstance()->Get(profile_) 759 EasyUnlockTpmKeyManagerFactory::GetInstance()->Get(profile_)
725 ->PrepareTpmKey(true /* check_private_key */, 760 ->PrepareTpmKey(true /* check_private_key */,
726 base::Closure()); 761 base::Closure());
727 #endif // defined(OS_CHROMEOS) 762 #endif // defined(OS_CHROMEOS)
728 763
729 tpm_key_checked_ = true; 764 tpm_key_checked_ = true;
730 } 765 }
OLDNEW
« no previous file with comments | « chrome/browser/signin/easy_unlock_service.h ('k') | chrome/browser/signin/easy_unlock_service_regular.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698