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

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: 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..503b1162696a091eb242c4d9a4948f99af71b916
--- /dev/null
+++ b/chrome/browser/accessibility/font_size_prefs.cc
@@ -0,0 +1,69 @@
+// 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 "base/observer_list.h"
+#include "base/prefs/pref_change_registrar.h"
+#include "base/prefs/pref_service.h"
+#include "base/values.h"
+#include "chrome/browser/accessibility/font_size_prefs.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_android.h"
+#include "chrome/browser/profiles/profile_manager.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() {
+ 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