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

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: Created 5 years, 11 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() : check_close_proximity(false) {
69 }
70
71 EasyUnlockService::UserSettings::~UserSettings() {
72 }
73
68 // static 74 // static
69 EasyUnlockService* EasyUnlockService::Get(Profile* profile) { 75 EasyUnlockService* EasyUnlockService::Get(Profile* profile) {
70 return EasyUnlockServiceFactory::GetForProfile(profile); 76 return EasyUnlockServiceFactory::GetForProfile(profile);
71 } 77 }
72 78
73 // static 79 // static
74 EasyUnlockService* EasyUnlockService::GetForUser( 80 EasyUnlockService* EasyUnlockService::GetForUser(
75 const user_manager::User& user) { 81 const user_manager::User& user) {
76 #if defined(OS_CHROMEOS) 82 #if defined(OS_CHROMEOS)
77 Profile* profile = chromeos::ProfileHelper::Get()->GetProfileByUser(&user); 83 Profile* profile = chromeos::ProfileHelper::Get()->GetProfileByUser(&user);
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 new base::DictionaryValue(), 232 new base::DictionaryValue(),
227 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 233 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
228 registry->RegisterBooleanPref( 234 registry->RegisterBooleanPref(
229 prefs::kEasyUnlockProximityRequired, 235 prefs::kEasyUnlockProximityRequired,
230 false, 236 false,
231 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); 237 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
232 } 238 }
233 239
234 // static 240 // static
235 void EasyUnlockService::RegisterPrefs(PrefRegistrySimple* registry) { 241 void EasyUnlockService::RegisterPrefs(PrefRegistrySimple* registry) {
242 registry->RegisterDictionaryPref(prefs::kEasyUnlockLocalStateUserPrefs);
236 registry->RegisterDictionaryPref(prefs::kEasyUnlockHardlockState); 243 registry->RegisterDictionaryPref(prefs::kEasyUnlockHardlockState);
237 #if defined(OS_CHROMEOS) 244 #if defined(OS_CHROMEOS)
238 EasyUnlockTpmKeyManager::RegisterLocalStatePrefs(registry); 245 EasyUnlockTpmKeyManager::RegisterLocalStatePrefs(registry);
239 #endif 246 #endif
240 } 247 }
241 248
242 // static 249 // static
243 void EasyUnlockService::ResetLocalStateForUser(const std::string& user_id) { 250 void EasyUnlockService::ResetLocalStateForUser(const std::string& user_id) {
244 DCHECK(!user_id.empty()); 251 DCHECK(!user_id.empty());
245 252
246 PrefService* local_state = GetLocalState(); 253 PrefService* local_state = GetLocalState();
247 if (!local_state) 254 if (!local_state)
248 return; 255 return;
249 256
250 DictionaryPrefUpdate update(local_state, prefs::kEasyUnlockHardlockState); 257 DictionaryPrefUpdate update(local_state, prefs::kEasyUnlockHardlockState);
251 update->RemoveWithoutPathExpansion(user_id, NULL); 258 update->RemoveWithoutPathExpansion(user_id, NULL);
252 259
253 #if defined(OS_CHROMEOS) 260 #if defined(OS_CHROMEOS)
254 EasyUnlockTpmKeyManager::ResetLocalStateForUser(user_id); 261 EasyUnlockTpmKeyManager::ResetLocalStateForUser(user_id);
255 #endif 262 #endif
256 } 263 }
257 264
265 // static
266 EasyUnlockService::UserSettings EasyUnlockService::GetUserSettings(
267 const std::string& user_id) {
268 DCHECK(!user_id.empty());
269 UserSettings user_settings;
270
271 PrefService* local_state = GetLocalState();
272 if (!local_state)
273 return user_settings;
274
275 const base::DictionaryValue* all_user_prefs_dict =
276 local_state->GetDictionary(prefs::kEasyUnlockLocalStateUserPrefs);
277 if (!all_user_prefs_dict)
278 return user_settings;
279
280 const base::DictionaryValue* user_prefs_dict;
281 if (!all_user_prefs_dict->GetDictionaryWithoutPathExpansion(user_id,
282 &user_prefs_dict))
283 return user_settings;
284
285 user_prefs_dict->GetBooleanWithoutPathExpansion(
286 prefs::kEasyUnlockProximityRequired,
287 &user_settings.check_close_proximity);
288
289 return user_settings;
290 }
291
258 bool EasyUnlockService::IsAllowed() { 292 bool EasyUnlockService::IsAllowed() {
259 if (shut_down_) 293 if (shut_down_)
260 return false; 294 return false;
261 295
262 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 296 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
263 proximity_auth::switches::kDisableEasyUnlock)) { 297 proximity_auth::switches::kDisableEasyUnlock)) {
264 return false; 298 return false;
265 } 299 }
266 300
267 if (!IsAllowedInternal()) 301 if (!IsAllowedInternal())
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 755
722 // TODO(tbarzic): Set check_private_key only if previous sign-in attempt 756 // TODO(tbarzic): Set check_private_key only if previous sign-in attempt
723 // failed. 757 // failed.
724 EasyUnlockTpmKeyManagerFactory::GetInstance()->Get(profile_) 758 EasyUnlockTpmKeyManagerFactory::GetInstance()->Get(profile_)
725 ->PrepareTpmKey(true /* check_private_key */, 759 ->PrepareTpmKey(true /* check_private_key */,
726 base::Closure()); 760 base::Closure());
727 #endif // defined(OS_CHROMEOS) 761 #endif // defined(OS_CHROMEOS)
728 762
729 tpm_key_checked_ = true; 763 tpm_key_checked_ = true;
730 } 764 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698