| 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()));
|
| +}
|
|
|