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

Unified Diff: chrome/browser/chromeos/policy/recommendation_restorer.cc

Issue 136633005: Turn back spoken feedback setting into a system-wide (non-per-user) preference (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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/chromeos/policy/recommendation_restorer.cc
diff --git a/chrome/browser/chromeos/policy/recommendation_restorer.cc b/chrome/browser/chromeos/policy/recommendation_restorer.cc
index aaf19e08b155627ae23fe08d63688e0877dd52e6..d3e0c63a45f074b92769bbed9d5bd07c1c0004b9 100644
--- a/chrome/browser/chromeos/policy/recommendation_restorer.cc
+++ b/chrome/browser/chromeos/policy/recommendation_restorer.cc
@@ -13,6 +13,7 @@
#include "base/prefs/pref_service.h"
#include "base/time/time.h"
#include "base/values.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h"
@@ -33,22 +34,27 @@ RecommendationRestorer::RecommendationRestorer(Profile* profile)
if (!chromeos::ProfileHelper::IsSigninProfile(profile))
return;
+ global_pref_change_registrar_.Init(g_browser_process->local_state());
+ global_pref_change_registrar_.Add(
+ prefs::kSpokenFeedbackEnabled,
+ base::Bind(&RecommendationRestorer::RestoreGlobalPref,
+ base::Unretained(this), true));
+
pref_change_registrar_.Init(profile->GetPrefs());
- pref_change_registrar_.Add(prefs::kLargeCursorEnabled,
- base::Bind(&RecommendationRestorer::Restore,
- base::Unretained(this), true));
- pref_change_registrar_.Add(prefs::kSpokenFeedbackEnabled,
- base::Bind(&RecommendationRestorer::Restore,
- base::Unretained(this), true));
- pref_change_registrar_.Add(prefs::kHighContrastEnabled,
- base::Bind(&RecommendationRestorer::Restore,
- base::Unretained(this), true));
+ pref_change_registrar_.Add(
+ prefs::kLargeCursorEnabled,
+ base::Bind(&RecommendationRestorer::RestoreUserPref,
+ base::Unretained(this), true));
+ pref_change_registrar_.Add(
+ prefs::kHighContrastEnabled,
+ base::Bind(&RecommendationRestorer::RestoreUserPref,
+ base::Unretained(this), true));
pref_change_registrar_.Add(prefs::kScreenMagnifierEnabled,
- base::Bind(&RecommendationRestorer::Restore,
- base::Unretained(this), true));
+ base::Bind(&RecommendationRestorer::RestoreUserPref,
+ base::Unretained(this), true));
pref_change_registrar_.Add(prefs::kScreenMagnifierType,
- base::Bind(&RecommendationRestorer::Restore,
- base::Unretained(this), true));
+ base::Bind(&RecommendationRestorer::RestoreUserPref,
+ base::Unretained(this), true));
notification_registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_CHANGED,
content::NotificationService::AllSources());
@@ -62,6 +68,7 @@ RecommendationRestorer::~RecommendationRestorer() {
void RecommendationRestorer::Shutdown() {
StopTimer();
pref_change_registrar_.RemoveAll();
+ global_pref_change_registrar_.RemoveAll();
notification_registrar_.RemoveAll();
}
@@ -84,10 +91,24 @@ void RecommendationRestorer::OnUserActivity(const ui::Event* event) {
restore_timer_.Reset();
}
-void RecommendationRestorer::Restore(bool allow_delay,
- const std::string& pref_name) {
+void RecommendationRestorer::RestoreUserPref(bool allow_delay,
+ const std::string& pref_name) {
+ RestorePrefInternal(allow_delay, pref_change_registrar_.prefs(), pref_name);
+}
+
+void RecommendationRestorer::RestoreGlobalPref(bool allow_delay,
+ const std::string& pref_name) {
+ RestorePrefInternal(allow_delay,
+ global_pref_change_registrar_.prefs(),
+ pref_name);
+}
+
+void RecommendationRestorer::RestorePrefInternal(
+ bool allow_delay,
+ PrefService* prefs,
+ const std::string& pref_name) {
const PrefService::Preference* pref =
- pref_change_registrar_.prefs()->FindPreference(pref_name.c_str());
+ prefs->FindPreference(pref_name.c_str());
if (!pref) {
NOTREACHED();
return;
@@ -108,15 +129,15 @@ void RecommendationRestorer::Restore(bool allow_delay,
if (allow_delay)
StartTimer();
else
- pref_change_registrar_.prefs()->ClearPref(pref->name().c_str());
+ prefs->ClearPref(pref->name().c_str());
}
void RecommendationRestorer::RestoreAll() {
- Restore(false, prefs::kLargeCursorEnabled);
- Restore(false, prefs::kSpokenFeedbackEnabled);
- Restore(false, prefs::kHighContrastEnabled);
- Restore(false, prefs::kScreenMagnifierEnabled);
- Restore(false, prefs::kScreenMagnifierType);
+ RestoreGlobalPref(false, prefs::kSpokenFeedbackEnabled);
+ RestoreUserPref(false, prefs::kLargeCursorEnabled);
+ RestoreUserPref(false, prefs::kHighContrastEnabled);
+ RestoreUserPref(false, prefs::kScreenMagnifierEnabled);
+ RestoreUserPref(false, prefs::kScreenMagnifierType);
}
void RecommendationRestorer::StartTimer() {

Powered by Google App Engine
This is Rietveld 408576698