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

Unified Diff: chrome/browser/accessibility/font_size_prefs.cc

Issue 415343002: Upstream accessibility font size preferences. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Made callback methods private, test expect statements changed, styling Created 6 years, 5 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/accessibility/font_size_prefs.cc
diff --git a/chrome/browser/accessibility/font_size_prefs.cc b/chrome/browser/accessibility/font_size_prefs.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fac26f62ab1e24756ca86fc0b60bdd6c6018df84
--- /dev/null
+++ b/chrome/browser/accessibility/font_size_prefs.cc
@@ -0,0 +1,68 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/accessibility/font_size_prefs.h"
+
+#include "base/observer_list.h"
+#include "base/prefs/pref_change_registrar.h"
+#include "base/prefs/pref_service.h"
+#include "base/values.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/pref_names.h"
+
+FontSizePrefs::FontSizePrefs(Profile* profile) {
+ pref_service_ = profile->GetPrefs();
+ pref_change_registrar_.reset(new PrefChangeRegistrar);
+ pref_change_registrar_->Init(pref_service_);
+ pref_change_registrar_->Add(
+ prefs::kWebKitFontScaleFactor,
+ base::Bind(&FontSizePrefs::OnFontScaleFactorPrefsChanged,
+ base::Unretained(this)));
+ pref_change_registrar_->Add(
+ prefs::kWebKitForceEnableZoom,
+ base::Bind(&FontSizePrefs::OnForceEnableZoomPrefsChanged,
+ base::Unretained(this)));
+}
+
+FontSizePrefs::~FontSizePrefs() {
+}
+
+void FontSizePrefs::Destroy() {
+ delete this;
+}
+
+void FontSizePrefs::SetFontScaleFactor(float font) {
+ pref_service_->SetDouble(prefs::kWebKitFontScaleFactor,
+ static_cast<double>(font));
+}
+
+float FontSizePrefs::GetFontScaleFactor() {
+ return pref_service_->GetDouble(prefs::kWebKitFontScaleFactor);
+}
+
+void FontSizePrefs::OnFontScaleFactorPrefsChanged() {
robliao 2014/07/25 23:49:34 Follow same order as header file.
sunangel 2014/07/28 21:17:20 Done.
+ FOR_EACH_OBSERVER(
+ Observer, observers_, OnChangeFontSize(GetFontScaleFactor()));
+}
+
+void FontSizePrefs::AddObserver(Observer* obs) {
+ observers_.AddObserver(obs);
+}
+
+void FontSizePrefs::RemoveObserver(Observer* obs) {
+ observers_.RemoveObserver(obs);
+}
+
+void FontSizePrefs::SetForceEnableZoom(bool enabled) {
+ pref_service_->SetBoolean(prefs::kWebKitForceEnableZoom, enabled);
+}
+
+bool FontSizePrefs::GetForceEnableZoom() {
+ return pref_service_->GetBoolean(prefs::kWebKitForceEnableZoom);
+}
+
+void FontSizePrefs::OnForceEnableZoomPrefsChanged() {
+ FOR_EACH_OBSERVER(
+ Observer, observers_, OnChangeForceEnableZoom(GetForceEnableZoom()));
+}

Powered by Google App Engine
This is Rietveld 408576698