Chromium Code Reviews| Index: chrome/browser/signin/easy_unlock_service.cc |
| diff --git a/chrome/browser/signin/easy_unlock_service.cc b/chrome/browser/signin/easy_unlock_service.cc |
| index e4408a1b471359dfe37029a2440dafcdd41b02ff..10d2a20aa40bff0ec220f26a389e116bd3f093bb 100644 |
| --- a/chrome/browser/signin/easy_unlock_service.cc |
| +++ b/chrome/browser/signin/easy_unlock_service.cc |
| @@ -187,19 +187,25 @@ void EasyUnlockService::RegisterProfilePrefs( |
| // static |
| void EasyUnlockService::RegisterPrefs(PrefRegistrySimple* registry) { |
| + registry->RegisterDictionaryPref(prefs::kEasyUnlockFirstRunComplete); |
| registry->RegisterDictionaryPref(prefs::kEasyUnlockHardlockState); |
| } |
| // static |
| -void EasyUnlockService::RemoveHardlockStateForUser(const std::string& user_id) { |
| +void EasyUnlockService::ResetLocalStateForUser(const std::string& user_id) { |
| DCHECK(!user_id.empty()); |
| PrefService* local_state = GetLocalState(); |
| if (!local_state) |
| return; |
| - DictionaryPrefUpdate update(local_state, prefs::kEasyUnlockHardlockState); |
| - update->RemoveWithoutPathExpansion(user_id, NULL); |
| + DictionaryPrefUpdate hardlock_update(local_state, |
| + prefs::kEasyUnlockHardlockState); |
| + hardlock_update->RemoveWithoutPathExpansion(user_id, NULL); |
| + |
| + DictionaryPrefUpdate first_run_update(local_state, |
| + prefs::kEasyUnlockFirstRunComplete); |
| + first_run_update->RemoveWithoutPathExpansion(user_id, NULL); |
| } |
| bool EasyUnlockService::IsAllowed() { |
| @@ -260,10 +266,13 @@ EasyUnlockScreenlockStateHandler* |
| if (!IsAllowed()) |
| return NULL; |
| if (!screenlock_state_handler_) { |
| + std::string user_id = GetUserEmail(); |
| + if (GetType() == TYPE_REGULAR) |
| + MaybeMigrateShowTutorialPref(user_id); |
| screenlock_state_handler_.reset(new EasyUnlockScreenlockStateHandler( |
| - GetUserEmail(), |
| + user_id, |
| GetHardlockState(), |
| - GetType() == TYPE_REGULAR ? profile_->GetPrefs() : NULL, |
| + GetLocalState(), |
| ScreenlockBridge::Get())); |
| } |
| return screenlock_state_handler_.get(); |
| @@ -521,6 +530,21 @@ void EasyUnlockService::SetHardlockStateForUser( |
| SetScreenlockHardlockedState(state); |
| } |
| +void EasyUnlockService::MaybeMigrateShowTutorialPref( |
| + const std::string& user_id) { |
| + DCHECK_EQ(TYPE_REGULAR, GetType()); |
| + |
| + PrefService* local_state = GetLocalState(); |
| + // The default value for kEasyUnlockShowTutorial pref is true. |
| + if (user_id.empty() || !local_state || |
| + profile_->GetPrefs()->GetBoolean(prefs::kEasyUnlockShowTutorial)) |
| + return; |
| + profile_->GetPrefs()->SetBoolean(prefs::kEasyUnlockShowTutorial, true); |
|
xiyuan
2014/10/08 19:57:25
nit: How about ClearPref() here?
tbarzic
2014/10/09 02:43:24
Done.
|
| + |
| + DictionaryPrefUpdate update(local_state, prefs::kEasyUnlockFirstRunComplete); |
| + update->SetBooleanWithoutPathExpansion(user_id, true); |
| +} |
| + |
| #if defined(OS_CHROMEOS) |
| void EasyUnlockService::OnCryptohomeKeysFetchedForChecking( |
| const std::string& user_id, |