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

Unified Diff: chrome/browser/signin/easy_unlock_service_regular.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, 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/signin/easy_unlock_service_regular.cc
diff --git a/chrome/browser/signin/easy_unlock_service_regular.cc b/chrome/browser/signin/easy_unlock_service_regular.cc
index 1132a46e8bfce92d626c4a9e4ac2413381ebc4e6..e043bb49058af04ee8a6d89cd9cd009e2bfaf2ac 100644
--- a/chrome/browser/signin/easy_unlock_service_regular.cc
+++ b/chrome/browser/signin/easy_unlock_service_regular.cc
@@ -9,6 +9,7 @@
#include "base/prefs/pref_service.h"
#include "base/prefs/scoped_user_pref_update.h"
#include "base/values.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
@@ -257,6 +258,9 @@ void EasyUnlockServiceRegular::InitializeInternal() {
prefs::kEasyUnlockAllowed,
base::Bind(&EasyUnlockServiceRegular::OnPrefsChanged,
base::Unretained(this)));
+ registrar_.Add(prefs::kEasyUnlockProximityRequired,
+ base::Bind(&EasyUnlockServiceRegular::OnPrefsChanged,
+ base::Unretained(this)));
OnPrefsChanged();
}
@@ -288,6 +292,7 @@ bool EasyUnlockServiceRegular::IsAllowedInternal() {
}
void EasyUnlockServiceRegular::OnPrefsChanged() {
+ SyncProfilePrefsToLocalState();
UpdateAppState();
}
@@ -310,3 +315,24 @@ void EasyUnlockServiceRegular::OnToggleEasyUnlockApiFailed(
LOG(WARNING) << "Failed to turn off Smart Lock: " << error_message;
SetTurnOffFlowStatus(FAIL);
}
+
+void EasyUnlockServiceRegular::SyncProfilePrefsToLocalState() {
+ PrefService* local_state =
+ g_browser_process ? g_browser_process->local_state() : NULL;
+ PrefService* profile_prefs = profile()->GetPrefs();
+ if (!local_state || !profile_prefs)
+ return;
+
+ // Create the dictionary of Easy Unlock preferences for the current user. The
+ // items in the dictionary are the same profile prefs used for Easy Unlock.
+ scoped_ptr<base::DictionaryValue> user_prefs_dict(
+ new base::DictionaryValue());
+ user_prefs_dict->SetBooleanWithoutPathExpansion(
+ prefs::kEasyUnlockProximityRequired,
+ profile_prefs->GetBoolean(prefs::kEasyUnlockProximityRequired));
+
+ DictionaryPrefUpdate update(local_state,
+ prefs::kEasyUnlockLocalStateUserPrefs);
+ std::string user_email = GetUserEmail();
+ update->SetWithoutPathExpansion(user_email, user_prefs_dict.Pass());
+}
« no previous file with comments | « chrome/browser/signin/easy_unlock_service_regular.h ('k') | chrome/common/extensions/api/easy_unlock_private.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698